Skip to content

Commit

Permalink
Fix version detection.
Browse files Browse the repository at this point in the history
The previous code was adding `__version__` to the globals which was then
ignored as there was a local version of the same name.

The new code is a lot more strict and no longer uses exec.

The verbose pip install wasn't needed.
  • Loading branch information
HexDecimal committed Jun 10, 2021
1 parent 19e08a6 commit 0d615dc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
name: sdist
- name: Build package in isolation
run: |
pip install -v tcod-*.tar.gz
pip install tcod-*.tar.gz
- name: Confirm package import
run: |
python -c "import tcod"
5 changes: 2 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ v2.0.0

Unreleased
------------------
Fixed
- Fixed version mismatch when building from sources.

12.6.0 - 2021-06-09
-------------------
Expand All @@ -19,9 +21,6 @@ Deprecated
- The handling of negative indexes given to console drawing and printing
functions will be changed to be used as absolute coordinates in the future.

Fixed
- Fixed version mismatch when building from sources.

12.5.1 - 2021-05-30
-------------------
Fixed
Expand Down
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import pathlib
import platform
import re
import sys
import warnings
from subprocess import CalledProcessError, check_output
Expand Down Expand Up @@ -37,12 +38,13 @@ def get_version() -> str:
return version
except CalledProcessError:
try:
__version__ = "0.0.0"
with open(PATH / "tcod/version.py") as version_file:
exec(version_file.read(), globals()) # Update __version__
match = re.match(r'__version__ = "(\S+)"', version_file.read())
assert match
return match.groups()[0]
except FileNotFoundError:
warnings.warn("Unknown version: " "Not in a Git repository and not from a sdist bundle or wheel.")
return __version__
warnings.warn("Unknown version: Not in a Git repository and not from a sdist bundle or wheel.")
return "0.0.0"


is_pypy = platform.python_implementation() == "PyPy"
Expand Down

0 comments on commit 0d615dc

Please sign in to comment.