Skip to content

Commit 2a4e3b4

Browse files
committed
Fix ptf --version
Use setuptools to write a src/ptf/_version.py file. Fixes #186 Signed-off-by: Antonin Bas <abas@vmware.com>
1 parent bb28a88 commit 2a4e3b4

5 files changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
- name: Install
4747
run: |
4848
sudo python3 -m pip install .
49+
ptf --version
4950
5051
- name: Before_script
5152
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ dist
77
build
88
*.egg-info
99
.eggs
10+
11+
src/ptf/_version.py

ptf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if os.path.exists(os.path.join(pydir, "ptf")):
3131
sys.path.insert(0, pydir)
3232

3333
import ptf
34-
from ptf import config
34+
from ptf import config, __version__
3535
import ptf.ptfutils
3636

3737
##@var DEBUG_LEVELS
@@ -225,7 +225,7 @@ be subtracted from the result by prefixing them with the '^' character. """
225225
# Set up default values
226226
parser.set_defaults(**config_default)
227227

228-
parser.add_argument("--version", action="version", version="ptf 0.1")
228+
parser.add_argument("--version", action="version", version=__version__)
229229

230230
parser.add_argument("test_specs", nargs="*", help="Tests / Groups to run")
231231

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ build-backend = 'setuptools.build_meta'
1111
root = "./"
1212
# use current tag and not next one
1313
version_scheme = "post-release"
14+
write_to = "src/ptf/_version.py"

src/ptf/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import os
44
import logging
55

6+
from ._version import __version__
7+
68
# Global config dictionary
79
# Populated by oft.
810
config = {}

0 commit comments

Comments
 (0)