Git Product home page Git Product logo

python-getversion's Issues

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

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.

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.