Git Product home page Git Product logo

python-getversion's Introduction

getversion

Get the version number of any python module or package, reliably.

Python versions Build Status Tests Status codecov

Documentation PyPI Downloads Downloads per week GitHub stars

This is the readme for developers. The documentation for users is available here: https://smarie.github.io/python-getversion/

Want to contribute ?

Contributions are welcome ! Simply fork this project on github, commit your contributions, and create pull requests.

Here is a non-exhaustive list of interesting open topics: https://github.com/smarie/python-getversion/issues

Running the tests

This project uses pytest.

pytest -v getversion/tests/

You may need to install requirements for setup beforehand, using

pip install -r ci_tools/requirements-test.txt

Packaging

This project uses setuptools_scm to synchronise the version number. Therefore the following command should be used for development snapshots as well as official releases:

python setup.py egg_info bdist_wheel rotate -m.whl -k3

You may need to install requirements for setup beforehand, using

pip install -r ci_tools/requirements-setup.txt

Generating the documentation page

This project uses mkdocs to generate its documentation page. Therefore building a local copy of the doc page may be done using:

mkdocs build -f docs/mkdocs.yml

You may need to install requirements for doc beforehand, using

pip install -r ci_tools/requirements-doc.txt

Generating the test reports

The following commands generate the html test report and the associated badge.

pytest --junitxml=junit.xml -v getversion/tests/
ant -f ci_tools/generate-junit-html.xml
python ci_tools/generate-junit-badge.py

PyPI Releasing memo

This project is now automatically deployed to PyPI when a tag is created. Anyway, for manual deployment we can use:

twine upload dist/* -r pypitest
twine upload dist/*

python-getversion's People

Contributors

hmaarrfk avatar smarie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

python-getversion's Issues

get_version_using_pkgresources does not work properly

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.

Fix issue with prerelease git versions where the dash before the version number disappears

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.