Skip to content

Commit 9c81a38

Browse files
committed
add hatch-vcs for versioning
1 parent 648e52d commit 9c81a38

File tree

5 files changed

+31
-18
lines changed

5 files changed

+31
-18
lines changed

.github/workflows/main.yml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,18 @@ jobs:
2929
- "3.8"
3030
- "3.9"
3131
- "3.10"
32-
- "3.11.0-beta.4"
33-
- "pypy2"
34-
- "pypy-3.7"
32+
- "3.11.0-beta.5"
33+
- "pypy3.9"
3534
exclude:
3635
- os: macos-latest
3736
python-version: pypy3
3837

3938
steps:
40-
- uses: "actions/checkout@v2"
41-
- uses: "actions/setup-python@v2"
39+
- uses: "actions/checkout@v3"
40+
with:
41+
# We want our tags here
42+
fetch-depth: 0
43+
- uses: "actions/setup-python@v4"
4244
with:
4345
python-version: "${{ matrix.python-version }}"
4446
- name: "Install dependencies"
@@ -63,8 +65,8 @@ jobs:
6365
- tests
6466
runs-on: ubuntu-latest
6567
steps:
66-
- uses: actions/checkout@v2
67-
- uses: actions/setup-python@v2
68+
- uses: actions/checkout@v3
69+
- uses: actions/setup-python@v4
6870
with:
6971
python-version: "3.10"
7072

@@ -98,8 +100,11 @@ jobs:
98100
runs-on: "ubuntu-latest"
99101

100102
steps:
101-
- uses: "actions/checkout@v2"
102-
- uses: "actions/setup-python@v1"
103+
- uses: "actions/checkout@v3"
104+
with:
105+
# We want our tags here
106+
fetch-depth: 0
107+
- uses: "actions/setup-python@v4"
103108
with:
104109
python-version: "3.10"
105110

@@ -109,6 +114,7 @@ jobs:
109114
if: "${{ env.TEST_PYPI_API_TOKEN != '' }}"
110115
run: |
111116
echo "DO_PUBLISH=yes" >> $GITHUB_ENV
117+
echo "SETUPTOOLS_SCM_PRETEND_VERSION=0.0.1" >> $GITHUB_ENV
112118
113119
- name: "Install pep517 and twine"
114120
run: "python -m pip install pep517 twine"
@@ -136,10 +142,10 @@ jobs:
136142
runs-on: "${{ matrix.os }}"
137143

138144
steps:
139-
- uses: "actions/checkout@v2"
140-
- uses: "actions/setup-python@v2"
145+
- uses: "actions/checkout@v3"
146+
- uses: "actions/setup-python@v4"
141147
with:
142-
python-version: "3.9"
148+
python-version: "3.10"
143149
- name: "Install in dev mode"
144150
run: "python -m pip install -e .[dev]"
145151
- name: "Import package"

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ requirements.in
1616
.direnv/
1717
doc/_build/
1818
htmlcov/
19+
src/hamcrest/_version.py
20+
.tool-versions

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
@@ -82,7 +82,10 @@ Source = "https://github.com/hamcrest/PyHamcrest/"
8282
Issues = "https://github.com/hamcrest/PyHamcrest/issues"
8383

8484
[tool.hatch.version]
85-
path = "src/hamcrest/__init__.py"
85+
source = "vcs"
86+
87+
[tool.hatch.build.hooks.vcs]
88+
version-file = "src/hamcrest/_version.py"
8689

8790
[tool.hatch.build.targets.sdist]
8891
exclude = [

src/hamcrest/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from hamcrest.core import *
22
from hamcrest.library import *
33
from hamcrest import core, library
4+
from hamcrest._version import version
45

5-
__version__ = "2.0.4"
6+
__version__ = version
67
__author__ = "Chris Rose"
78
__copyright__ = "Copyright 2020 hamcrest.org"
89
__license__ = "BSD, see License.txt"

tox.ini

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ commands =
115115
coverage combine
116116
coverage report
117117

118-
119118
[testenv:lint]
120119
basepython = python3.9
121120
skip_install = true
@@ -136,9 +135,11 @@ commands =
136135

137136
[testenv:manifest]
138137
basepython = python3.9
139-
deps = check-manifest
138+
deps =
139+
check-manifest
140+
setuptools-scm
140141
skip_install = true
141-
commands = check-manifest
142+
commands = check-manifest --ignore src/hamcrest/_version.py
142143

143144

144145
[testenv:pypi-description]

0 commit comments

Comments
 (0)