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

Unable to handle *.pth files that use Python rather than paths #6797

Open
kdowney-talos opened this issue Dec 24, 2024 · 0 comments
Open

Unable to handle *.pth files that use Python rather than paths #6797

kdowney-talos opened this issue Dec 24, 2024 · 0 comments
Assignees
Labels
needs repro Issue has not been reproduced yet

Comments

@kdowney-talos
Copy link

Environment data

  • Pylance version: 2024.12.1
  • OS and version: Ubuntu 22.04 (dev container) on MacOS 15.2, ARM65
  • Python version (& distribution if applicable, e.g. Anaconda): 3.12

Code Snippet

Editable packages which generate *.pth files like this:

/workspaces/pms/serenity.base/src/python

work file, and the imports are shown. But if you have one more like this:

import __editable___serenity_analytics_1_0_0_finder; __editable___serenity_analytics_1_0_0_finder.install()

then you'll get errors regarding missing imports like this:

Import "serenity_analytics.validators.dataframe_validators" could not be resolved

In our case, it came about due to this pyproject.toml config, which mapped the package to two different directories:

[tool.setuptools.packages.find]
where = ["src/python", "tests"]
include = ["serenity_*"]

Repro Steps

See above.

Expected behavior

Both format pth files should be handled, and the module should resolve properly.

NOTE: unit tests, etc. all work fine even though imports are not found, so they are valid.

Actual behavior

Imports from such editable installs are incorrectly marked as missing.

Logs

I believe these are the relevant lines -- as you can see, the one package that has the different style of *.pth is not included in the list:

2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)   Finding python search paths
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)   Executing interpreter: '/workspaces/pms/serenity.middleware/.venv/bin/python'
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)   Skipping '/usr/lib/python312.zip' because it is not a valid directory
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)   Received 9 paths from interpreter
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)     file:///usr/lib/python3.12
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)     file:///usr/lib/python3.12/lib-dynload
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.middleware/.venv/lib/python3.12/site-packages
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.base/src/python
2024-12-24 21:14:37.118 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.base.services/src/python
2024-12-24 21:14:37.119 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.data.client/src/python
2024-12-24 21:14:37.119 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.middleware/src/python
2024-12-24 21:14:37.119 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.risk/src/python
2024-12-24 21:14:37.119 [info] [Info  - 9:14:37 PM] (2526)     file:///workspaces/pms/serenity.specifications/src/python

which is consistent with the output of:

python -c "import sys; print('\n'.join(sys.path))"

That suggests that maybe this way of enumerating the paths isn't sufficient?

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants