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

Files listed in exclude are included when building wheel only #1384

Closed
3 tasks done
finswimmer opened this issue Sep 18, 2019 · 5 comments
Closed
3 tasks done

Files listed in exclude are included when building wheel only #1384

finswimmer opened this issue Sep 18, 2019 · 5 comments
Labels
area/build-system Related to PEP 517 packaging (see poetry-core) kind/bug Something isn't working as expected
Milestone

Comments

@finswimmer
Copy link
Member

finswimmer commented Sep 18, 2019

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name:Ubuntu 18.04
  • Poetry version: Poetry 0.12.17
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

I have defined a file to be excluded from the build in my pyproject.toml. When running poetry build this file is excluded in the sdist and wheel. When running poetry build -f wheel the file is included, running poetry build -f sdist the file is excluded.

Way to reproduce:

$ poetry new issue
$ cd issue
$ poetry install
$ touch issue/exclude_me.py

Add issue/exclude_me.py to the pyproject.toml

[tool.poetry]
name = "issue"
version = "0.1.0"
description = ""
authors = ["Fin Swimmer"]
exclude = ["issue/exclude_me.py"]

Run poetry build -vvv:

Using virtualenv: /home/finswimmer/.cache/pypoetry/virtualenvs/issue-py3.6
Building issue (0.1.0)
 - Building sdist
 - Adding: issue/__init__.py
 - Adding: pyproject.toml
 - Built issue-0.1.0.tar.gz

 - Building wheel
 - Adding: /tmp/tmpvo4lwtdk/issue-0.1.0/issue/__init__.py
 - Built issue-0.1.0-py3-none-any.whl

Run poetry build -vvv -f wheel:

Using virtualenv: /home/finswimmer/.cache/pypoetry/virtualenvs/issue-py3.6
Building issue (0.1.0)
 - Building wheel
 - Adding: /home/finswimmer/issue/issue/__init__.py
 - Adding: /home/finswimmer/issue/issue/exclude_me.py
 - Built issue-0.1.0-py3-none-any.whl

Run poetry build -vvv -f sdist:

Using virtualenv: /home/finswimer/.cache/pypoetry/virtualenvs/issue-py3.6
Building issue (0.1.0)
 - Building sdist
 - Adding: issue/__init__.py
 - Adding: pyproject.toml
 - Built issue-0.1.0.tar.gz
@sdispater
Copy link
Member

Does it also happen with the 1.0.0b1 release?

@finswimmer
Copy link
Member Author

Unfortunately yes:

$ poetry --version           
Poetry version 1.0.0b1
$ poetry build -vvv
Using virtualenv: /home/finswimmer/.cache/pypoetry/virtualenvs/issue-YJJEBOvC-py3.6
Building issue (0.1.0)
 - Building sdist
 - Adding: issue/__init__.py
 - Adding: pyproject.toml
 - Built issue-0.1.0.tar.gz

 - Building wheel
 - Adding: /tmp/tmpf9m_ej5q/issue-0.1.0/issue/__init__.py
 - Built issue-0.1.0-py3-none-any.whl
$ poetry build -vvv -f wheel
Using virtualenv: /home/finswimmer/.cache/pypoetry/virtualenvs/issue-YJJEBOvC-py3.6
Building issue (0.1.0)
 - Building wheel
 - Adding: /home/finswimmer/issue/issue/__init__.py
 - Adding: /home/finswimmer/issue/issue/exclude_me.py
 - Built issue-0.1.0-py3-none-any.whl
$ poetry build -vvv -f sdist
Using virtualenv: /home/finswimmer/.cache/pypoetry/virtualenvs/issue-YJJEBOvC-py3.6
Building issue (0.1.0)
 - Building sdist
 - Adding: issue/__init__.py
 - Adding: pyproject.toml
 - Built issue-0.1.0.tar.gz

What I notice is, that in case both packages are build the files are added from a tmp folder to the , whereas if only build the wheel it is added from the absolute path to original file.

I'm not familiar with the internals of poetry. Could it be, that if both packages are created, the wheel is builded from the sdist packages and if I just create the wheel something like python setup.py bdist_wheel is emulated? There are differences between sdist and wheel how and where one can define which files should be excluded. Maybe the problem is here in some way?

@sdispater sdispater added kind/bug Something isn't working as expected area/build-system Related to PEP 517 packaging (see poetry-core) labels Sep 30, 2019
@sdispater sdispater added this to the 1.0 milestone Sep 30, 2019
@finswimmer
Copy link
Member Author

finswimmer commented Oct 10, 2019

Hello,

I start trying to read the code and maybe I've found a point where to start.

In wheel.py the method find_excluded_files, which is inherited from Builder, will be overwritten by a method returning an empty set:

https://github.com/sdispater/poetry/blob/2966ab177206e8f8f888f6050a5f39b18cbda16b/poetry/masonry/builders/wheel.py#L202-L205

This is not done in sdist.py. There the original method from the Builder class is called.

https://github.com/sdispater/poetry/blob/2966ab177206e8f8f888f6050a5f39b18cbda16b/poetry/masonry/builders/builder.py#L78-L81

I'm not familiar with @lru_cache(maxsize=None) decorator, but I guess this causes that the method isn't executed twice.

Could it be, that if sdist and wheel are build, the result of the first call to this method, during building the sdist package, is used, when the wheel package is build in the next step. And if I only build the wheel package the method with the empty set returned is called instead?

fin swimmer

@finswimmer
Copy link
Member Author

finswimmer commented Oct 11, 2019

Ok, I think I got it. There are two issues.

The first is, as guessed above, the overwritten find_excluded_files method:

https://github.com/sdispater/poetry/blob/2966ab177206e8f8f888f6050a5f39b18cbda16b/poetry/masonry/builders/wheel.py#L202-L205

It must be removed.

The second problem is in the _copy_module method here:

https://github.com/sdispater/poetry/blob/2966ab177206e8f8f888f6050a5f39b18cbda16b/poetry/masonry/builders/wheel.py#L151-L158

Instead of:

if file in excluded:
    continue

one have to check if the relative filepath is in excluded:

if str(rel_file) in excluded:
    continue

It's time to learn how to create a pull request ;)

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

No branches or pull requests

2 participants