Search code examples
pythonsetup.pysetuptools-scm

Python setup.py setuptools_scm use_scm_version/get_version() error


Dear interent my docker build (RUN python3 setup.py install) continues to fail with the following error: LookupError: setuptools-scm was unable to detect version for '/src'. I know there are posts about this all over but I still can't sort it out. Here's my repo:

.
├── Dockerfile
├── VERSION  # a one-line file: 1.5.0
├── package
│   ├── __init__.py
│   ├── module.py
├── setup.py
└── .git

Here's my setup.py file:

from setuptools import setup

setup_requirements = [
    'setuptools_scm==3.5.0',
    "Cython==0.29.24",
]
setup(
    ...
    use_scm_version=True,
    setup_requires=setup_requirements,
    ...
)

A couple notes:

  1. If I run git describe i get the version i'm hoping use_scm_version finds: 1.5.0-rc.1
  2. If I comment out use_scm_version=True and instead use version=1.5.0, it works perfectly

Thank you so much for any and all help, I'm so stuck. Cheers :)


Solution

  • I have just stumbled in a very similar issue (and lost several hours on it...) on a CI pipeline that I maintain.

    This is due to setuptools_scm silently ignoring a git error related to this git vulnerability fix release, see https://github.com/pypa/setuptools_scm/issues/707

    Here is a (similar/duplicate) issue report that shows also how to diagnose the issue.