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

PDM doesn't find Python interpreters when PDM_IGNORE_ACTIVE_VENV is set #2779

Closed
1 task done
p-rogalski opened this issue Apr 8, 2024 · 2 comments · Fixed by #2781
Closed
1 task done

PDM doesn't find Python interpreters when PDM_IGNORE_ACTIVE_VENV is set #2779

p-rogalski opened this issue Apr 8, 2024 · 2 comments · Fixed by #2781
Labels
🐛 bug Something isn't working

Comments

@p-rogalski
Copy link
Contributor

p-rogalski commented Apr 8, 2024

  • I have searched the issue tracker and believe that this is not a duplicate.

Make sure you run commands with -v flag before pasting the output.

Steps to reproduce

  1. Have some Python version >=3.10 installed

  2. Use following minimal pyproject.toml

    [project]
    name = "test"
    version = "0.0.1"
    requires-python = ">=3.10"
  3. Set environment variable PDM_IGNORE_SAVED_PYTHON and PDM_IGNORE_ACTIVE_VENV.

  4. Try to install the project:

    pdm install --verbose

Actual behavior

PDM does not find a Python version to use and errors out:

PS C:\Users\progalski\git\test> pdm install --verbose
WARNING: Lockfile does not exist
Updating the lock file...
[NoPythonVersion]: No Python that satisfies >=3.10 is found on the system.

Expected behavior

According to PDM Docs: Virtualenv auto-detection I would expect that PDM creates a new virtual environment because virtual env auto-detection fails.

Environment Information

# Paste the output of `pdm info && pdm info --env` below:
PS C:\Users\progalski\git\test> pdm info && pdm info --env
[NoPythonVersion]: No Python that satisfies >=3.10 is found on the system.

Environment Information without the problematic environment variables set:

# Paste the output of `pdm info && pdm info --env` below:
PDM version:
  2.13.2
Python Interpreter:
  C:\Users\progalski\git\test\.venv\Scripts\python.exe (3.11)
Project Root:
  C:/Users/progalski/git/test
Local Packages:

{
  "implementation_name": "cpython",
  "implementation_version": "3.11.4",
  "os_name": "nt",
  "platform_machine": "AMD64",
  "platform_release": "10",
  "platform_system": "Windows",
  "platform_version": "10.0.22631",
  "python_full_version": "3.11.4",
  "platform_python_implementation": "CPython",
  "python_version": "3.11",
  "sys_platform": "win32"
}
@p-rogalski p-rogalski added the 🐛 bug Something isn't working label Apr 8, 2024
@p-rogalski
Copy link
Contributor Author

p-rogalski commented Apr 8, 2024

I had a look into the PDM source code, the logic of getting a valid interpreter can be found here:

def resolve_interpreter(self) -> PythonInfo:

If PDM_IGNORE_ACTIVE_VENV is set, the logic which creates a new virtual environment is skipped completely. This is unexpected, because the env var name suggests that it just ignores the currently activated venv.

Instead, I would PDM expect to fall back to creating a new virtual environment when python.use_venv is True.

@p-rogalski p-rogalski changed the title PDM doesn't find Python interpreters when PDM_IGNORE_ACTIVE_VENV and PDM_IGNORE_SAVED_PYTHON are both set PDM doesn't find Python interpreters when PDM_IGNORE_ACTIVE_VENV is set Apr 8, 2024
@noirbizarre
Copy link
Member

I just hit the same issue.
Working on a fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working
Projects
None yet
2 participants