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 install from requirements.txt does not consider auto selected python version #3095

Closed
1 task done
vitidev opened this issue Aug 12, 2024 · 1 comment · Fixed by #3097
Closed
1 task done

pdm install from requirements.txt does not consider auto selected python version #3095

vitidev opened this issue Aug 12, 2024 · 1 comment · Fixed by #3097
Assignees
Labels
🐛 bug Something isn't working

Comments

@vitidev
Copy link

vitidev commented Aug 12, 2024

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

I want to use pdm install for "quick install and run" but it doesn't work properly

Steps to reproduce

create dir with requirements.txt (with one dep: requests)

pdm install -v
Found following files from other formats that you may import:
0. z:/test/requirements.txt (requirements)
1. don't do anything, I will import later.
Please select: 0
WARNING: Project requires a python version of , The virtualenv is being created for you as it cannot be matched to the right version.
INFO: python.use_venv is on, creating a virtualenv for this project...
Run command: ['C:\\Users\\viti\\.local\\pipx\\venvs\\pdm\\Scripts\\python.exe', '-m', 'virtualenv', 'z:\\test\\.venv', '-p', 'G:\\Dev\\Python3.12\\python.EXE', '--prompt=test-3.12', '--no-pip', '--no-setuptools', '--no-wheel']
created virtual environment CPython3.12.4.final.0-64 in 67ms
  creator CPython3Windows(dest=z:\test\.venv, clear=False, no_vcs_ignore=False, global=False)
  activators BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
Virtualenv is created successfully at z:\test\.venv
The project's requires-python has been set to >=3.12. You can change it later if necessary.
Changes are written to pyproject.toml.
WARNING: Lockfile does not exist
Updating the lock file...
STATUS: Resolving dependencies
STATUS: Resolve for environment ()
pdm.termui: ======== Start resolving requirements ========
pdm.termui:   requests
pdm.termui:   Adding requirement requests
C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\resolver\providers.py:200: 
PackageWarning: Skipping [email protected] because it requires Python>=3.8 but the lock targets to work with all Python versions. 
Instead, another version of requests that supports all Python versions will be used.
...
...
INFO: Use `-q/--quiet` to suppress these warnings, or ignore them per-package with `ignore_package_warnings` config in [tool.pdm] table.
  Lock successful.
Changes are written to pdm.lock.
Synchronizing working set with resolved packages: 5 to add, 0 to update, 0 to remove

  v Install certifi 2021.10.8 successful
  v Install idna 2.6 successful
  v Install requests 2.18.4 successful
  v Install urllib3 1.22 successful

   All complete! 5/5 0:00:00

Actual behavior

it selects version of python
The project's requires-python has been set to >=3.12
and immediately ignores
because it requires Python>=3.8 but the lock targets to work with all Python versions
and break outdated command

$ pdm outdated -v
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "c:\users\viti\.local\bin\pdm.exe\__main__.py", line 7, in <module>
  File "C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 346, in main
    return core.main(args or sys.argv[1:])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 264, in main
    raise cast(Exception, err).with_traceback(traceback) from None
  File "C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 259, in main
    self.handle(project, options)
  File "C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\core.py", line 195, in handle
    command.handle(project, options)
  File "C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\cli\commands\outdated.py", line 99, in handle
    if name == normalize_name(project.name):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\viti\.local\pipx\venvs\pdm\Lib\site-packages\pdm\utils.py", line 347, in normalize_name
    name = re.sub(r"[^A-Za-z0-9]+", "-", name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "G:\Dev\Python3.12\Lib\re\__init__.py", line 186, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

Expected behavior

Consider auto selected version of Python when installing dependencies.

Environment Information

I have 3 versions of python installed: 3.10, 3.11, 3.12
pdm installed via pipx

    pdm info && pdm info --env
    PDM version:
      2.17.3
    Python Interpreter:
      z:\test\.venv\Scripts\python.exe (3.12)
    Project Root:
      z:/test
    Local Packages:

    {
      "implementation_name": "cpython",
      "implementation_version": "3.12.4",
      "os_name": "nt",
      "platform_machine": "AMD64",
      "platform_release": "10",
      "platform_system": "Windows",
      "platform_version": "10.0.19045",
      "python_full_version": "3.12.4",
      "platform_python_implementation": "CPython",
      "python_version": "3.12",
      "sys_platform": "win32"
    }
@vitidev vitidev added the 🐛 bug Something isn't working label Aug 12, 2024
@frostming frostming self-assigned this Aug 13, 2024
frostming added a commit that referenced this issue Aug 13, 2024
@vitidev
Copy link
Author

vitidev commented Aug 14, 2024

@frostming

pdm outdated still gives error

[TypeError]: expected string or bytes-like object, got 'NoneType'

after this pdm install
it's not critical because it's not necessary, I'm just informing you

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