capn-freako/PyBERT

Derive project version from a single source.

Closed this issue · 0 comments

Problem Description & Change Request

Currently, we have to record a version change in 3 files:

  • pyproject.toml,
  • conda.recipe/<project>/meta.yaml, and
  • __init__.py.

This is fragile and often results in inconsistent version reporting.

==> Implement some form of single source versioning.

Helpful Resources

The following may contain various bits of information helpful in this pursuit:

Importing information from pyproject.toml into conda-build flow

Code in the meta.yaml similar to the following may be used to import information (such as the project version number) from the pyproject.toml file into the conda-build flow:

{% set pyproject = load_file_data('pyproject.toml') %}
{% set poetry = pyproject.get('tool', {}).get('poetry') %}
package:
  name: {{ poetry.get('name') }}
  version: {{ poetry.get('version') }}

See this page for more detail.

Importing package version from pyproject.toml into __init__.py

This SO answer suggests a way to import the version number from pyproject.toml into __init__.py.
When combined with the above technique, this should allow the pyproject.toml file to become the sole source for package version number information.