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

poetry install doesn't add license files to dist-info directory #9836

Closed
andreasdoll opened this issue Nov 7, 2024 · 8 comments
Closed

poetry install doesn't add license files to dist-info directory #9836

andreasdoll opened this issue Nov 7, 2024 · 8 comments
Assignees
Labels
kind/feature Feature requests/implementations

Comments

@andreasdoll
Copy link

andreasdoll commented Nov 7, 2024

Issue Kind

Change in current behaviour

Description

Hello

I want to add license files to the dist-info directory when using poetry install.

Currently the automatic inclusion of license files only applies the wheels/sdist (when using poetry build).
When using poetry install, no license file gets added to venv/Lib/site-packages/my_pkg-1.2.3.dist-info/ directory.

Is it intended behavior that install doesn't add the license files?
Can I achieve my goal somehow without modifying poetry?
If not: would you rather add the automatic inclusion to install, or manually as

[tool.poetry] 
include = [
    { path = "LICENSE.txt", format = "dist-info" },
]

Impact

My motivation is a tool dealing with licenses. In a CI/CD pipeline, I use poetry install to setup the environment in which I perform unit tests, and in this setup the license files are missing from the dist-info directory.

No issue when installing this tool from a package index, since in this case I use build outputs (wheel/sdist). which indeed have the license file automatically added.

Workarounds

No workaround known, since the include functionality in [tool.poetry] targets only wheels/sdist.

@andreasdoll andreasdoll added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Nov 7, 2024
@Secrus Secrus self-assigned this Nov 7, 2024
@Secrus Secrus added status/accepted Feature request accepted for the roadmap and removed status/triage This issue needs to be triaged labels Nov 7, 2024
@dimbleby
Copy link
Contributor

dimbleby commented Nov 7, 2024

poetry install is doing an editable install, pretty much all of the files in your project are not copied around. Why do you want LICENSE to be copied?

Indeed, what is the expected behaviour for an editable install if you update the LICENSE file in your project directory? Do you want a stale LICENSE file to be left in the dist-info?

@andreasdoll
Copy link
Author

The reason I'd like to have LICENSE copied is that the package expects its license file to be in the respective dist-info directory (which is the case when installed from a package index). This is not the case when installed via poetry install (in a CI/CD pipeline) and thus prevents me from executing unit tests without some mocking.

Regarding your second paragraph: true, install creates an editable install, yet poetry creates a dist-info/METADATA which is based on the information in pyproject.toml. If one updates this information, the METADATA file is outdated , just like the license file in your example. From my point of view, there is no reason to to treat those two sources of metadata differently, but I accept that there are differing POVs.

After looking a bit into the codebase, I think it will be less effort for me to mock in my tests than to submit a PR.
I understand that you probably have no interest in working on this yourself since it's quire a cornercase.

@Secrus Secrus removed the status/accepted Feature request accepted for the roadmap label Nov 7, 2024
@dimbleby
Copy link
Contributor

dimbleby commented Nov 7, 2024

METADATA is a generated file that poetry is required to create by the spec describing editable installs

In contrast, I see LICENSE as more analogous with any other part of the source tree - therefore in my opinion it would be undesirable to copy it around at an editable install.

Especially if it's anyway less effort for you not to pursue this then I'd just close it out.

(By the way, it seems curious to be trying to check the license of your own project. That's surely the one project where you really should already know the answer...)

@Secrus
Copy link
Member

Secrus commented Nov 7, 2024

Once we implement PEP 639 this will be a valid request, until then I close it as a duplicate of #9670

@Secrus Secrus closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
@dimbleby
Copy link
Contributor

dimbleby commented Nov 7, 2024

I don't see that PEP639 has anything to say about editable installs; but that discussion can wait until someone does something about PEP639

@Secrus
Copy link
Member

Secrus commented Nov 7, 2024

I don't see that PEP639 has anything to say about editable installs

The editable wheels (PEP 660) spec says that they should be installed just like regular wheels, which means that new changes to .dist-info from PEP 639 are also included.

@andreasdoll
Copy link
Author

andreasdoll commented Nov 7, 2024

(By the way, it seems curious to be trying to check the license of your own project. That's surely the one project where you really should already know the answer...)

Of course I know the license of the package itself. The problem lies in running the tests.
The simplified story is: the tool (it's a package) reads for all installed packages the license file from the respective dist-info directory

  1. this works if the package is installed with poetry add from a package index (since it uses wheel/sdist where the license file is in the dist-info directory)
  2. this doesn't work if the package is installed with poetry install since then there is no license file in the dist-info directory of this package

During testing in a CI/CD pipeline I'm in case (2) since I haven't built and published yet.

As said, I understand that you have a different opinion, thus feel free to close this issue.
By the way: thanks for your work on poetry!

Copy link

github-actions bot commented Dec 8, 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 Dec 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations
Projects
None yet
Development

No branches or pull requests

3 participants