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

Resolving Missing Package Source Directories in Editable Installs #1871

Open
AdrianCert opened this issue Dec 28, 2024 · 1 comment
Open

Comments

@AdrianCert
Copy link

I found that not all package source directories are included in the .pth file during an editable install.

Project Setup

Here’s how my project is structured:

packages/a/src/mypkg/a.py
packages/a/src/mypkg/a1.py
packages/b/src/mypkg/b.py
packages/b/src/mypkg/c.py

In the pyproject.toml, the setup is properly configured like this:

[tool.hatch.build]
packages = [
"/packages/a/src/mypkg",
"/packages/b/src/mypkg",
"/packages/c/src/mypkg",
# more packages here
]

Behavior Observed

Normal Build: When performing a standard build, the site-packages directory correctly includes all Python files as expected.
Editable Install: During an editable install, the .pth file only contains the last entry from the package list. This means not all source directories are mapped correctly.

Likely Cause

The issue seems to originate from this section of the Hatch codebase:

editable_project.add_to_path(os.path.dirname(relative_path))

Here’s the key problem:

The current implementation creates a dictionary mapping top-level package names to a path. This results in a 1-to-1 relationship, where only the last entry for a given top-level package is retained.

Suggested Fix

Instead of mapping top-level packages to paths, the relationship should be inverted: map paths to top-level packages. This change would ensure all relevant paths are included in the .pth file.

@AdrianCert
Copy link
Author

If the suggested fix is reasonable, I can come up with a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant