Skip to content

Commit f0d0819

Browse files
committed
Remove version fallback
1 parent a2d2fd1 commit f0d0819

File tree

2 files changed

+17
-43
lines changed

2 files changed

+17
-43
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_patched_pip.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,17 +439,12 @@ def __init__(self, *args, **kwargs):
439439
finally:
440440
thread.join()
441441

442-
def test_patches_repo_version_resolution_exact(self):
442+
def test_patches_repo_version_resolution(self):
443443
patch_dir_parent = self.patch_dir
444-
self.patch_dir = patch_dir_parent / '1.3.2'
444+
graalpy_version = '1.3.2'
445+
self.patch_dir = patch_dir_parent / graalpy_version
445446
self.patch_dir.mkdir()
446-
self.check_installing_with_patch_repo(str(patch_dir_parent / '<version>'), graalpy_version='1.3.2')
447-
448-
def test_patches_repo_version_resolution_major(self):
449-
patch_dir_parent = self.patch_dir
450-
self.patch_dir = patch_dir_parent / '1.3'
451-
self.patch_dir.mkdir()
452-
self.check_installing_with_patch_repo(str(patch_dir_parent / '<version>'), graalpy_version='1.3.2')
447+
self.check_installing_with_patch_repo(str(patch_dir_parent / '<version>'), graalpy_version=graalpy_version)
453448

454449
def test_patches_repo_version_resolution_dev(self):
455450
patch_dir_parent = self.patch_dir

graalpython/lib-graalpython/patches/pip-23.2.1.patch

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ index a8cd133..20dd1e6 100644
127127
# file in .data maps to same location as file in wheel root).
128128
diff --git a/pip/_internal/utils/graalpy.py b/pip/_internal/utils/graalpy.py
129129
new file mode 100644
130-
index 0000000..375f66e
130+
index 0000000..5b35102
131131
--- /dev/null
132132
+++ b/pip/_internal/utils/graalpy.py
133-
@@ -0,0 +1,351 @@
133+
@@ -0,0 +1,330 @@
134134
+import abc
135135
+import logging
136136
+import os
@@ -175,10 +175,6 @@ index 0000000..375f66e
175175
+ pass
176176
+
177177
+
178-
+class RepositoryNotFoundException(RepositoryException):
179-
+ pass
180-
+
181-
+
182178
+class AbstractPatchRepository(metaclass=abc.ABCMeta):
183179
+ def __init__(self, metadata: dict):
184180
+ self._repository = metadata
@@ -251,8 +247,6 @@ index 0000000..375f66e
251247
+ try:
252248
+ with open(patches_path / METADATA_FILENAME) as f:
253249
+ metadata_content = f.read()
254-
+ except FileNotFoundError:
255-
+ raise RepositoryNotFoundException(f"'{METADATA_FILENAME}' doesn't exist")
256250
+ except OSError as e:
257251
+ raise RepositoryException(f"'{METADATA_FILENAME}' cannot be read: {e}")
258252
+ return cls(patches_path, cls.metadata_from_string(metadata_content))
@@ -278,12 +272,8 @@ index 0000000..375f66e
278272
+ try:
279273
+ url = url_for_file(patches_url, METADATA_FILENAME)
280274
+ response = cls.get_session().get(url)
281-
+ if response.status_code == 404:
282-
+ raise RepositoryNotFoundException(f"'{METADATA_FILENAME} not found at url: {url}")
283275
+ response.raise_for_status()
284276
+ metadata_content = response.content.decode('utf-8')
285-
+ except RepositoryNotFoundException:
286-
+ raise
287277
+ except Exception as e:
288278
+ raise RepositoryException(f"'{METADATA_FILENAME} cannot be retrieved': {e}")
289279
+ return cls(patches_url, cls.metadata_from_string(metadata_content))
@@ -321,29 +311,18 @@ index 0000000..375f66e
321311
+
322312
+
323313
+def create_patch_repository(patches_url):
324-
+ if patches_url:
325-
+ if VERSION_PARAMETER in patches_url:
326-
+ if not GRAALPY_VERSION.endswith('-dev'):
327-
+ try_version = GRAALPY_VERSION
328-
+ while '.' in try_version:
329-
+ url = patches_url.replace(VERSION_PARAMETER, try_version)
330-
+ try:
331-
+ return repository_from_url_or_path(url)
332-
+ except RepositoryNotFoundException:
333-
+ logger.debug("No patch repository found for version %s at %s", try_version, url)
334-
+ except RepositoryException as e:
335-
+ logger.warning("Failed to load GraalPy patch repository from %s: %s", url, e)
336-
+ logger.warning("Falling back to internal GraalPy patch repository")
337-
+ break
338-
+ try_version = try_version.rsplit('.', 1)[0]
339-
+ else:
340-
+ logger.debug("Skipping versioned GraalPy patch repository on snapshot build")
314+
+ if patches_url and VERSION_PARAMETER in patches_url:
315+
+ if not GRAALPY_VERSION.endswith('-dev'):
316+
+ patches_url = patches_url.replace(VERSION_PARAMETER, GRAALPY_VERSION)
341317
+ else:
342-
+ try:
343-
+ return repository_from_url_or_path(patches_url)
344-
+ except RepositoryException as e:
345-
+ logger.warning("Failed to load GraalPy patch repository from %s: %s", patches_url, e)
346-
+ logger.warning("Falling back to internal GraalPy patch repository")
318+
+ logger.debug("Skipping versioned GraalPy patch repository on snapshot build")
319+
+ patches_url = None
320+
+ if patches_url:
321+
+ try:
322+
+ return repository_from_url_or_path(patches_url)
323+
+ except RepositoryException as e:
324+
+ logger.warning("Failed to load GraalPy patch repository from %s: %s", patches_url, e)
325+
+ logger.warning("Falling back to internal GraalPy patch repository")
347326
+ try:
348327
+ return LocalPatchRepository.from_path(DEFAULT_PATCHES_PATH)
349328
+ except RepositoryException as e:

0 commit comments

Comments
 (0)