SHA256
1
0
forked from pool/python-pdm

- Add findpython-022.patch to make package work with findpython

0.2.2 (from gh#pdm-project/pdm#1516).

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-pdm?expand=0&rev=22
This commit is contained in:
Matej Cepl 2022-11-16 08:59:17 +00:00 committed by Git OBS Bridge
parent 7e8fb22f0e
commit aeb3cb44c9
3 changed files with 110 additions and 3 deletions

100
findpython-022.patch Normal file
View File

@ -0,0 +1,100 @@
From f8ec8b7bda1b88e60b554b5713ca615c9bf94367 Mon Sep 17 00:00:00 2001
From: Frost Ming <mianghong@gmail.com>
Date: Wed, 16 Nov 2022 09:25:21 +0800
Subject: [PATCH] fix: test against the latest findpython
---
news/1516.bugfix.md | 1 +
src/pdm/cli/actions.py | 16 +++++-----------
src/pdm/models/python.py | 11 +++++++----
tests/cli/test_use.py | 4 ++--
4 files changed, 15 insertions(+), 17 deletions(-)
create mode 100644 news/1516.bugfix.md
--- /dev/null
+++ b/news/1516.bugfix.md
@@ -0,0 +1 @@
+Fix the test failure with the latest `findpython` installed.
--- a/src/pdm/cli/actions.py
+++ b/src/pdm/cli/actions.py
@@ -31,12 +31,7 @@ from pdm.cli.utils import (
set_env_in_reg,
translate_groups,
)
-from pdm.exceptions import (
- InvalidPyVersion,
- NoPythonVersion,
- PdmUsageError,
- ProjectError,
-)
+from pdm.exceptions import NoPythonVersion, PdmUsageError, ProjectError
from pdm.formats import FORMATS
from pdm.formats.base import array_of_inline_tables, make_array, make_inline_table
from pdm.models.caches import JSONFileCache
@@ -584,8 +579,10 @@ def do_use(
python = python.strip()
def version_matcher(py_version: PythonInfo) -> bool:
- return ignore_requires_python or project.python_requires.contains(
- str(py_version.version), True
+ return (
+ ignore_requires_python
+ or py_version.valid
+ and project.python_requires.contains(str(py_version.version), True)
)
if not project.cache_dir.exists():
@@ -647,9 +644,6 @@ def do_use(
if python:
use_cache.set(python, selected_python.path.as_posix())
- if not selected_python.valid:
- path = str(selected_python.path)
- raise InvalidPyVersion(f"Invalid Python interpreter: {path}")
if not save:
return selected_python
old_python = (
--- a/src/pdm/models/python.py
+++ b/src/pdm/models/python.py
@@ -5,7 +5,7 @@ from pathlib import Path
from typing import Any
from findpython import PythonVersion
-from packaging.version import Version
+from packaging.version import InvalidVersion, Version
from pdm.utils import cached_property
@@ -72,6 +72,9 @@ class PythonInfo:
@property
def identifier(self) -> str:
- if os.name == "nt" and self.is_32bit:
- return f"{self.major}.{self.minor}-32"
- return f"{self.major}.{self.minor}"
+ try:
+ if os.name == "nt" and self.is_32bit:
+ return f"{self.major}.{self.minor}-32"
+ return f"{self.major}.{self.minor}"
+ except InvalidVersion:
+ return "unknown"
--- a/tests/cli/test_use.py
+++ b/tests/cli/test_use.py
@@ -6,7 +6,7 @@ from pathlib import Path
import pytest
from pdm.cli import actions
-from pdm.exceptions import InvalidPyVersion
+from pdm.exceptions import NoPythonVersion
from pdm.models.caches import JSONFileCache
@@ -56,7 +56,7 @@ echo hello
shim_path = project.root.joinpath("python_shim.sh")
shim_path.write_text(wrapper_script)
shim_path.chmod(0o755)
- with pytest.raises(InvalidPyVersion):
+ with pytest.raises(NoPythonVersion):
actions.do_use(project, shim_path.as_posix())

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 16 08:58:23 UTC 2022 - Matej Cepl <mcepl@suse.com>
- Add findpython-022.patch to make package work with findpython
0.2.2 (from gh#pdm-project/pdm#1516).
-------------------------------------------------------------------
Tue Nov 15 19:09:33 UTC 2022 - Matej Cepl <mcepl@suse.com>

View File

@ -32,6 +32,9 @@ Summary: Python Development Master
License: MIT
URL: https://github.com/pdm-project/pdm/
Source0: https://files.pythonhosted.org/packages/source/p/pdm/pdm-%{version}.tar.gz
# PATCH-FIX-UPSTREAM findpython-022.patch gh#pdm-project/pdm#1516 mcepl@suse.com
# Makes the module work with findpython 0.2.2
Patch0: findpython-022.patch
BuildRequires: %{python_module base >= 3.7}
BuildRequires: %{python_module pdm-pep517 >= 1.0}
BuildRequires: %{python_module pip}
@ -40,7 +43,7 @@ BuildRequires: python-rpm-macros
Requires: python-blinker
Requires: python-cachecontrol >= 0.12.11
Requires: python-certifi
Requires: python-findpython >= 0.2.0
Requires: python-findpython >= 0.2.2
Requires: python-packaging >= 20.9
Requires: python-pep517 >= 0.11.0
Requires: python-platformdirs
@ -105,8 +108,6 @@ donttest="network"
# mock testing finds the wrong python versions in our multiflavor setup
donttest="$donttest or test_project_packages_path or test_conda_backend_create"
donttest="$donttest or test_init_non_interactive"
# gh#pdm-project/pdm#1516
donttest="$donttest or test_use_invalid_wrapper_python"
%pytest -k "not ($donttest)"
%endif