hatch-vcs icon indicating copy to clipboard operation
hatch-vcs copied to clipboard

Help for LookupError: setuptools-scm was unable to detect version for

Open maxschulz-COL opened this issue 1 year ago • 7 comments

Hey guys,

I am trying to implement hatch-vcs but seem to be missing something to make it work. I get the following traceback when running the command hatch version:

Traceback (most recent call last):
  File "/Users/Maximilian_Schulz/opt/anaconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/Maximilian_Schulz/opt/anaconda3/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/Users/Maximilian_Schulz/Library/Application Support/hatch/env/virtual/vizro/Xlhn8nc6/vizro-build/lib/python3.9/site-packages/hatchling/__main__.py", line 6, in <module>
    sys.exit(hatchling())
  File "/Users/Maximilian_Schulz/Library/Application Support/hatch/env/virtual/vizro/Xlhn8nc6/vizro-build/lib/python3.9/site-packages/hatchling/cli/__init__.py", line 26, in hatchling
    command(**kwargs)
  File "/Users/Maximilian_Schulz/Library/Application Support/hatch/env/virtual/vizro/Xlhn8nc6/vizro-build/lib/python3.9/site-packages/hatchling/cli/version/__init__.py", line 29, in version_impl
    version_data = source.get_version_data()
  File "/Users/Maximilian_Schulz/Library/Application Support/hatch/env/virtual/vizro/Xlhn8nc6/vizro-build/lib/python3.9/site-packages/hatch_vcs/version_source.py", line 70, in get_version_data
    version = get_version(**self.construct_setuptools_scm_config())
  File "/Users/Maximilian_Schulz/Library/Application Support/hatch/env/virtual/vizro/Xlhn8nc6/vizro-build/lib/python3.9/site-packages/setuptools_scm/__init__.py", line 148, in get_version
    _version_missing(config)
  File "/Users/Maximilian_Schulz/Library/Application Support/hatch/env/virtual/vizro/Xlhn8nc6/vizro-build/lib/python3.9/site-packages/setuptools_scm/__init__.py", line 108, in _version_missing
    raise LookupError(
LookupError: setuptools-scm was unable to detect version for /Users/Maximilian_Schulz/Library/CloudStorage/Documents/Python/Vizro/vizro/vizro-core.

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

I have added

[build-system]
requires = ["hatchling","hatch-vcs"]
build-backend = "hatchling.build"

to the pyproject.toml

and

[version]
source = "vcs"

[build.hooks.vcs]
version-file = "src/vizro/_version.py"

to the hatch.toml

Am I missing something? Sorry to ask here, I could not figure out a solution so far (new to version determination via VCS!)

This issue: https://github.com/pypa/setuptools_scm/issues/278 seems to suggest something about .git being at a different level than the setup.py (or pyproject.toml I suppose) - could the reason be that I am trying to implement this on a monorepo?

Any help would be much appreciated!

maxschulz-COL avatar Sep 07 '23 08:09 maxschulz-COL