Skip to content

Commit

Permalink
fix issue with absolute paths landing in SOURCE.txt (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
thrau committed Oct 24, 2024
1 parent 59f5f67 commit 5bf9b4c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion plux/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

name = "plux"

__version__ = "1.12.0"
__version__ = "1.12.1"

__all__ = [
"FunctionPlugin",
Expand Down
8 changes: 6 additions & 2 deletions plux/build/setuptools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
7 changes: 7 additions & 0 deletions tests/cli/test_entrypoints.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os.path
import sys
from pathlib import Path

import pytest

Expand All @@ -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("/")

0 comments on commit 5bf9b4c

Please sign in to comment.