I'm having trouble getting a python package to build with python -m build .. setup.py fails on:
FileNotFoundError: [Errno 2] No such file or directory: 'requirements/requirements.txt'
It's caused by the fact that build is copying files to a temporary directory first. But it's only copying the source/, README.md, setup.py, setup.cfg. It's not copying requirements/.
For complex reasons my setup.py needs to reference other files at the root of the source repo - a directory containing multiple requirements.txt files. It's not really worth discussing why it needs to be structured this way, I've already been through that long debate with colleagues.
This works fine when we install the package through pip install -e . or as a git dependency git+ssh://... but fails when building before we push to a pypi repo.
setup.cfg
setup.py
source/
source/my_package/
requirements/
requirements/requirements.txt
requirements/some-other-requirements.txt
setup.py references this directory before calling setup().
from pathlib import Path
from setuptools import setup, find_namespace_packages
requirements_dir = Path("requirements")
# This is the line that fails:
with (requirements_dir / "requirements.txt").open() as f:
install_requires = list(f)
setup(
packages=find_namespace_packages(where="source", include=["acme_corp.*"], exclude=["tests", "tests.*"]),
package_dir={"": "source"},
install_requires=install_requires,
extras_require=optional_packages,
)