diff --git a/plux/build/setuptools.py b/plux/build/setuptools.py index 3d65919..bc8a87e 100644 --- a/plux/build/setuptools.py +++ b/plux/build/setuptools.py @@ -345,13 +345,17 @@ def get_distribution_from_workdir(workdir: str) -> setuptools.Distribution: dist = setuptools.Distribution() dist.parse_config_files(config_files) - if os.path.exists("setup.py"): + if os.path.exists(os.path.join(workdir, "setup.py")): # use setup.py script if available dist.script_name = os.path.join(workdir, "setup.py") else: - # else use a bogus file (seems to work regardless) + # else use a config file (seems to work regardless) dist.script_name = config_files[0] + # note: the property Distribution.script_name is added to `SOURCES.txt` during the `sdist` command. the path + # must be a relative path. see https://github.com/localstack/plux/issues/23 + dist.script_name = os.path.relpath(dist.script_name, workdir) + return dist diff --git a/tests/cli/test_entrypoints.py b/tests/cli/test_entrypoints.py index 3672bad..9849425 100644 --- a/tests/cli/test_entrypoints.py +++ b/tests/cli/test_entrypoints.py @@ -1,5 +1,6 @@ import os.path import sys +from pathlib import Path import pytest @@ -26,3 +27,9 @@ def test_entrypoints(project_name): with open(os.path.join(project, "test_project.egg-info", "entry_points.txt"), "r") as f: lines = [line.strip() for line in f.readlines() if line.strip()] assert lines == ["[plux.test.plugins]", "myplugin = mysrc.plugins:MyPlugin"] + + # make sure that SOURCES.txt contain no absolute paths + with open(os.path.join(project, "test_project.egg-info", "SOURCES.txt"), "r") as f: + lines = [line.strip() for line in f.readlines() if line.strip()] + for line in lines: + assert not line.startswith("/")