ofek / hatch-vcs

Hatch plugin for versioning with your preferred VCS
MIT License
111 stars 15 forks source link

setuptools-scm "root" parameter is ignored in raw-options #16

Closed quarckster closed 1 year ago

quarckster commented 1 year ago

Consider this config in the pyproject.toml:

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

and such source tree:

.
├── .git
├── package1
|   ...
│   └── pyproject.toml
├── package2
|   ...
│   └── pyproject.toml
...
└── README.md

If I try to build a package with dynamic versioning then it will fail because it setuptools-scm is not able to find .git directory

LookupError: Error getting the version from source `vcs`: setuptools-scm was unable to detect version for /some/path/package1.

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.

It happens due to this line https://github.com/ofek/hatch-vcs/blob/388c947133061a2056de9fe2f1102685a648f248/hatch_vcs/version_source.py#L56. I'm not sure what 's the intention of this but this prevents to work with projects where pyproject.toml is not located in the same directory with .git.

RonnyPfannschmidt commented 1 year ago

I consider this a bug, the hatch root is not the vcs root

Unfortunately i can't dig into this soon

ofek commented 1 year ago

https://github.com/ofek/hatch-vcs/releases/tag/v0.2.1