Skip to content

Commit

Permalink
Use setuptools_scm to auto-generate version (NVIDIA#737)
Browse files Browse the repository at this point in the history
* Use setuptools_scm to auto-generate version

[setuptools_scm](https://github.com/pypa/setuptools_scm) is the de-facto
standard to automate the version information of a Python project. It
uses information from version control system like git to generate
[PEP 440](https://peps.python.org/pep-0440/) version identifiers.

The version number is generated on build time and included in source
dist and Python wheels. It works with `pip install` from a local
checkout or git checkout URL.

For git repositories, the version from the last git tag in the history.
If the current checkout is not in tag, setuptools_scm includes git tag
revision and count since last tag in the version. This information is
useful to debug development checkouts.

Example: `cli-0.10.2.dev4+g724d895` means four commits (`dev4`) after
release tag `v0.10.1` (sic!).

The change also fixes a problem with PR NVIDIA#727. It added dynamic version
without actually making the version dynamic.

Also run tests whenever `pyproject.toml` or requirements are modified.

Resolves: NVIDIA#268
Resolves: NVIDIA#736
Signed-off-by: Christian Heimes <[email protected]>
Signed-off-by: Mark Sturdevant <[email protected]>
  • Loading branch information
tiran authored Apr 4, 2024
1 parent f1864ac commit 03f7b90
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@ on:
- "main"
paths:
- '**.py'
- 'scripts/*.sh'
- 'pyproject.toml'
- 'requirements*.txt'
- 'tox.ini'
- 'scripts/*.sh'
pull_request:
branches:
- "main"
paths:
- '**.py'
- 'scripts/*.sh'
- 'pyproject.toml'
- 'requirements*.txt'
- 'tox.ini'
- 'scripts/*.sh'

env:
PYTHON_VERSION: 3.11
Expand All @@ -39,6 +43,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# https://github.com/actions/checkout/issues/249
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ on:
- "main"
paths:
- '**.py'
- 'pyproject.toml'
- 'requirements*.txt'
- 'tox.ini'
- 'scripts/*.sh'
pull_request:
branches:
- "main"
paths:
- '**.py'
- 'pyproject.toml'
- 'requirements*.txt'
- 'tox.ini'
- 'scripts/*.sh'

Expand All @@ -42,6 +46,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# https://github.com/actions/checkout/issues/249
fetch-depth: 0

- name: Setup Python ${{ matrix.python }}
uses: actions/setup-python@v5
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ __pycache__/
# C extensions
*.so

# generated by setuptools_scm
/cli/_version.py

# Distribution / packaging
.Python
build/
Expand Down
11 changes: 8 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[project]
name = "cli"
version = "0.0.1"
authors = [
{ name="TBD", email="[email protected]" },
]
Expand All @@ -15,15 +18,17 @@ classifiers = [
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Programming Language :: Python :: 3",
]
dynamic = ["dependencies"]
dynamic = ["dependencies", "version"]

[tool.setuptools_scm]
version_file = "cli/_version.py"

[project.urls]
Homepage = "https://github.com/instruct-lab/cli"
Issues = "https://github.com/instruct-lab/cli/issues"

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}
version = {attr = "cli.__version__"}

[project.scripts]
# defines lab executable
Expand Down
3 changes: 3 additions & 0 deletions scripts/functional-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ trap 'cleanup "$?"' EXIT QUIT INT TERM

rm -f config.yaml

# print version
ilab --version

# pipe 3 carriage returns to ilab init to get past the prompts
echo -e "\n\n\n" | ilab init

Expand Down

0 comments on commit 03f7b90

Please sign in to comment.