Skip to content

Commit 86a7408

Browse files
authored
Add another case to the normalized metadata directory names (oppia#23987)
* Add another case to the normalized metadata directory names * Fix logic
1 parent 07f1c0c commit 86a7408

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

scripts/install_python_prod_dependencies.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,13 @@ def _get_possible_normalized_metadata_directory_names(
438438
# Metadata folders can use different separators: hyphens, underscores, or
439439
# dots. We need to check all possible combinations since different packages
440440
# use different conventions (e.g., jaraco.classes, jaraco-classes,
441-
# jaraco_classes).
441+
# jaraco_classes). We also need to handle the case where only the first
442+
# delimiter is replaced (e.g. keyrings.google_artifactregistry_auth-1.1.2).
442443
name_variations = [
443444
library_name,
444445
library_name.replace('-', '_'),
445446
library_name.replace('-', '.'),
447+
library_name.replace('-', '.', 1).replace('-', '_'),
446448
]
447449

448450
possible_names = set()

scripts/install_python_prod_dependencies_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ def mock_find_distributions( # pylint: disable=unused-argument
787787
Distribution('dependency-1', '1.5.1', {}),
788788
Distribution('dependency2', '5.0.0', {}),
789789
Distribution('dependency3-hyphenated', '3.4.0', {}),
790+
Distribution('dependency4.multi-word-suffix', '1.1.2', {}),
790791
Distribution('dependency-5', '0.5.3', {}),
791792
Distribution(
792793
'dependency6',
@@ -810,6 +811,7 @@ def mock_list_dir(unused_path: str) -> List[str]:
810811
'dependency-1-1.5.1.dist-info',
811812
'dependency2-5.0.0.egg-info',
812813
'dependency3.hyphenated-3.4.0.dist-info',
814+
'dependency4.multi_word_suffix-1.1.2.dist-info',
813815
'dependency-5-0.5.3-py3.10.egg-info',
814816
'dependency_6-0.5.3-py3.10.egg-info',
815817
]
@@ -1004,6 +1006,10 @@ def test_normalize_python_library_name(self) -> None:
10041006
('backports.tarfile', 'backports-tarfile'),
10051007
('backports_tarfile', 'backports-tarfile'),
10061008
('backports-tarfile-2', 'backports-tarfile-2'),
1009+
(
1010+
'keyrings.google_artifactregistry_auth',
1011+
'keyrings-google-artifactregistry-auth',
1012+
),
10071013
('apache-beam[gcp]', 'apache-beam'),
10081014
('Pillow', 'pillow'),
10091015
('pylatexenc', 'pylatexenc'),

0 commit comments

Comments
 (0)