Bug 1437593 - Add support for using Pipfiles for managing virtual environment dependencies; r=ted

MozReview-Commit-ID: GWFJZfYWi5Y

--HG--
extra : rebase_source : 5b63da69ea4ce5b9149d07661088677ef996e98b
This commit is contained in:
Dave Hunt 2018-03-27 12:59:40 +01:00
Родитель 8bb28829fd
Коммит 9f1dc3ec97
3 изменённых файлов: 36 добавлений и 1 удалений

Просмотреть файл

@ -748,6 +748,14 @@ class MozbuildObject(ProcessExecutionMixin):
def _set_log_level(self, verbose):
self.log_manager.terminal_handler.setLevel(logging.INFO if not verbose else logging.DEBUG)
def activate_pipenv(self, path):
if not os.path.exists(path):
raise Exception('Pipfile not found: %s.' % path)
self._activate_virtualenv()
pipenv_reqs = os.path.join(self.topsrcdir, 'python/mozbuild/mozbuild/pipenv.txt')
self.virtualenv_manager.install_pip_requirements(pipenv_reqs, require_hashes=False, vendored=True)
self.virtualenv_manager.activate_pipenv(path)
class MachCommandBase(MozbuildObject):
"""Base class for mach command providers that wish to be MozbuildObjects.

Просмотреть файл

@ -0,0 +1,6 @@
third_party/python/certifi
third_party/python/pathlib
third_party/python/pipenv
third_party/python/six
third_party/python/virtualenv
third_party/python/virtualenv-clone

Просмотреть файл

@ -533,6 +533,28 @@ class VirtualenvManager(object):
subprocess.check_call([os.path.join(self.bin_path, 'pip')] + args,
stderr=subprocess.STDOUT)
def activate_pipenv(self, pipfile):
"""Install a Pipfile located at path and activate environment"""
pipenv = os.path.join(self.bin_path, 'pipenv')
env = os.environ.copy()
env.update({
'PIPENV_IGNORE_VIRTUALENVS': '1',
'PIPENV_PIPFILE': pipfile,
'WORKON_HOME': os.path.join(self.topobjdir, '_virtualenvs'),
})
subprocess.check_call(
[pipenv, 'install', '--deploy'],
stderr=subprocess.STDOUT,
env=env)
self.virtualenv_root = subprocess.check_output(
[pipenv, '--venv'],
stderr=subprocess.STDOUT,
env=env).rstrip()
self.activate()
def verify_python_version(log_handle):
"""Ensure the current version of Python is sufficient."""
@ -575,4 +597,3 @@ if __name__ == '__main__':
manager.populate()
else:
manager.ensure()