Skip to content

Commit

Permalink
Implement Python package versioning (#174)
Browse files Browse the repository at this point in the history
* advice from @gsakkis

* .gitignore file

* black .

* Clarifying comments
  • Loading branch information
johnkerl authored Jun 20, 2022
1 parent 8be06c9 commit c3eae12
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ examples/cmake_project/build
# Python distribution / packaging
.eggs
*.egg-info
apis/python/src/tiledbsc/_version.py

/.quarto/
8 changes: 8 additions & 0 deletions apis/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ requires = [
"pybind11>=2.6.2"
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
version_scheme = "guess-next-dev"
local_scheme = "dirty-tag"
# Relative path to cwd, used for finding the SCM root
root = "../.."
# Path relative to root to a file that gets replaced with a file containing the current version
write_to = "apis/python/src/tiledbsc/_version.py"
5 changes: 0 additions & 5 deletions apis/python/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,3 @@ ci =
pytest
anndata
pybind11

[tool.setuptools_scm]
version_scheme = guess-next-dev
local_scheme = dirty-tag
write_to = ./version.py
4 changes: 0 additions & 4 deletions apis/python/setup.py

This file was deleted.

33 changes: 33 additions & 0 deletions apis/python/src/tiledbsc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# The way this works is:
#
# o We put a `[tool.setuptools_scm]` stanza in pyproject.toml.
#
# o When the user does `pip install .` the src/tiledbsc/_version.py
# file gets created. We have a .gitignore line for that since it
# isn't supposed to go into version control, but rather, is supposed
# to be created at package-setup time.
#
# o The src/tiledbsc/_version.py is created by setuptools by reading
# Git history. If the currently checked-out code is at a version stamp
# like `1.2.3` we'll get `__version__` being `1.2.3`; else we'll get
# something like `1.2.4.dev2`.
#
# o When the user does `import tiledbsc` this code here is run,
# which loads the `src/tiledbsc/_version.py`.
#
# In summary, who needs to do what:
#
# o Package developers: simply create a Git release at
# https://github.com/single-cell-data/TileDB-SingleCell/releases
#
# o Package users: just `pip install .`.
try:
from ._version import version as __version__
except ImportError:
from pkg_resources import DistributionNotFound, get_distribution

try:
__version__ = get_distribution("tiledbsc").version
except DistributionNotFound:
__version__ = "unknown"

from .soma_collection import SOMACollection
from .soma import SOMA
from .soma_options import SOMAOptions
Expand Down

0 comments on commit c3eae12

Please sign in to comment.