Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix corner case of pip hack workaround we should get rid of anyway #1807

Merged
merged 1 commit into from May 12, 2019
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