I have a project with this file structure:
project/
|- ...
|- include/
\- version.hpp
|- conanfile.py
|- pyproject.toml
|- setup.py
\- version.py
version.hppis the only point where I keep the current version.version.pyprogrammatically parses the version fromversion.hpp.- Both
conanfile.pyandsetup.pydofrom version import get_version, and useget_version()to get the current version.python -m pip install .has been working without issues until now. - Now, I have added
pyproject.toml(because I needed it to generate wheels viacibuildwheel), and when I dopipx run cibuildwheelorpython -m pip install ., I get aModuleNotFoundError: No module named 'version'.
How can I make version.py visible from setup.py when using pyproject.toml?
[Update]
I was initially wondering if I had missed some basic configuration but, according to the comment and answer, this is not an obvious catch.
I would add this is not a proper Python project. It's a C++ project, with SWIG and some auto-generated Python code.
I could add a link to the GitHub project, in case you may find that useful for looking at the source code.
My current solution is ugly, but just works. I copy-pasted the get_version() code from version.py into setup.py.
setup.pyandpyproject.tomlrespectively. Having a moduleversionoutside your Python package hierarchy is terrible form, though - consider a__version__in your package__init__instead?