Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maxschulz-COL opened this issue Sep 7, 2023 · 7 comments

Comments

@maxschulz-COL
Copy link

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: pypa/setuptools_scm#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!

@RonnyPfannschmidt
Copy link
Collaborator

If your project is not at the root, setuptools-scm needs to be told or configured to search (doing this automatic breaks too many upstreams)

@maxschulz-COL
Copy link
Author

If your project is not at the root, setuptools-scm needs to be told or configured to search (doing this automatic breaks too many upstreams)

Thanks so much for getting back so quickly! Would you be able to point me to where to include the setting? While I love hatch and find the idea of hatch-vcs great, I struggle with the documentation sometimes :( . Like quite literally, where do I "tell setuptools-scm".

My guess is:
use_scm_version={'root':'../..', ...} needs to go somewhere in the pyproject.toml

Thanks so much ❤️

@ofek
Copy link
Owner

ofek commented Sep 7, 2023

https://github.com/ofek/hatch-vcs#version-source-options

@maxschulz-COL
Copy link
Author

https://github.com/ofek/hatch-vcs#version-source-options

Thanks for getting back, I had previously read this bit and was not sure how to use it. (probably my ignorance about toml files...)

It would be amazing to have an example on how to use the Version source options.

From what I read, I should probably use raw-options, and then clicking on the link, something with root, but how and in what combination to add? Would I add this under [version] or under [build.hooks.vcs] and in what syntax.

My guess would be:

[version]
root = ../..

@ofek
Copy link
Owner

ofek commented Sep 7, 2023

[tool.hatch.build.hooks.vcs]
raw-options = { root = "../.." }

@maxschulz-COL
Copy link
Author

Thanks a lot for the hint, I seem to be getting the same error (also with variations of locating the root). Will have to abandon for now, going with a version in the packages __init__ until I have time to figure out what I am doing wrong.

In case you are curious at checking what is wrong, this is my attempt: mckinsey/vizro@main...release/try_hatch_vcs

The whole project is set up with hatch, and it is a very enjoyable experience. Thanks a lot for creating the tool :)

@atthealchemist
Copy link

atthealchemist commented Oct 17, 2023

I don't know if it helps someone, but at least works for me:

Put in your pyproject.toml file:

[tool.hatch.version]
source = "vcs"
raw-options = { root = "../.." }

Tested on hatch-vcs version: 0.3.0
Anyway, kudos to developers for creating the great tool :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants