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 sync (editable mode) doesn't handle/allow custom *.pth files #10207

Open
tik-stbuehler opened this issue Feb 20, 2025 · 6 comments
Open
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@tik-stbuehler
Copy link

Issue Kind

Brand new capability

Description

The wheel build via poetry build includes custom *.pth files, but they are not installed in editable mode, and there doesn't seem to be an option to enforce this (also couldn't find anything in the source that might do it).

Code references for editable wheel build (which is later installed to the virtualenv):

Impact

I use *.pth-files to initialize the environment; this is an application and is always installed in its own virtualenv, so there is no downside, but it makes life much easier.

Workarounds

With hatch instead of poetry I can install *.pth-files using [tool.hatch.build.targets.wheel.force-include].

@tik-stbuehler tik-stbuehler added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Feb 20, 2025
@Secrus
Copy link
Member

Secrus commented Feb 20, 2025

It sounds like you just need to include the file in the wheel

[tool.poetry]
include = [
    { path = "*.pth", format = "wheel" },
]

@tik-stbuehler
Copy link
Author

It sounds like you just need to include the file in the wheel

[tool.poetry]
include = [
    { path = "*.pth", format = "wheel" },
]

As i said: it ends up in the "normal" wheel just fine, but not in the "editable" wheel (which basically only contains the auto-created PROJECT.pth-file and some metadata).

In "editable" mode it doesn't call _copy_module(), which would normally add the "included" files to the wheel; it calls _add_pth(), which only collects (base) paths of packages to write into the PROJECT.pth file.

@Secrus
Copy link
Member

Secrus commented Feb 20, 2025

PRs are welcome

@dimbleby
Copy link
Contributor

PRs are welcome

current behaviour seems correct to me. All files are not included in editable wheels, I see no reason to make a special case of some?

@tik-stbuehler
Copy link
Author

PRs are welcome

Before I (or somebody else) tries to implement support for this it'd be nice to know if it'd be considered (and whether it needs to be hidden behind flags / options).

current behaviour seems correct to me. All files are not included in editable wheels, I see no reason to make a special case of some?

I think "editable" basically means "can edit the source and don't need to re-install to activate the changes" (but you probably need to restart your program).

One can argue that this should mean that the editable wheel doesn't include any of the source files, but: I'd also say that "editable wheels should behave the same as normal wheels" is a reasonable requirement.

I see a few ways to go:

  • don't support *.pth-files in editable installs (as it is now in poetry)
  • make python look for *.pth files in all search directories
  • try symlinking *.pth-files instead of copying (on platforms that support it): still no new *.pth files will be found, but changes to existing ones might get applied
  • just copy the *.pth-files - neither changes, deletions or creations of/to *.pth files are applied without reinstall

As far as I know poetry doesn't really support installing "non-editable" (neither via poetry sync nor via poetry install), and pip install wouldn't (properly) support packages from multiple sources.

@dimbleby
Copy link
Contributor

an editable install just means arranging that the path is such that the python code in your project is available.

That does not mean copying around other files that happen to have special meaning. IMO what you are doing is non-standard, and I would not expect tools to have special support for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

3 participants