Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
johnslemmer opened this issue Apr 2, 2019 · 5 comments · Fixed by #1626
Closed
2 tasks done
Assignees
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected

Comments

@johnslemmer
Copy link

johnslemmer commented Apr 2, 2019

  • 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!!!!

@johnslemmer johnslemmer changed the title source builds incorrectly auto detects subpackages of excluded files/directories SDist builds incorrectly auto detects subpackages of excluded files/directories Apr 2, 2019
@bdoms
Copy link

bdoms commented Aug 28, 2019

Just encountered this in Poetry version 0.12.16 on Ubuntu. I found that any directory that was excluded with something like foo/** would have this error if that directory contained Python files.

It's scary to have an install fail when all your tests pass and the build works fine.

@stale
Copy link

stale bot commented Nov 13, 2019

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Nov 13, 2019
@johnslemmer
Copy link
Author

johnslemmer commented Nov 13, 2019

I just tested this on Poetry version 1.0.0b4 and I'm still seeing the same issue.

@sdispater please remove the wontfix label

@sdispater sdispater added kind/bug Something isn't working as expected area/build-system Related to PEP 517 packaging (see poetry-core) and removed wontfix labels Nov 13, 2019
@finswimmer finswimmer self-assigned this Nov 21, 2019
finswimmer pushed a commit to finswimmer/poetry that referenced this issue Nov 24, 2019
@TheErk
Copy link

TheErk commented Jan 3, 2020

I was hit by something similar yesterday using poetry 1.0.0.
I have a package whose directory structure is:
module_name
├── src
│   └── module_name
└── tests
└── data

my pyproject.toml has package description:

packages = [
    { include = "module_name", from = "src" },
#    { include = "tests", format = "sdist" },
]

I wanted to include tests dir in the source distribution (only) but If I do that poetry install will fail telling me that there is no "tests" package in "module_name".

As explaine in #1109 this should work, unless I missed something?

NB: the packaging with poetry buildworks as expected but poetry install fails.

finswimmer pushed a commit to finswimmer/poetry that referenced this issue Jan 24, 2020
sdispater pushed a commit that referenced this issue Feb 28, 2020
…1009) (#1626)

* fix: exclude subpackage from `setup.py` if `__init__.py` is excluded

Fixes: #1009

* fix: added missing test data

* fix: lint test data

* change (sdist.git): exclude folders with no python file

* fix (sdist.git): make black happy
sdispater added a commit that referenced this issue Mar 20, 2020
* Fix Github actions cache issues (#1908)

* Fix case of `-f` flag

* Make it clearer what options to pass to `--format`

* fix (masonry.api): `get_requires_for_build_wheel` must return additional list of requirements for building a package, not listed in `pyproject.toml` and not dependencies for the package itself (#1875)

fix (tests): adopted tests

* Lazy Keyring intialization for PasswordManager (#1892)

* Fix Github Actions cache issues (#1928)

* Avoid nested quantifiers with overlapping character space on git url parsing (#1902 (#1913)

* fix (git): match for `\w` instead of `.` for getting user

* change (vcs.git): hold pattern of the regex parts in a dictionary to be consistent over all regexs

* new (vcs.git): test for `parse_url` and some fixes for the regex pattern

* new (vcs.git): test for `parse_url` with string that should fail

* fix (test.vcs.git): make flake8 happy

* fix: correct parsing of wheel version with regex. (#1932)

The previous regexp was only taking the first integer of the version number,
this presented problems when the major version number reached double digits.

Poetry would determine that the version of the dependency is '1', rather than,
ie: '14'. This caused failures to solve versions.

* Fix errors when using the --help option (#1910)

* Fix how repository credentials are retrieved from env vars (#1909)

# Conflicts:
#	poetry/utils/password_manager.py

* Fix downloading packages from Simplepypi (#1851)

* fix downloading packages from simplepypi

* unused code removed

* remove unused imports

* Upgrade dependencies for the 1.0.3 release (#1965)

* Bump version to 1.0.3 (#1966)

* Fix non-compliant Git URL matching

RFC 3986 § 2.3 permits more characters in a URL than were matched. This
corrects that, though there may be other deficiencies. This was a
regression from v1.0.2, where at least “.” was matched without error.

* Update README.md "Updating Poetry"

Currently the note in "Updating Poetry" is different from the one below in "Enable tab completion for Bash, Fish, or Zsh". This MR is to make them more consistent.

* init: change dev dependency prompt

* Fix CI issues (#2069)

* fix (setup_reader): check if `func.value` has attr `id` (#2041)

* fix(git): get commit sha of git commit from annotated tags (#1948)

* fix(git): have annotated tags resolve to the commit sha

* fix(git): fix quote

* fix(git): change to rev-parse

* fix: use correct badge on README (#2065)

* Fix #1791: Load repository URL from config (#2061)

* Fix #1791: Load repository URL from config

* Ran black to fix linting errors

* Add test for repo URL env variable

* Changed schema to support url in multi dependencies (#2035)

* Fix handling of forward slashes and url encoding in credentials (#1911)

* Add support for forward slashes and url encoding in credentials

* Remove extra newline

* Remove unquote

* Bump actions/checkout from v1 to v2 (#2075)

* Update release.yml

* Update main.yml

* Fix vendor package as installed package (#1883) (#1981)

* Fix vendor package as installed package (#1883)

* import from

Co-Authored-By: Sébastien Eustace <sebastien.eustace@gmail.com>

* test vendor package as installed

* refactor

* remove blank line

Co-authored-by: Sébastien Eustace <sebastien.eustace@gmail.com>

* fix(utils.env): import cli_run from virtualenv (#2096)

* fix(utils.env): import cli_run from virtualenv if create_environment import failes

* fix (utils.env): added accidentally removed code

* list .venv when it exists (#1762)

* list .venv when it exists

* only list when in-project is true

* missing config

* move logic to manager.list

* Add .venv when it exists

* fix: exclude subpackage from `setup.py` if `__init__.py` is excluded (#1009) (#1626)

* fix: exclude subpackage from `setup.py` if `__init__.py` is excluded

Fixes: #1009

* fix: added missing test data

* fix: lint test data

* change (sdist.git): exclude folders with no python file

* fix (sdist.git): make black happy

* get_vcs starts searching git folder from tmp dir instead of project (#1946) (#1947)

* fix (builder): take `self._original_path` if available to find `.git` folder

* change (vcs): use `git rev-parse --show-toplevel` to find git root folder

* fix (vcs): change back to original working dir after finding vcs

* change (builder): introduce self._original_path to keep original path
if(vcs): resolve directory for `get_vcs`

* Normalize author name unicode before matching (#2006)

* Fix accented characters not being matched in author name

Fixes #2004

* Normalized the strings instead of modifying the pattern

* Applied isort & black

* Fix the url used for installation when fallbacking on PyPI (#2099)

* Upgrade dependencies before the 1.0.4 release (#2100)

* Upgrade dependencies before the 1.0.4 release (#2103)

* Release 1.0.4 (#2101)

* Update release script

* Bump version to 1.0.4

* Fix release script (#2104)

* Fix VCS when git is not in PATH

* Upgrade dependencies before the 1.0.5 release (#2111)

* Bump version to 1.0.5 (#2112)

* Fix GitHub URL for black

Black is now officially supported by the Python Software Foundation

* Update Contributing.md* Fix markdown formatting* Update link to official website FAQ

* Update managing-environments.md

Co-authored-by: brandonaut <brandon@hubermx.com>
Co-authored-by: finswimmer <finswimmer77@gmail.com>
Co-authored-by: Yannick PÉROUX <yannick.peroux@gmail.com>
Co-authored-by: Edward George <edwardgeorge@gmail.com>
Co-authored-by: Jan Škoda <skoda@jskoda.cz>
Co-authored-by: Andrew Marshall <andrew@johnandrewmarshall.com>
Co-authored-by: Andrew Selzer <andrewfselzer@gmail.com>
Co-authored-by: Andriy Maletsky <andriy.maletsky@gmail.com>
Co-authored-by: Julien Lhermitte <705366+jrmlhermitte@users.noreply.github.com>
Co-authored-by: Michael Aquilina <michaelaquilina@gmail.com>
Co-authored-by: Joshua Cannon <joshdcannon@gmail.com>
Co-authored-by: László Velinszky <laszlo.velinszky@meltwater.com>
Co-authored-by: Lu Zhu <misterzhu@gmail.com>
Co-authored-by: BSKY <git@bsky.moe>
Co-authored-by: Trim21 <github@trim21.me>
Co-authored-by: Frost Ming <frostming@tencent.com>
Co-authored-by: Raphael Yancey <raphael@badfile.net>
Co-authored-by: adisbladis <adisbladis@gmail.com>
Co-authored-by: Dimitri Merejkowsky <dimitri.merejkowsky@tanker.io>
Co-authored-by: Jules Chéron <jules.cheron@gmail.com>
Co-authored-by: Alex Povel <48824213+alexpovel@users.noreply.github.com>
Copy link

github-actions bot commented Mar 3, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants