aboutcode-org / typecode

7 stars 9 forks source link

Fix versioning #3

Closed pombredanne closed 3 years ago

pombredanne commented 3 years ago

Building a wheel or sdist from a tarball that is NOT a git checkout (e.g. without .git metadata directory) ends up having a 0.0.0 version. We need a fallback from setuptools_scm

pombredanne commented 3 years ago

Here is the problem:

$ wget https://github.com/nexB/typecode/archive/v21.1.21.tar.gz
$ tar -xf typecode-21.1.21.tar.gz 
$ python setup.py bdist_wheel
Traceback (most recent call last):
  File "setup.py", line 6, in <module>
    setuptools.setup()
  File "/tmp/typecode/tmp/lib/python3.6/site-packages/setuptools/__init__.py", line 153, in setup
    return distutils.core.setup(**attrs)
  File "/tmp/.pyenv/versions/3.6.10/lib/python3.6/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/tmp/typecode/tmp/lib/python3.6/site-packages/setuptools/dist.py", line 424, in __init__
    k: v for k, v in attrs.items()
  File "/tmp/.pyenv/versions/3.6.10/lib/python3.6/distutils/dist.py", line 281, in __init__
    self.finalize_options()
  File "/tmp/typecode/tmp/lib/python3.6/site-packages/setuptools/dist.py", line 695, in finalize_options
    ep(self)
  File "/tmp/typecode/typecode-21.1.21/.eggs/setuptools_scm-5.0.1-py3.6.egg/setuptools_scm/integration.py", line 61, in infer_version
    dist.metadata.version = _get_version(config)
  File "/tmp/typecode/typecode-21.1.21/.eggs/setuptools_scm-5.0.1-py3.6.egg/setuptools_scm/__init__.py", line 173, in _get_version
    parsed_version = _do_parse(config)
  File "/tmp/typecode/typecode-21.1.21/.eggs/setuptools_scm-5.0.1-py3.6.egg/setuptools_scm/__init__.py", line 142, in _do_parse
    "use git+https://github.com/user/proj.git#egg=proj" % config.absolute_root
LookupError: setuptools-scm was unable to detect version for '/tmp/typecode/typecode-21.1.21'.

Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.

For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=proj
pombredanne commented 3 years ago

This is now handled with the latest skeleton using setuptools_scm fallback_version