Skip to content

Commit

Permalink
try to install toga packages with "--no-deps" first
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Mar 18, 2018
1 parent 2596892 commit 02209e9
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions briefcase/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ class UglyHack:
"""
TODO: Use a more direct way to get the information ;)
"""
def __init__(self):
def __init__(self, requirements):
self.requirements = requirements

from pip.operations.freeze import freeze
self.freeze_lines = [line for line in freeze()]

Expand All @@ -283,21 +285,47 @@ def get(self, requirement):
line=line.replace("-e ", "--editable=")
return line

ugly = UglyHack()

final_requirements = []
def get_all_toga_req(self):
requirements = []
for line in self.freeze_lines:
if "toga" in line:# and not "toga_dummy" in line:
line=line.replace("-e ", "--editable=")
requirements.append(line)
return requirements

def transform(self):
toga_used = False
final_requirements = []
for requirement in requirements:
if "toga" in requirement:
toga_used = True
else:
final_requirements.append(
self.get(requirement) or requirement
)

if toga_used:
toga_requirements = self.get_all_toga_req()
else:
toga_requirements = None
return toga_requirements, final_requirements

for requirement in requirements:
print("Install %r to: %r" % (requirement, target))
final_requirements.append(
ugly.get(requirement) or requirement
toga_requirements, requirements = UglyHack(requirements).transform()
if toga_requirements:
pip.main([
'install',
'--no-deps',
'--force-reinstall',
'--target={}'.format(target)
] + toga_requirements,
)

pip.main([
'install',
'--upgrade',
'--force-reinstall',
'--target={}'.format(target)
] + final_requirements,
] + toga_requirements + requirements,
)

def install_app_requirements(self):
Expand Down

0 comments on commit 02209e9

Please sign in to comment.