smarie / python-getversion Goto Github PK
View Code? Open in Web Editor NEWGet the version number of any python module or package, reliably.
Home Page: https://smarie.github.io/python-getversion/
License: BSD 3-Clause "New" or "Revised" License
Get the version number of any python module or package, reliably.
Home Page: https://smarie.github.io/python-getversion/
License: BSD 3-Clause "New" or "Revised" License
When 'git'
command is not in path, setuptools_scm get_version
does not provide a readabale explanation. We should therefore rather check it upfront
from setuptools_scm import has_command
has_command('git')
Consider some random python module that is in a git-versioned folder, tagged as 1.0.0-rc1
(release candidate. See semantic versioning: https://semver.org/spec/v2.0.0-rc.1.html)
The following code does not retrieve the right version string: the dash before the pre-release info is removed
from getversion import get_module_version
# import whatever local folder or file is available in this git folder
import my_module
# get the version and details. it will fallback to using the setuptools_scm one
ver, details = get_module_version(my_module)
print(details) # SUCCESS on the setuptools_scm one (the last one)
print(ver) # prints "1.0.0rc1" instead of "1.0.0-rc1"
This has for example as consequence that the resulting version string is not compliant with semver
while the initial git tag was:
from semver import parse_version_info
parse_version_info("1.0.0-rc1") # this is ok
parse_version_info("1.0.0rc1") # this fails
raises ValueError: 1.0.0rc1 is not valid SemVer string
This happens typically when we develop new versions of an existing and already installed package.
import makefun
found_version, detailed_results = get_module_version(makefun)
print(detailed_results)
yields
Version '1.8.0' found for module 'makefun' by strategy 'get_unzipped_wheel_or_egg_version', after the following failed attempts:
- Attempts for module 'makefun':
- <get_module_version_attr>: module 'makefun' has no attribute '__version__'
- <get_version_using_pkgresources>: Another distribution of the same package (with version '1.8.0') is installed, but is not the one that was imported
- <get_builtin_module_version>: Module makefun is not a built-in module
- <get_unzipped_wheel_or_egg_version>: SUCCESS: 1.8.0
While it should have found it sooner, in get_version_using_pkgresources
. The error message is not right: I am using the installed package, not any fancy one.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.