Skip to content

SDist builds incorrectly auto detects subpackages of excluded files/directories #1009

@johnslemmer

Description

@johnslemmer
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.

Issue

If you pull down the example repo above and run poetry build you will notice that the setup.py inside dist/example-0.1.0.tar.gz has the following line:

packages = \
['example', 'example.test']

For some reason (well, after scouring through the source, I believe the culprit to be here because the __init__.py is never checked against the excluded files) example.test is in this list of "public" modules, and I believe this is a mistake. pyproject.toml has the line exclude = ["**/test/**/*"] and poetry correclty leaves out those files from the build. However, the code generating setup.py seems to not be not checking this exclude directive.

As you can see if I try to explicitly install the source tarball in a new poetry project I get the following error:

$ poetry new testThisTheory
$ cd testThisTheory
$ poetry add --path ../poetryIncorrectSubpackageAutoDetec/dist/example-0.1.0.tar.gz example

Updating dependencies
Resolving dependencies... (0.1s)


Package operations: 1 install, 0 updates, 0 removals

Writing lock file

  - Installing example (0.1.0 ../poetryIncorrectSubpackageAutoDetec/dist/example-0.1.0.tar.gz)

[EnvCommandError]
Command ['/XXXXXX/.venv/bin/python', '-m', 'pip', 'install', '--no-deps', '/XXXXXXX/poetryIncorrectSubpackageAutoDetec/dist/example-0.1.0.tar.gz'] errored with the following output: 
Processing /XXXXXXX/poetryIncorrectSubpackageAutoDetec/dist/example-0.1.0.tar.gz
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
    Complete output from command python setup.py egg_info:
    running egg_info
    creating pip-egg-info/example.egg-info
    writing pip-egg-info/example.egg-info/PKG-INFO
    writing top-level names to pip-egg-info/example.egg-info/top_level.txt
    writing dependency_links to pip-egg-info/example.egg-info/dependency_links.txt
    writing manifest file 'pip-egg-info/example.egg-info/SOURCES.txt'
    error: package directory 'example/test' does not exist
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/3w/g_wbfnl522z2br4vldngqrth0000gn/T/pip-req-build-MLnJlo/
You are using pip version 18.1, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

I think I know where the issue lies, and would be willing to submit a pull request if that would be helpful. Let me know.

PS. I tested with doing a poetry add on the built wheel and it works just fine.
PPS. I also tested doing as poetry add directly on the repo directory and it also works fine.
PPPS. thank you so much for this kick-ass project @sdispater!!!!

Metadata

Metadata

Assignees

Labels

area/build-systemRelated to PEP 517 packaging (see poetry-core)kind/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions