Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,44 @@ jobs:
with:
python-version: '3.12'

# A tag that disagrees with the version it claims to publish names the
# release one thing on GitHub and another on PyPI, and the number cannot
# be taken back. SCALCS and HJCFIT both have this gate; dcio did not, and
# 0.1.1 went out with dcio.__version__ still reading 0.1.0 -- a different
# drift, now fixed at the source by deriving it from the metadata.
- name: Tag matches the version
if: startsWith(github.ref, 'refs/tags/v')
run: |
python - <<'PY'
import os, pathlib, re
proj = re.search(r'^version = "([^"]+)"',
pathlib.Path('pyproject.toml').read_text(), re.M).group(1)
tag = os.environ['GITHUB_REF'].removeprefix('refs/tags/v')
if proj != tag:
raise SystemExit(f'tag v{tag} does not match version {proj}')
print('tag and version agree:', proj)
PY

- name: Build
run: |
python -m pip install --upgrade pip build twine
python -m build

# The one thing a hardcoded __version__ could get wrong, asserted against
# the built artifact rather than the source tree.
- name: The wheel reports its own version
run: |
python -m venv /tmp/vcheck
/tmp/vcheck/bin/pip install --quiet dist/*.whl
/tmp/vcheck/bin/python - <<'PY'
import re, pathlib, dcio
proj = re.search(r'^version = "([^"]+)"',
pathlib.Path('pyproject.toml').read_text(), re.M).group(1)
if dcio.__version__ != proj:
raise SystemExit(f'wheel reports {dcio.__version__}, pyproject says {proj}')
print('installed wheel reports', dcio.__version__)
PY

# twine check catches the metadata problems that make a PyPI page render
# badly or an upload fail outright -- a README that is not valid
# reStructuredText or Markdown, a missing long_description content type.
Expand Down
14 changes: 13 additions & 1 deletion dcio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,17 @@
>>> print(rec)
"""

__version__ = "0.1.0"
# Taken from the installed package metadata rather than written here, so it
# cannot drift from pyproject.toml. It already had: 0.1.1 was published with
# pyproject saying 0.1.1 and this saying 0.1.0, so `pip install "dcio>=0.1.1"`
# succeeded and `dcio.__version__` then reported 0.1.0.
try:
from importlib.metadata import PackageNotFoundError, version as _version
try:
__version__ = _version("dcio")
except PackageNotFoundError: # a source tree that was never installed
__version__ = "0.0.0+unknown"
del _version, PackageNotFoundError
except ImportError: # pragma: no cover
__version__ = "0.0.0+unknown"
__author__ = "Remis Lape"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "dcio"
version = "0.1.1"
version = "0.1.2"
description = "I/O and record layer for electrophysiology file formats used by the DCPROGS suite"
readme = "README.md"
license = "MIT"
Expand Down