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

Add developer mode #111

Closed
wants to merge 2 commits into from
Closed
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
95 changes: 75 additions & 20 deletions briefcase/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,38 +258,94 @@ def _git_pull(self, path):
print('Unable to update template {}, using unpulled.'.format(template_name))
print(error_message)

def install_app_requirements(self):
print(" * Installing requirements...")
if self.distribution.install_requires:
def _install_requirement(self, requirements, target):
if not requirements:
print("No requirements.")
return

class UglyHack:
"""
TODO: Use a more direct way to get the information ;)
"""
def __init__(self, requirements):
self.requirements = requirements

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

def get(self, requirement):
"""
return the 'pip freeze' line for the given requirement
e.g.:
--editable=git+https://github.com/pybee/toga.git@02a47d27d32d16b54800b658d9afd2b316924fd1#egg=toga_gtk&subdirectory=src/gtk
"""
egg_name = requirement.replace("-", "_")
for line in self.freeze_lines:
if egg_name in line:
line=line.replace("-e ", "--editable=")
return line

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

toga_requirements, requirements = UglyHack(requirements).transform()
if toga_requirements:
pip.main([
'install',
'--upgrade',
'--no-deps',
'--force-reinstall',
'--target={}'.format(self.app_packages_dir)
] + self.distribution.install_requires,
'--target={}'.format(target)
] + toga_requirements,
)
else:
print("No requirements.")

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

def install_app_requirements(self):
print(" * Installing requirements...")
self._install_requirement(
self.distribution.install_requires,
target=self.app_packages_dir
)

def install_platform_requirements(self):
print(" * Installing platform requirements...")
if self.app_requires:
pip.main([
'install',
'--upgrade',
'--force-reinstall',
'--target={}'.format(self.app_packages_dir),
] + self.app_requires
)
else:
print("No platform requirements.")
self._install_requirement(self.app_requires,
target=self.app_packages_dir
)

def install_code(self):
print(" * Installing project code...")
pip.main([
'install',
'--upgrade',
'--force-reinstall',
'--no-dependencies', # We just want the code, not the dependencies
'--target={}'.format(self.app_dir),
'.'
Expand All @@ -316,7 +372,6 @@ def install_launch_scripts(self):
pip.main([
'install',
'--upgrade',
'--force-reinstall',
'--target=%s' % self.app_packages_dir,
'setuptools'
])
Expand Down
1 change: 0 additions & 1 deletion briefcase/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ def install_platform_requirements(self):
pip.main([
'install',
'--upgrade',
'--force-reinstall',
] + self.app_requires
)
else:
Expand Down