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

Preferably use __pypackages__ in the current directory #1736

Closed
Ttayu opened this issue Feb 24, 2023 · 3 comments
Closed

Preferably use __pypackages__ in the current directory #1736

Ttayu opened this issue Feb 24, 2023 · 3 comments
Labels
⭐ enhancement Improvements for existing features

Comments

@Ttayu
Copy link

Ttayu commented Feb 24, 2023

Is your feature request related to a problem? Please describe.

In pdm 2.4.6, the current directory __pypackages__/{version}/lib is not referenced, but reference parent directory's one.
Suppose you have the following directory structure.
For example, when python is executed in package1, get_packages_path() in sitecustomize.py returns the location of __pypackages__ in package0.
Similarly, package2 refers to __pypackages__ in package1.

Can't this be made to use __pypackages__ in the current directory?

package0
├── package1
│   ├── package2
│   │   ├── pdm.lock
│   │   ├── __pypackages__
│   │   ├── pyproject.toml
│   │   └── README.md
│   ├── pdm.lock
│   ├── __pypackages__
│   ├── pyproject.toml
│   └── README.md
├── __pypackages__
├── pdm.lock
├── pyproject.toml
└── README.md

Version

pdm: 2.4.6
python: 3.10
OS:

NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Describe the solution you'd like

Use find_paths.append(script_dir)

find_paths.insert(0, script_dir)

I did not understand the intention of using "insert".
I have looked into the issue and am sorry if this has already been discussed.

@Ttayu Ttayu added the ⭐ enhancement Improvements for existing features label Feb 24, 2023
@frostming
Copy link
Collaborator

I don't think your proposed solution has anything to do with the described issue.

get_packages_path() requires __pypackages__/{version}/lib to exist, can you confirm it exists in package1?

@Ttayu
Copy link
Author

Ttayu commented Feb 26, 2023

I assume that the lib directory exists in all __pypackages__ directories.
In fact, the append function works as I expected.
I am wondering if this is the expected behavior according to pdm.

@Ttayu
Copy link
Author

Ttayu commented Feb 26, 2023

Setup

$ cd work_dir
$ mkdir -p package0/package1/
$ cd package0
$ pdm init
# All interactive must be set to 'yes'. Otherwise, the 'name' variable will not be initialized in pyproject.toml
$ pdm add isort # anything is ok.
$ cd package1
$ pdm init
$ pdm add mypy

Good

$ pwd
/path/to/work_dir/package0/package1
$ python -c "import mypy"
$ python -c "import isort" # ModuleNotFoundError: No module named 'isort'

Bad?

$ pwd
/path/to/work_dir/package0/package1
$ python
>>> import isort
>>> import mypy
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'mypy'

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

No branches or pull requests

2 participants