Skip to content

Commit 568e662

Browse files
authored
Merge pull request #38 from derb12/update_internals
MAINT: Add dynamic versioning and dependabot for GitHub actions versioning
2 parents 8595c67 + 861b765 commit 568e662

File tree

7 files changed

+65
-26
lines changed

7 files changed

+65
-26
lines changed

.github/dependabot.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# See the documentation for all configuration options:
2+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
3+
4+
version: 2
5+
updates:
6+
- package-ecosystem: "github-actions" # Only update GitHub actions dependencies
7+
directory: "/" # Only update the worflow files
8+
schedule:
9+
interval: "monthly"

.github/workflows/python-test-latest.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
- 'tests/**'
2424
- '.github/workflows/**'
2525

26+
# cancel current jobs if a new job is started
27+
concurrency:
28+
group: ${{ github.workflow }}-${{ github.ref }}
29+
cancel-in-progress: true
30+
2631
jobs:
2732
test-nightly:
2833

@@ -34,10 +39,10 @@ jobs:
3439
python-version: ['3.13']
3540

3641
steps:
37-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
3843

3944
- name: Set up Python ${{ matrix.python-version }}
40-
uses: actions/setup-python@v5
45+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
4146
with:
4247
python-version: ${{ matrix.python-version }}
4348

@@ -47,6 +52,7 @@ jobs:
4752
python -m pip install pytest
4853
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
4954
python -m pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple scipy
55+
python -m pip install .
5056
5157
- name: Test with required dependencies
5258
# use -Werror so that any warnings will show up as errors -> want to be as stringent

.github/workflows/python-test.yml

+18-9
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
- 'tests/**'
2424
- '.github/workflows/**'
2525

26+
# cancel current jobs if a new job is started
27+
concurrency:
28+
group: ${{ github.workflow }}-${{ github.ref }}
29+
cancel-in-progress: true
30+
2631
jobs:
2732
test:
2833

@@ -34,12 +39,16 @@ jobs:
3439
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.13t']
3540

3641
steps:
37-
- uses: actions/checkout@v4
42+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
43+
# fetch-depth: '0' is needed to fetch tags for hatch-vcs (and thus setuptools-scm)
44+
# to generate the version correctly; only really needed for jobs that would build and
45+
# upload to pypi, so ignore it since fetching the entire git history can take much longer
46+
# than the default of fetching just the last commit
47+
#with:
48+
#fetch-depth: '0'
3849

3950
- name: Set up Python
40-
# Switch back to actions/setup-python@v5 once they support free-threaded python;
41-
# see revelant PR: https://github.com/actions/setup-python/pull/973
42-
uses: Quansight-Labs/setup-python@v5
51+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
4352
with:
4453
python-version: ${{ matrix.python-version }}
4554

@@ -71,10 +80,10 @@ jobs:
7180
python-version: ['3.9']
7281

7382
steps:
74-
- uses: actions/checkout@v4
83+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
7584

7685
- name: Set up Python ${{ matrix.python-version }}
77-
uses: actions/setup-python@v5
86+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
7887
with:
7988
python-version: ${{ matrix.python-version }}
8089

@@ -83,7 +92,7 @@ jobs:
8392
# for minimum supported versions
8493
run: |
8594
python -m pip install --upgrade pip
86-
python -m pip install "numpy==1.20.*" "scipy==1.6.*" pytest
95+
python -m pip install . "numpy==1.20.*" "scipy==1.6.*" pytest
8796
8897
- name: Test with minimum required dependencies
8998
run: pytest .
@@ -103,10 +112,10 @@ jobs:
103112
python-version: ['3.13']
104113

105114
steps:
106-
- uses: actions/checkout@v4
115+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
107116

108117
- name: Set up Python ${{ matrix.python-version }}
109-
uses: actions/setup-python@v5
118+
uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
110119
with:
111120
python-version: ${{ matrix.python-version }}
112121

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ wheels/
2121
*.egg-info/
2222
.installed.cfg
2323
*.egg
24+
_version.py
2425

2526
# PyInstaller
2627
# Usually these files are written by a python script from a template

docs/conf.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@
7070
# for |version| and |release|, also used in various other places throughout
7171
# the built documents.
7272
#
73-
# The short X.Y version.
74-
version = '1.2.0'
73+
from importlib.metadata import version as _get_version
7574
# The full version, including alpha/beta/rc tags.
76-
release = version
75+
release = _get_version('pybaselines')
76+
# The short X.Y version.
77+
version = '.'.join(release.split('.')[:2])
7778

7879
# The language for content autogenerated by Sphinx. Refer to documentation
7980
# for a list of supported languages.

pybaselines/__init__.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@
1111
1212
"""
1313

14-
__version__ = '1.2.0'
15-
14+
try:
15+
from ._version import __version__
16+
except ImportError:
17+
# in case of local use without installing first
18+
__version__ = '1.2.0.post1.dev0'
1619

1720
# import utils first since it is imported by other modules; likewise, import
1821
# optimizers and api last since they import the other modules

pyproject.toml

+20-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[build-system]
22
# hatchling v1.27 was first version to use default metadata version 2.4, allowing project.license
33
# and project.license-files fields following PEP-639
4-
requires = ["hatchling>=1.27"]
4+
requires = ["hatchling>=1.27", "hatch-vcs"]
55
build-backend = "hatchling.build"
66

77
[tool.hatch.build]
@@ -13,10 +13,20 @@ exclude = [
1313
"/tools",
1414
]
1515

16+
[tool.hatch.version]
17+
source = "vcs"
18+
fallback-version = "1.2.0.post1.dev0"
19+
20+
[tool.hatch.version.raw-options]
21+
version_scheme = "no-guess-dev"
22+
23+
[tool.hatch.build.hooks.vcs]
24+
version-file = "pybaselines/_version.py"
25+
1626

1727
[project]
1828
name = "pybaselines"
19-
version = "1.2.0"
29+
dynamic = ["version"]
2030
authors = [
2131
{name = "Donald Erb", email = "donnie.erb@gmail.com"},
2232
]
@@ -107,7 +117,7 @@ src_paths = ["pybaselines", "tests"]
107117
known_local_folder = ["example_helpers"]
108118

109119
[tool.ruff]
110-
exclude = ["docs/*"]
120+
exclude = ["docs/conf.py"]
111121
line-length = 100
112122
fix = false
113123
output-format = "full"
@@ -142,7 +152,7 @@ convention = "numpy"
142152
"D205", # D205: 1 blank line required between summary line and description
143153

144154
]
145-
"examples/*" = [
155+
"docs/examples/*" = [
146156
"B007", # B007: Loop control variable `name` not used within loop body; want to be explicit in examples
147157
"D205", # D205: 1 blank line required between summary line and description
148158
"D400", # D400: first line should end with a period
@@ -165,14 +175,14 @@ search = "version = \"{current_version}\""
165175
replace = "version = \"{new_version}\""
166176

167177
[[tool.bumpversion.files]]
168-
filename = "pybaselines/__init__.py"
169-
search = "__version__ = '{current_version}'"
170-
replace = "__version__ = '{new_version}'"
178+
filename = "pyproject.toml"
179+
search = "fallback-version = \"{current_version}.post1.dev0\""
180+
replace = "fallback-version = \"{new_version}.post1.dev0\""
171181

172182
[[tool.bumpversion.files]]
173-
filename = "docs/conf.py"
174-
search = "version = '{current_version}'"
175-
replace = "version = '{new_version}'"
183+
filename = "pybaselines/__init__.py"
184+
search = "__version__ = '{current_version}.post1.dev0'"
185+
replace = "__version__ = '{new_version}.post1.dev0'"
176186

177187
[[tool.bumpversion.files]]
178188
filename = "CITATION.cff"

0 commit comments

Comments
 (0)