Skip to content

Commit fb5feb9

Browse files
authored
Correctly update version when building wheel (#9)
1 parent 506cc6f commit fb5feb9

File tree

3 files changed

+14
-17
lines changed

3 files changed

+14
-17
lines changed

.github/workflows/test.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ jobs:
3737
pip install pytest
3838
3939
- name: Build in place
40-
run: |
41-
python -m pymsbuild
42-
python -m pymsbuild -c _msbuild_test.py
40+
run: python -m pymsbuild
41+
42+
- name: Build test modules
43+
run: python -m pymsbuild -c _msbuild_test.py
4344

4445
- name: Test with pytest
4546
run: |

_msbuild.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
PyFile("etwtrace/__main__.py"),
6161
PyFile("etwtrace/__init__.py"),
6262
PyFile("etwtrace/_cli.py"),
63-
# _version-ver is generated at build with the correct version number
64-
PyFile("etwtrace/_version-ver.py", name="_version.py"),
63+
PyFile("etwtrace/_version.py", IncludeInLayout=False),
6564

6665
Package(
6766
'profiles',
@@ -115,14 +114,11 @@ def init_METADATA():
115114

116115

117116
def init_PACKAGE(tag=None):
118-
# Create _version-ver.py with replaced %VERSION% from METADATA
119-
VER_PY = PACKAGE.find("_version.py")
120-
try:
121-
f = open("src/etwtrace/_version.py", "r", encoding="utf-8")
122-
except FileNotFoundError:
123-
return
124-
with f:
125-
ver_py = f.read()
126-
ver_py = ver_py.replace("%VERSION%", METADATA["Version"])
127-
with open(f"src/etwtrace/_version-ver.py", "w", encoding="utf-8") as f:
128-
f.write(ver_py)
117+
if tag:
118+
ver = METADATA["Version"]
119+
state = get_current_build_state()
120+
ver_py = state.temp_dir / "_version.py"
121+
state.temp_dir.mkdir(parents=True, exist_ok=True)
122+
with open(ver_py, "w", encoding="utf-8") as f:
123+
print(f'__version__ = "{ver}"', file=f)
124+
PACKAGE.find("_version.py").source = ver_py

src/etwtrace/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1"
1+
__version__ = "0.0"

0 commit comments

Comments
 (0)