question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LookupError: setuptools-scm was unable to detect version (due to no git installation)

See original GitHub issue

Hi,

I’m using this to provide dev versions (which is nice). I have a .gitlab-ci.yml configuration like so:

package:
  image: python:3.7-alpine
  stage: package
  before_script:
    - python -m pip install pep517 --user
  script:
    - python -m pep517.build --source --binary --out-dir dist/ .
  artifacts:
    paths:
      - dist/

for packaging. As it turns out, in the alpine docker images, there is no git (not surprising). What is a little misleading is the error message associated with the fact that git doesn’t exist:

$ python -m pep517.build --source --binary --out-dir dist/ .
/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools_scm/utils.py:119: UserWarning: 'git' was not found
  warnings.warn("%r was not found" % name)
Traceback (most recent call last):
  File "/root/.local/lib/python3.7/site-packages/pep517/_in_process.py", line 257, in <module>
    main()
  File "/root/.local/lib/python3.7/site-packages/pep517/_in_process.py", line 240, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/root/.local/lib/python3.7/site-packages/pep517/_in_process.py", line 213, in build_sdist
    return backend.build_sdist(sdist_directory, config_settings)
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools/build_meta.py", line 214, in build_sdist
    config_settings)
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools/build_meta.py", line 194, in _build_with_temp_dir
    self.run_setup()
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools/build_meta.py", line 142, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 87, in <module>
    dependency_links=[],
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/local/lib/python3.7/distutils/core.py", line 108, in setup
    _setup_distribution = dist = klass(attrs)
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools/dist.py", line 447, in __init__
    k: v for k, v in attrs.items()
  File "/usr/local/lib/python3.7/distutils/dist.py", line 292, in __init__
    self.finalize_options()
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools/dist.py", line 735, in finalize_options
    ep.load()(self, ep.name, value)
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools_scm/integration.py", line 17, in version_keyword
    dist.metadata.version = get_version(**value)
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools_scm/__init__.py", line 150, in get_version
    parsed_version = _do_parse(config)
  File "/tmp/pep517-build-env-6rj6j5_k/lib/python3.7/site-packages/setuptools_scm/__init__.py", line 113, 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 '/builds/scipp/itkdb'.

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
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/root/.local/lib/python3.7/site-packages/pep517/build.py", line 124, in <module>
    main(parser.parse_args())
  File "/root/.local/lib/python3.7/site-packages/pep517/build.py", line 120, in main
    build(args.source_dir, dist, args.out_dir)
  File "/root/.local/lib/python3.7/site-packages/pep517/build.py", line 88, in build
    _do_build(hooks, env, dist, dest)
  File "/root/.local/lib/python3.7/site-packages/pep517/build.py", line 71, in _do_build
    filename = build(td, {})
  File "/root/.local/lib/python3.7/site-packages/pep517/wrappers.py", line 216, in build_sdist
    'config_settings': config_settings,
  File "/root/.local/lib/python3.7/site-packages/pep517/wrappers.py", line 248, in _call_hook
    extra_environ=extra_environ
  File "/root/.local/lib/python3.7/site-packages/pep517/wrappers.py", line 57, in default_subprocess_runner
    check_call(cmd, cwd=cwd, env=env)
  File "/usr/local/lib/python3.7/subprocess.py", line 347, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/local/bin/python', '/root/.local/lib/python3.7/site-packages/pep517/_in_process.py', 'build_sdist', '/tmp/tmph3jvovmt']' returned non-zero exit status 1.

This is probably an easy check to catch if git doesn’t exist before trying to use it? To fix this is a simple apk --no-cache add git before trying to run anything else.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RonnyPfannschmidtcommented, Nov 19, 2019

it should be, i’m currently not in a position to make the required amount of time for setuptools_scm, this likely changes next month

0reactions
RonnyPfannschmidtcommented, Dec 6, 2020

closing as duplicate of #339

Read more comments on GitHub >

github_iconTop Results From Across the Web

LookupError: setuptools-scm was unable to detect version #278
Hi, I'm trying to use setuptools_scm in a project. However, I'm facing this error: Traceback (most recent call last): File "setup.py", ...
Read more >
LookupError: setuptools-scm was unable to detect version ...
I'm trying to install setup.py (from the website: https://github.com/richpsharp/ipbes-analysis/tree/1.1.0/ipbes-ndr) in the python virtual ...
Read more >
Frequently Asked Questions - PyScaffold
LookupError : setuptools-scm was unable to detect version for '/path/to/your/project':: This is due to the fact that setuptools_scm assumes that the root of ......
Read more >
[#IMPALA-5190] Python xdist installation fails with "LookupError
Python xdist installation fails with "LookupError: setuptools-scm was unable to detect version". Status: Assignee: Priority: Resolution: Resolved.
Read more >
setuptools-scm - PyPI
setuptools_scm extracts Python package versions from git or hg metadata instead of ... If you see unusual version numbers for packages but python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found