Skip to content

Commit 61e092c

Browse files
authored
Merge pull request #1807 from JonasT/run_setup_py_transform_fix
Fix corner case of pip hack workaround we should get rid of anyway
2 parents 6f08f52 + eb3fbce commit 61e092c

File tree

2 files changed

+31
-10
lines changed

2 files changed

+31
-10
lines changed

pythonforandroid/pythonpackage.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,21 @@
5555

5656

5757
def transform_dep_for_pip(dependency):
58-
if dependency.find("@") > 0:
58+
if dependency.find("@") > 0 and (
59+
dependency.find("@") < dependency.find("://") or
60+
"://" not in dependency
61+
):
5962
# WORKAROUND FOR UPSTREAM BUG:
6063
# https://github.com/pypa/pip/issues/6097
6164
# (Please REMOVE workaround once that is fixed & released upstream!)
6265
#
6366
# Basically, setup_requires() can contain a format pip won't install
6467
# from a requirements.txt (PEP 508 URLs).
65-
# To avoid this, translate to an #egg-name= reference:
66-
url = (dependency.partition("@")[2].strip() +
67-
"#egg-name=" +
68+
# To avoid this, translate to an #egg= reference:
69+
if dependency.endswith("#"):
70+
dependency = dependency[:-1]
71+
url = (dependency.partition("@")[2].strip().partition("#egg")[0] +
72+
"#egg=" +
6873
dependency.partition("@")[0].strip()
6974
)
7075
return url

tests/test_pythonpackage_basic.py

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,31 @@ def test_get_dep_names_of_package():
136136

137137

138138
def test_transform_dep_for_pip():
139-
transformed = transform_dep_for_pip(
140-
"python-for-android @ https://github.com/kivy/"
141-
"python-for-android/archive/master.zip"
139+
# A reminder, this entire function we test here is just a workaround
140+
# for https://github.com/pypa/pip/issues/6097 (and not a nice one.)
141+
# As soon as upstream fixes it, we should throw it & this test out
142+
transformed = (
143+
transform_dep_for_pip(
144+
"python-for-android @ https://github.com/kivy/" +
145+
"python-for-android/archive/master.zip"
146+
),
147+
transform_dep_for_pip(
148+
"python-for-android @ https://github.com/kivy/" +
149+
"python-for-android/archive/master.zip" +
150+
"#egg=python-for-android-master"
151+
),
152+
transform_dep_for_pip(
153+
"python-for-android @ https://github.com/kivy/" +
154+
"python-for-android/archive/master.zip" +
155+
"#" # common hack variant used by others to make pip parse it
156+
),
142157
)
143158
expected = (
144-
"https://github.com/kivy/python-for-android/archive/master.zip"
145-
"#egg-name=python-for-android"
159+
"https://github.com/kivy/python-for-android/archive/master.zip" +
160+
"#egg=python-for-android"
146161
)
147-
assert transformed == expected
162+
assert transformed == (expected, expected, expected)
163+
assert transform_dep_for_pip("https://a@b/") == "https://a@b/"
148164

149165

150166
def test_is_filesystem_path():

0 commit comments

Comments
 (0)