Skip to content

Commit

Permalink
Try other ways to go about this
Browse files Browse the repository at this point in the history
  • Loading branch information
hmaarrfk committed Apr 13, 2024
1 parent 100c010 commit 869a0aa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ jobs:
pip install .[dev]
- name: Unit tests
run: |
pytest -v pygfx/__pyinstaller
# Run from a directory that is not the package directory
# To simulate how real users would run it
RUN_FROM_DIR=$(mktemp -d)
cd ${RUN_FROM_DIR)
pytest -vxs --pyargs pygfx.__pyinstaller
test-examples-build:
name: Test examples
Expand Down
24 changes: 16 additions & 8 deletions pygfx/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,20 @@

package_root = os.path.dirname(os.path.realpath(__file__))
package_name = os.path.basename(package_root)
STATIC_VERSION_FILE = "_static_version.py"


def get_version():
version_info = get_static_version_info()
try:
from ._static_version import version, refnames, git_hash
version_info = dict(
version=version,
refnames=refnames,
git_hash=git_hash,
)
except ImportError:
version_info = get_static_version_info()

version = version_info["version"]
if version == "__use_git__":
version = get_version_from_git()
Expand All @@ -27,13 +37,11 @@ def get_version():
return version


def get_static_version_info():
from ._static_version import version, refnames, git_hash
return dict(
version=version,
refnames=refnames,
git_hash=git_hash,
)
def get_static_version_info(version_file=STATIC_VERSION_FILE):
version_info = {}
with open(os.path.join(package_root, version_file), "rb") as f:
exec(f.read(), {}, version_info)
return version_info


def version_is_from_git():
Expand Down

0 comments on commit 869a0aa

Please sign in to comment.