plux entrypoints adds absolute path to setup.py to SOURCES.txt
With https://github.com/localstack/localstack-cli/pull/27, we are currently trying to migrate our PyInstaller binary CLI build of the LocalStack CLI to our new namespace packaging (which was recently introduced). We are now at a state where only the Windows build failed with the following error:
...
reading manifest file 'localstack_ext.egg-info\SOURCES.txt'
Traceback (most recent call last):
File "D:\a\localstack-cli\localstack-cli\.venv\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
...
File "C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-a5jadoa9\overlay\Lib\site-packages\setuptools\_distutils\util.py", line 133, in convert_path
raise ValueError(f"path '{pathname}' cannot be absolute")
ValueError: path '/home/runner/actions-runner/_work/localstack-ext/localstack-ext/localstack-pro-core/setup.py' cannot be absolute
[end of output]
...
It seems that the execution of python3 -m plux entrypoints does add an absolute path to the setup.py in the SOURCES.txt in the egg_info folder (which causes issues only on Windows). Here's a quick reproducer in localstack/localstack:
mkdir /tmp/plux-test && cd /tmp/plux-test
git clone [email protected]:localstack/localstack.git
cd localstack
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements-dev.txt
cd localstack-pro-core
python3 -m plux entrypoints
cat localstack-core/localstack_core.egg-info/SOURCES.txt | grep -E ^/
# -> /tmp/test/localstack/setup.py
Replacing python3 -m plux entrypoints with python3 -m setup plugins egg_info works just fine:
cd /tmp/plux-test/localstack && rm -rf localstack-core/localstack_core.egg-info
source .venv/bin/activate
cd localstack-pro-core
python3 -m setup plugins egg_info
cat localstack-core/localstack_core.egg-info/SOURCES.txt | grep -E ^/
# Command fails because SOURCES.txt does not contain any absolute paths
I am actually not sure what causes this, plux really basically just calls these two setuptools commands:
https://github.com/localstack/plux/blob/8a5b75935988a949d0ef7a3eebe04a79ba49d765/plux/cli/cli.py#L22-L26
This is also failing on Linux when trying to build extension https://github.com/localstack/altimeter-ext/tree/ed1485d557e8606e5c553b6ff6801411adc9f2dc
I can see that when trying to build the .whl file I get
...
writing requirements to backend/resource_graph.egg-info/requires.txt
writing top-level names to backend/resource_graph.egg-info/top_level.txt
writing entry points to backend/resource_graph.egg-info/entry_points.txt
reading manifest file 'backend/resource_graph.egg-info/SOURCES.txt'
writing manifest file 'backend/resource_graph.egg-info/SOURCES.txt'
error: Error: setup script specifies an absolute path:
/home/luca/Code/altimeter-ext/pyproject.toml
setup() arguments must *always* be /-separated paths relative to the
setup.py directory, *never* absolute paths.
ERROR Backend subprocess exited when trying to invoke build_wheel
If I look inside the SOURCES.txt (inside .egg.info) I can see
README.md
pyproject.toml
/home/luca/Code/altimeter-ext/pyproject.toml
backend/resource_graph/__init__.py
backend/resource_graph/config.py
...
Which is the only place I could find an absolute path so I'm fairly sure this is the issue
Installing dependencies with python3 -c "from setuptools import setup; setup()" plugins egg_info instead of python -m plux entrypoints seems to solve the issue as if I look again inside the SOURCES.txt now I can see
README.md
pyproject.toml
backend/resource_graph/__init__.py
backend/resource_graph/config.py
backend/resource_graph/extension.py
...
(aka no absolute path present)