Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pythonforandroid/pythonpackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,21 @@


def transform_dep_for_pip(dependency):
if dependency.find("@") > 0:
if dependency.find("@") > 0 and (
dependency.find("@") < dependency.find("://") or
"://" not in dependency
):
# WORKAROUND FOR UPSTREAM BUG:
# https://github.com/pypa/pip/issues/6097
# (Please REMOVE workaround once that is fixed & released upstream!)
#
# Basically, setup_requires() can contain a format pip won't install
# from a requirements.txt (PEP 508 URLs).
# To avoid this, translate to an #egg-name= reference:
url = (dependency.partition("@")[2].strip() +
"#egg-name=" +
# To avoid this, translate to an #egg= reference:
if dependency.endswith("#"):
dependency = dependency[:-1]
url = (dependency.partition("@")[2].strip().partition("#egg")[0] +
"#egg=" +
dependency.partition("@")[0].strip()
)
return url
Expand Down
28 changes: 22 additions & 6 deletions tests/test_pythonpackage_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,31 @@ def test_get_dep_names_of_package():


def test_transform_dep_for_pip():
transformed = transform_dep_for_pip(
"python-for-android @ https://github.com/kivy/"
"python-for-android/archive/master.zip"
# A reminder, this entire function we test here is just a workaround
# for https://github.com/pypa/pip/issues/6097 (and not a nice one.)
# As soon as upstream fixes it, we should throw it & this test out
transformed = (
transform_dep_for_pip(
"python-for-android @ https://github.com/kivy/" +
"python-for-android/archive/master.zip"
),
transform_dep_for_pip(
"python-for-android @ https://github.com/kivy/" +
"python-for-android/archive/master.zip" +
"#egg=python-for-android-master"
),
transform_dep_for_pip(
"python-for-android @ https://github.com/kivy/" +
"python-for-android/archive/master.zip" +
"#" # common hack variant used by others to make pip parse it
),
)
expected = (
"https://github.com/kivy/python-for-android/archive/master.zip"
"#egg-name=python-for-android"
"https://github.com/kivy/python-for-android/archive/master.zip" +
"#egg=python-for-android"
)
assert transformed == expected
assert transformed == (expected, expected, expected)
assert transform_dep_for_pip("https://a@b/") == "https://a@b/"


def test_is_filesystem_path():
Expand Down