Skip to content

Commit

Permalink
Backed out changeset f92dcf5319ae (bug 1490253) for bustage on test_m…
Browse files Browse the repository at this point in the history
…ozbuild_reading.py. CLOSED TREE
  • Loading branch information
ncsoregi committed Oct 9, 2018
1 parent 7278abd commit fbee846
Show file tree
Hide file tree
Showing 6 changed files with 208 additions and 121 deletions.
20 changes: 20 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]

[packages]
attrs = "==18.1.0"
blessings = "==1.7"
jsmin = "==2.1.0"
json-e = "==2.7.0"
pip-tools = "==3.0.0"
pipenv = "==2018.5.18"
pytest = "==3.6.2"
python-hglib = "==2.4"
requests = "==2.9.1"
six = "==1.10.0"
virtualenv = "==15.2.0"
voluptuous = "==0.11.5"
172 changes: 172 additions & 0 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion build/virtualenv_packages.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mozilla.pth:python/l10n
mozilla.pth:third_party/python/atomicwrites
mozilla.pth:third_party/python/attrs/src
mozilla.pth:third_party/python/blessings
mozilla.pth:third_party/python/Click
mozilla.pth:third_party/python/compare-locales
mozilla.pth:third_party/python/configobj
mozilla.pth:third_party/python/cram
Expand Down
56 changes: 16 additions & 40 deletions python/mozbuild/mozbuild/vendor_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from __future__ import absolute_import, print_function, unicode_literals

import os
import shutil
import subprocess

import mozfile
Expand All @@ -25,59 +24,36 @@ def vendor(self, packages=None):
self.topsrcdir, os.path.join('third_party', 'python'))

packages = packages or []
pipenv = self.ensure_pipenv()

self._activate_virtualenv()
pip_compile = os.path.join(self.virtualenv_manager.bin_path, 'pip-compile')
if not os.path.exists(pip_compile):
path = os.path.normpath(os.path.join(self.topsrcdir, 'third_party', 'python', 'pip-tools'))
self.virtualenv_manager.install_pip_package(path, vendored=True)
spec = os.path.join(vendor_dir, 'requirements.in')
requirements = os.path.join(vendor_dir, 'requirements.txt')
for package in packages:
if not all(package.partition('==')):
raise Exception('Package {} must be in the format name==version'.format(package))

with NamedTemporaryFile('w') as tmpspec:
shutil.copyfile(spec, tmpspec.name)
self._update_packages(tmpspec.name, packages)
for package in packages:
subprocess.check_call(
[pipenv, 'install', package],
cwd=self.topsrcdir)

# resolve the dependencies and update requirements.txt
subprocess.check_output([
pip_compile,
tmpspec.name,
'--no-header',
'--no-index',
'--output-file', requirements,
'--generate-hashes'])
with NamedTemporaryFile('w') as requirements:
# determine the dependency graph and generate requirements.txt
subprocess.check_call(
[pipenv, 'lock', '--requirements'],
cwd=self.topsrcdir,
stdout=requirements)

with TemporaryDirectory() as tmp:
# use requirements.txt to download archived source distributions of all packages
self.virtualenv_manager._run_pip([
'download',
'-r', requirements,
'-r', requirements.name,
'--no-deps',
'--dest', tmp,
'--no-binary', ':all:',
'--disable-pip-version-check'])
self._extract(tmp, vendor_dir)

shutil.copyfile(tmpspec.name, spec)
self.repository.add_remove_files(vendor_dir)

def _update_packages(self, spec, packages):
for package in packages:
if not all(package.partition('==')):
raise Exception('Package {} must be in the format name==version'.format(package))

requirements = {}
with open(spec, 'r') as f:
for line in f.readlines():
name, version = line.rstrip().split('==')
requirements[name] = version
for package in packages:
name, version = package.split('==')
requirements[name] = version

with open(spec, 'w') as f:
for name, version in sorted(requirements.items()):
f.write('{}=={}\n'.format(name, version))
self.repository.add_remove_files(vendor_dir)

def _extract(self, src, dest):
"""extract source distribution into vendor directory"""
Expand Down
12 changes: 0 additions & 12 deletions third_party/python/requirements.in

This file was deleted.

68 changes: 0 additions & 68 deletions third_party/python/requirements.txt

This file was deleted.

0 comments on commit fbee846

Please sign in to comment.