Skip to content

Commit bc45bba

Browse files
authored
Use hatch versioning, drop setuptools (#890)
1 parent 1c7895f commit bc45bba

File tree

10 files changed

+51
-13
lines changed

10 files changed

+51
-13
lines changed

.git_archival.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
4+
ref-names: $Format:%D$

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/workflows/deploy_release.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ jobs:
3939
run: |
4040
tox -e wheelinstall --recreate --installpkg dist/*-none-any.whl
4141
42+
- name: Test installation from a source distribution
43+
run: |
44+
tox -e wheelinstall --recreate --installpkg dist/*.tar.gz
45+
4246
- name: Upload wheel and source distributions to PyPI
4347
run: |
4448
python -m pip install twine

.github/workflows/run_all_tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ jobs:
7979
run: |
8080
tox -e wheelinstall --recreate --installpkg dist/*-none-any.whl
8181
82+
- name: Test installation from a source distribution
83+
run: |
84+
tox -e wheelinstall --recreate --installpkg dist/*.tar.gz
85+
8286
run-all-gallery-tests:
8387
name: ${{ matrix.name }}
8488
runs-on: ${{ matrix.os }}
@@ -185,6 +189,10 @@ jobs:
185189
run: |
186190
tox -e wheelinstall --recreate --installpkg dist/*-none-any.whl
187191
192+
- name: Test installation from a source distribution
193+
run: |
194+
tox -e wheelinstall --recreate --installpkg dist/*.tar.gz
195+
188196
run-gallery-ros3-tests:
189197
name: ${{ matrix.name }}
190198
runs-on: ${{ matrix.os }}

.github/workflows/run_tests.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ jobs:
6363
run: |
6464
tox -e wheelinstall --recreate --installpkg dist/*-none-any.whl
6565
66+
- name: Test installation from a source distribution
67+
run: |
68+
tox -e wheelinstall --recreate --installpkg dist/*.tar.gz
69+
6670
- name: Upload distribution as a workspace artifact
6771
if: ${{ matrix.upload-wheels }}
6872
uses: actions/upload-artifact@v3
@@ -165,6 +169,10 @@ jobs:
165169
run: |
166170
tox -e wheelinstall --recreate --installpkg dist/*-none-any.whl
167171
172+
- name: Test installation from a source distribution
173+
run: |
174+
tox -e wheelinstall --recreate --installpkg dist/*.tar.gz
175+
168176
deploy-dev:
169177
name: Deploy pre-release from dev
170178
needs: [run-tests, run-gallery-tests, run-tests-on-conda]

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ coverage.xml
7171

7272
#sqlite
7373
.sqlite
74+
75+
# Version
76+
_version.py

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@
1010
- Allow for `datetime.date` to be used instead of `datetime.datetime`. @bendichter [#874](https://github.com/hdmf-dev/hdmf/pull/874)
1111
- Updated `HDMFIO` and `HDF5IO` to support `ExternalResources`. @mavaylon1 [#895](https://github.com/hdmf-dev/hdmf/pull/895)
1212
- Dropped Python 3.7 support. @rly [#897](https://github.com/hdmf-dev/hdmf/pull/897)
13+
- Added HTML repr to `Container` objects which displays an interactive tree of a container's values and children in a Jupyter notebook and other HTML representations. @edeno [#883](https://github.com/hdmf-dev/hdmf/pull/883)
1314

1415
### Documentation and tutorial enhancements:
1516
- Added tutorial for the new `TermSet` class @mavaylon1 [#880](https://github.com/hdmf-dev/hdmf/pull/880)
1617

1718
## Bug fixes
1819
- Fixed CI testing of minimum installation requirements, and removed some gallery tests run on each PR. @rly
1920
[#877](https://github.com/hdmf-dev/hdmf/pull/877)
21+
- Fixed reporting of version when installed using conda. @rly [#890](https://github.com/hdmf-dev/hdmf/pull/890)
22+
2023

2124
## HMDF 3.6.1 (May 18, 2023)
2225

pyproject.toml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[build-system]
2-
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
3-
build-backend = "setuptools.build_meta"
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
44

55
[project]
66
name = "hdmf"
@@ -51,8 +51,19 @@ linkml = ["linkml-runtime>=1.5.0"]
5151
[project.scripts]
5252
validate_hdmf_spec = "hdmf.testing.validate_spec:main"
5353

54-
[tool.setuptools.package-data]
55-
hdmf = ["common/hdmf-common-schema/common/*.yaml", "common/hdmf-common-schema/common/*.json"]
54+
[tool.hatch.version]
55+
source = "vcs"
56+
57+
[tool.hatch.build.hooks.vcs]
58+
# this file is created/updated when the package is installed and used in
59+
# src/hdmf/__init__.py to set `hdmf.__version__`
60+
version-file = "src/hdmf/_version.py"
61+
62+
[tool.hatch.build.targets.sdist]
63+
exclude = [".git_archival.txt"]
64+
65+
[tool.hatch.build.targets.wheel]
66+
packages = ["src/hdmf"]
5667

5768
# [tool.mypy]
5869
# no_incremental = true # needed b/c mypy and ruamel.yaml do not play nice. https://github.com/python/mypy/issues/12664
@@ -83,8 +94,6 @@ exclude_lines = [
8394
"@abstract"
8495
]
8596

86-
[tool.setuptools_scm]
87-
8897
# [tool.black]
8998
# line-length = 120
9099
# preview = true

setup.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/hdmf/__init__.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ def get_region_slicer(**kwargs):
2727
return None
2828

2929

30-
from importlib.metadata import version # noqa: E402
31-
32-
__version__ = version(__package__)
33-
del version
30+
try:
31+
# see https://effigies.gitlab.io/posts/python-packaging-2023/
32+
from ._version import __version__
33+
except ImportError: # pragma: no cover
34+
pass
3435

3536

3637
from ._due import BibTeX, due # noqa: E402

0 commit comments

Comments
 (0)