R/Python package versioning and Poetry

I've got some standard automation for a small mono-repo that I've setup and I'm managing it with Poetry since most of the library packages are Python. I'd really like to use automated versioning that's built into poetry combined with the poetry_bumpversion plugin. Since it supports file specific replacement of embedded versions

eg.... convert __version__= "0.0.1" to __version__= "0.0.2"

I'm finding this tool works on incrementing DESCRIPTION file versions for R too, which is awesome. You just have to configure it as such in your pyproject toml file:

[[tool.poetry_bumpversion.replacements]]
files = ["DESCRIPTION"]
search = 'Version: {current_version}'
replace = 'Version: {new_version}'

Anyway, I'd like to use this tool not just for major, minor, and patch releases but also for the various pre- version bumps too using poetry. For example a pre-patch increment would increment from 2.1.1 to 2.1.2a0 or a pre-minor 2.1.1 to 2.2.0a0. My question is does R/RStudio play nice with the appended values that come with Poetry's pre appended versioning?

I know you can be very specific about the version you install using devtools, for example:

devtools::install_version("coolPackage", version="2.2.0a0")

which is what I'd like but I'd rather not someone use install.packages("coolPackage") and install 2.2.0a0 by default, I'd rather they stick with non-pre packages; 2.1.1 in this case.

1 Like

R has very strict rules about valid version strings. From Writing R Extensions:

The mandatory β€˜Version’ field gives the version of the package. This is a sequence of at least two (and usually three) non-negative integers separated by single β€˜.’ or β€˜-’ characters. The canonical form is as shown in the example, and a version such as β€˜0.01’ or β€˜0.01.0’ will be handled as if it were β€˜0.1-0’. It is not a decimal number, so for example 0.9 < 0.75 since 9 < 75.

To confirm, I put 2.1.2a0 into DESCRIPTION of one of my existing R packages and got the following error:

Error : Invalid DESCRIPTION file

Malformed package version.

See section 'The DESCRIPTION file' in the 'Writing R Extensions'
manual.

install.packages() will install whichever version you upload to CRAN. Thus if you only upload 2.1.1, then that is what will be installed. Similarly, remotes::install_github() will install the version that is on the default branch, so you'll have to decide whether to use versions like 2.2.0a0 in the default branch or only in feature branches.

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.