Skip to content

Commit

Permalink
Test the fix for including modules from different locations
Browse files Browse the repository at this point in the history
When we try to include moduleA from libA and moduleB from libB then
package_dir in the generated setup.py must to contain either one or
both `"moduleA": "libA/moduleA"` or `"moduleB": "libB/moduleB"`
so we are able to find both modules when building the source dist.
  • Loading branch information
jaharkes committed Jun 3, 2021
1 parent 1f66983 commit a4121d9
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
Empty file.
Empty file.
15 changes: 15 additions & 0 deletions tests/masonry/builders/fixtures/split_source/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "split-source"
version = "0.1"
description = "Combine packages from different locations."
authors = [
"Jan Harkes <jaharkes@cs.cmu.edu>"
]
license = "MIT"
packages = [
{ include = "moduleA", from = "libA" },
{ include = "moduleB", from = "libB" },
]

[tool.poetry.dependencies]
python = "^3.6"
20 changes: 20 additions & 0 deletions tests/masonry/builders/test_sdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,3 +629,23 @@ def test_sdist_mtime_zero():
with gzip.open(str(sdist), "rb") as gz:
gz.read(100)
assert gz.mtime == 0


def test_split_source():
root = fixtures_dir / "split_source"
poetry = Factory().create_poetry(root)

builder = SdistBuilder(poetry)

# Check setup.py
setup = builder.build_setup()
setup_ast = ast.parse(setup)

setup_ast.body = [n for n in setup_ast.body if isinstance(n, ast.Assign)]
ns = {}
exec(compile(setup_ast, filename="setup.py", mode="exec"), ns)
assert "moduleA" in ns["package_dir"] or "moduleB" in ns["package_dir"]
if "moduleA" in ns["package_dir"]:
assert ns["package_dir"]["moduleA"] == "libA/moduleA"
if "moduleB" in ns["package_dir"]:
assert ns["package_dir"]["moduleB"] == "libB/moduleB"

0 comments on commit a4121d9

Please sign in to comment.