How can I get the version defined in setup.py (setuptools) in my package?

前端 未结 16 782
无人及你
无人及你 2020-11-27 09:47

How could I get the version defined in setup.py from my package (for --version, or other purposes)?

16条回答
  •  离开以前
    2020-11-27 10:21

    deploy package to server and file naming convention for indices packages :

    example for pip dynamic version conversion:

    • win:

      • test_pkg-1.0.0-cp36-cp36m-win_amd64.whl
      • test_pkg-1.0.0-py3.6-win-amd64.egg
    • mac:

      • test_pkg-1.0.0-py3.7-macosx-10.12-x86_64.egg
      • test_pkg-1.0.0-py3.7-macosx-10.12-x86_64.whl
    • linux:
      • test_pkg-1.0.0-cp36-cp36m-linux_x86_64.whl
    from setuptools_scm import get_version
    
    def _get_version():
    
         dev_version = str(".".join(map(str, str(get_version()).split("+")[0]\
                .split('.')[:-1])))
    
        return dev_version
    
    

    Find the sample setup.py calls the dynamic pip version matching from git commit

    setup(
        version=_get_version(),
        name=NAME,
        description=DESCRIPTION,
        long_description=LONG_DESCRIPTION,
        classifiers=CLASSIFIERS,
    
    # add few more for wheel wheel package ...conversion
    
    )
    

提交回复
热议问题