-
-
Notifications
You must be signed in to change notification settings - Fork 956
Read the Kolibri version from one shared helper across platforms #15106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rtibblesbot
wants to merge
3
commits into
learningequality:develop
Choose a base branch
from
rtibblesbot:issue-15077-92a158
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # /// script | ||
| # requires-python = ">=3.6" | ||
| # dependencies = [] | ||
| # /// | ||
| """Print the Kolibri version from ``kolibri/_version.py`` -- the setuptools-scm | ||
| source of truth -- given a directory holding the ``kolibri`` package or a ``.whl``. | ||
|
|
||
| Stdlib-only and 3.6-compatible: callers run it under a bare ``python3``. | ||
| """ | ||
|
|
||
| import os | ||
| import sys | ||
| import zipfile | ||
|
|
||
| VERSION_MODULE = "kolibri/_version.py" | ||
|
|
||
|
|
||
| def read_version(path): | ||
| if path.endswith(".whl"): | ||
| with zipfile.ZipFile(path) as wheel: | ||
| source = wheel.read(VERSION_MODULE) | ||
| else: | ||
| with open(os.path.join(path, VERSION_MODULE), "rb") as version_module: | ||
| source = version_module.read() | ||
| # _version.py imports nothing and only assigns, so running it is the same as | ||
| # importing it -- which is not an option for a member of a wheel. | ||
| namespace = {} | ||
| exec(source, namespace) | ||
| return namespace["__version__"] | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| print(read_version(sys.argv[1])) # noqa: T201 |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import os | ||
| import zipfile | ||
|
|
||
| from build_tools.read_kolibri_version import read_version | ||
|
|
||
| VERSION = "0.19.0.dev0+g1234abc" | ||
|
|
||
| # What setuptools-scm's version_file_template emits (pyproject.toml). | ||
| SCM_VERSION_PY = ( | ||
| "# file generated by setuptools-scm\n" | ||
| "# don't change, don't track in version control\n" | ||
| "__version__ = version = '%s'\n" % VERSION | ||
| ) | ||
|
|
||
|
|
||
| def test_reads_version_from_a_tree(tmp_path): | ||
| package_dir = os.path.join(str(tmp_path), "kolibri") | ||
| os.makedirs(package_dir) | ||
| with open(os.path.join(package_dir, "_version.py"), "w") as version_module: | ||
| version_module.write(SCM_VERSION_PY) | ||
| assert read_version(str(tmp_path)) == VERSION | ||
|
|
||
|
|
||
| def test_reads_version_from_a_wheel(tmp_path): | ||
| whl = os.path.join(str(tmp_path), "kolibri-0.19.0-py2.py3-none-any.whl") | ||
| with zipfile.ZipFile(whl, "w") as archive: | ||
| archive.writestr("kolibri/_version.py", SCM_VERSION_PY) | ||
| archive.writestr("kolibri-0.19.0.dist-info/METADATA", "Name: kolibri\n") | ||
| assert read_version(whl) == VERSION |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.