Skip to content

fix gitversion to not recompute version from sdist - #316

Merged
hameerabbasi merged 3 commits into
Quansight-Labs:masterfrom
lucascolley:sdist-existing-v
Feb 10, 2026
Merged

hameerabbasi merged 3 commits into
Quansight-Labs:masterfrom
lucascolley:sdist-existing-v

Conversation

@lucascolley

Copy link
Copy Markdown
Contributor

hopefully the last one needed @hameerabbasi 😅

Comment thread tools/gitversion.py Resolved
Comment thread tools/gitversion.py Resolved
@lucascolley

Copy link
Copy Markdown
Contributor Author
image

Comment thread tools/gitversion.py Resolved
Comment thread tools/gitversion.py Resolved
@lucascolley

Copy link
Copy Markdown
Contributor Author
Running command: /Users/lucascolley/ghq/github.com/scipy/scipy/.pixi/envs/build/bin/python3.14 /Users/lucascolley/ghq/github.com/scipy/scipy/subprojects/uarray/tools/gitversion.py
--- stdout ---

--- stderr ---
Traceback (most recent call last):
  File "/Users/lucascolley/ghq/github.com/scipy/scipy/subprojects/uarray/tools/gitversion.py", line 23, in <module>
    main()
    ~~~~^^
  File "/Users/lucascolley/ghq/github.com/scipy/scipy/subprojects/uarray/tools/gitversion.py", line 11, in main
    version_module = __import__(str(source_version_path))
ModuleNotFoundError: No module named '/Users/lucascolley/ghq/github'

@lucascolley

Copy link
Copy Markdown
Contributor Author

looks like __import__ struggles if there is a . in the path

Comment thread tools/gitversion.py Resolved

@lucascolley lucascolley left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that doesn't help

Traceback (most recent call last):
  File "/Users/lucascolley/ghq/github.com/scipy/scipy/subprojects/uarray/tools/gitversion.py", line 23, in <module>
    main()
    ~~~~^^
  File "/Users/lucascolley/ghq/github.com/scipy/scipy/subprojects/uarray/tools/gitversion.py", line 11, in main
    version_module = __import__(str(source_version_path.absolute()))
ModuleNotFoundError: No module named '/Users/lucascolley/ghq/github'

@lucascolley

Copy link
Copy Markdown
Contributor Author

perhaps

import importlib.util

spec = importlib.util.spec_from_file_location(
    "version_module",
    source_version_path,
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

print(module.__version__)

@hameerabbasi

hameerabbasi commented Feb 10, 2026 •

Copy link
Copy Markdown
Collaborator

perhaps

import importlib.util

spec = importlib.util.spec_from_file_location(
    "version_module",
    source_version_path,
)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)

print(module.__version__)

That worked, thanks! I found the docs at about the same time as you! https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly

Comment thread tools/gitversion.py Resolved
@hameerabbasi

Copy link
Copy Markdown
Collaborator

Hmm, I was fairly sure that __import__ took paths, guess I was wrong.

Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
@hameerabbasi

Copy link
Copy Markdown
Collaborator

Imma merge this early to unblock you; wheels seem to be producing for all the platforms.

@hameerabbasi
hameerabbasi merged commit 6d8c2d7 into Quansight-Labs:master Feb 10, 2026
9 checks passed
@lucascolley
lucascolley deleted the sdist-existing-v branch February 10, 2026 15:54
@lucascolley

Copy link
Copy Markdown
Contributor Author

thanks Hameer :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants