conda-incubator / conda-project

Tool for encapsulating, running, and reproducing projects with Conda environments
https://conda-incubator.github.io/conda-project/
BSD 3-Clause "New" or "Revised" License
28 stars 11 forks source link

fix: version string #101

Closed mattkram closed 1 year ago

mattkram commented 1 year ago

Fixes the dynamic loading of package version in the installed package.

We use setuptools-scm to write the version to the file src/conda_project/_version.py. This file is not to be checked into git.

We then dynamically import this file into the global conda_project.__version__.

This file will be generated both during pip install -e ., as well as when generating the source distribution for PyPI via python -m build.

If there is any error importing the _version.py file, the version number will be set to "unknown".

A test has been added to the conda recipe to ensure that the version of the built package is correct.

codecov[bot] commented 1 year ago

Codecov Report

Merging #101 (c0db254) into main (a0bab0f) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #101   +/-   ##
=======================================
  Coverage   96.63%   96.63%           
=======================================
  Files           9        9           
  Lines         742      742           
=======================================
  Hits          717      717           
  Misses         25       25           
Impacted Files Coverage Δ
src/conda_project/__init__.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

mattkram commented 1 year ago

Using a git archive doesn't seem to work, so I've reverted those changes: https://github.com/pypa/setuptools_scm#git-archives

However, I have confirmed that we can publish the source tarball to pypi.org and then build the conda package from that.

We may have an opportunity for some more work in the future to enable building the conda package from the released git tarball, but for now let's plan to build from pypi.org.