When setuptools are run from other tooling (e.g. pip install git...), the file would point to different location. Using current directory seems to be safer.
Reproducer:
$ python3.11 -m venv venv $ . ./venv/bin/activate $ pip install git+https://pagure.io/koji.git@koji-1.34.0
Metadata Update from @mfilip: - Pull-request tagged with: testing-ready
This swaps one issue for another. Now the code will break if cwd is not the checkout.
I'm not convinced the problem is __file__, or at least not just that.
__file__
When I run the replication commands, this is the error I got:
File "/tmp/pip-build-env-thcl182y/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires self.run_setup() ~~~~~~~~~~~~~~^^ File "/tmp/pip-build-env-thcl182y/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 522, in run_setup super().run_setup(setup_script=setup_script) ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-thcl182y/overlay/lib/python3.13/site-packages/setuptools/build_meta.py", line 320, in run_setup exec(code, locals()) ~~~~^^^^^^^^^^^^^^^^ File "<string>", line 39, in <module> File "<string>", line 29, in get_version KeyError: '__version__'
It's notable that this fails on the keyerror, but does not fail on the exec immediately prior. This says to me the pip run is finding koji/_version.py, but somehow isn't getting __version__ out of it.
koji/_version.py
__version__
If we can rely on setup.py having access to the correct git checkout, then __file__ should work. If we can't rely on that, the cwd is likely just as invalid
Ouch, nevermind, it is fixed in master by PR #4100
Metadata Update from @tkopecek: - Pull-request untagged with: testing-ready
Pull-Request has been closed by tkopecek
When setuptools are run from other tooling (e.g. pip install git...),
the file would point to different location. Using current directory
seems to be safer.