Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make version dynamic #25

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

jdblischak
Copy link
Collaborator

Motivation

The version is currently hard-coded as 0.1.0-dev:

__version__ = "0.1.0-dev"

Thus even though there are tags available, they are ignored:

git clone https://github.com/single-cell-data/TileDB-SOMA-ML.git
cd TileDB-SOMA-ML/
git log -n 1 --oneline
## e985fcb (HEAD -> main, origin/main, origin/HEAD) compat GHA: use tdbs 1.15.2 (#24)
git tag -l
## 0.1.0alpha
## 0.1.0alpha2
git describe --dirty --tags --long --match *[0-9]*
## 0.1.0alpha2-1-ge985fcb

python -m venv ./venv-ml
source ./venv-ml/bin/activate
pip install build setuptools-scm

python -m setuptools_scm
## Warning: could not use pyproject.toml, using default configuration.
##  Reason: /tmp/TileDB-SOMA-ML/pyproject.toml does not contain a tool.setuptools_scm section.
## 0.1.0a3.dev1+ge985fcb
python -m build .
## Successfully built tiledbsoma_ml-0.1.0.dev0.tar.gz and tiledbsoma_ml-0.1.0.dev0-py3-none-any.whl
pip install --prefer-binary dist/tiledbsoma_ml-*.tar.gz

pip list | grep tiledbsoma-ml
## tiledbsoma-ml            0.1.0.dev0
# Switch directory to not import source package
cd .. && python -c "import tiledbsoma_ml as soma_ml; print(soma_ml.__version__)"
## 0.1.0-dev

And because of this hard-coding, I can't override the version string in the conda recipe using SETUPTOOLS_SCM_PRETEND_VERSION (TileDB-Inc/tiledb-soma-ml-feedstock#5 (comment)).

Solution

I decided to use the latest setuptools-scm 8+ solution, so I deleted the section tool.setuptools.dynamic, which uses the dynamic metadata feature of setuptools.

I managed to get it working. I also confirmed that SETUPTOOLS_SCM_PRETEND_VERSION mostly works now.

There is still some strangeness. First, our alpha gets truncated to a. I think this is because of PEP 440. Also, it reports 0.1.0a3 (as above in the output from python -m setuptools_scm), which I don't understand. Hopefully once we drop the alpha from our version strings the dynamic versions will be more predictable.

@johnkerl
Copy link
Member

@jdblischak some historical narrative on the tiledbsoma repo's solution(s) to this, in case it's helpful (please disregard if unhelpful)

single-cell-data/TileDB-SOMA#3429

@jdblischak
Copy link
Collaborator Author

some historical narrative on the tiledbsoma repo's solution(s) to this, in case it's helpful (please disregard if unhelpful)

Yes, that is useful context. IIUC my PR supports PEP 440, which is also the goal of single-cell-data/TileDB-SOMA#3429

Though this PR is also much humbler. I am trying to update the repo from its current state of "always reporting the version as 0.1.0-dev" to "report dynamic version via setuptools-scm". If we have additional requirements (eg related to the use of rc for release candidates), we may need to address these in a follow-up PR.

@jdblischak
Copy link
Collaborator Author

The output of import tiledbsoma_ml as soma_ml; print(soma_ml.__version__) now matches that of python -m setuptools_scm: 0.1.0a3.dev3+gcce96b8 (eg here for the py39 build). I don't like how it truncates the tag name from "alpha" to "a", nor do I understand why it bumps from the tag's "alpha2" to "a3", but at least now the version is dynamically generated.

Thoughts on this approach? I am open to alternative solutions. For example, we could use the setuptools-scm option version_file instead of using __version__ = version("tiledbsoma-ml"). I don't have strong feelings about the exact approach as long as it is working.

Copy link
Member

@johnkerl johnkerl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Although I of course defer to @ryan-williams and @bkmartinjr on this repo.

@ryan-williams
Copy link
Member

Thanks @jdblischak, this lgtm, merging

@ryan-williams ryan-williams merged commit 0d11360 into single-cell-data:main Jan 21, 2025
27 checks passed
@jdblischak jdblischak deleted the dynamic-version branch January 21, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants