Bug 1356101 - Derive the mach_bootstrap search path from build/virtualenv_packages.txt. r=gps

Most entries in virtualenv_packages.txt that are .pth or packages.txt
are currently in SEARCH_PATHS in mach_bootstrap. The ones that are
missing would make sense in SEARCH_PATHS. None of non-.pth or
packages.txt entries, however, are in SEARCH_PATHS and don't make sense
there.

On the other hand, virtualenv_packages.txt misses a lot of things that
are in SEARCH_PATHS, all of which should be there. One exception:
xpcom/idl-parser, which causes problems due to the xpidl package
containing an xpidl module, which causes problems with the in-tree
scripts using it. Plus, it needs a cache directory, which is messy, so
it's preferable to keep it away from the virtualenv. It turns out it was
added to mach_bootstrap.py in bug 893976 for a command that was since
then removed (bug 1244736), so we can get away with removing it.

So instead of keeping those two separate lists out of sync, we replace
the SEARCH_PATHS list from mach_bootstrap with one that is derived at
runtime from the contents of virtualenv_packages.txt.

And since a .pth can't fail to install in the virtualenv, it makes no
sense to have psutil.pth defined as optional, which allows it to end up
in the mach_bootstrap search path automatically.

Finally, because we do have overlapping module names in the tree (e.g.
runtests), and mach_bootstrap's SEARCH_PATHS had a guaranteed order,
we change the order of the virtualenv_packages.txt file to match what
used to be in mach_bootstrap, and make all the pth entries use the same
file name so that the order is more guaranteed in the virtualenv too.

--HG--
extra : rebase_source : 5bd09f2f984d6f78a76b38e768d8a67806af5954
This commit is contained in:
Mike Hommey 2017-04-14 08:19:08 +09:00
parent d9e412fe4d
commit 1170646315
2 changed files with 67 additions and 105 deletions

View file

@ -32,74 +32,6 @@ Press ENTER/RETURN to continue or CTRL+c to abort.
'''.lstrip() '''.lstrip()
# TODO Bug 794506 Integrate with the in-tree virtualenv configuration.
SEARCH_PATHS = [
'python/mach',
'python/mozboot',
'python/mozbuild',
'python/mozlint',
'python/mozversioncontrol',
'python/blessings',
'python/compare-locales',
'python/configobj',
'python/dlmanager',
'python/futures',
'python/jsmin',
'python/psutil',
'python/pylru',
'python/which',
'python/pystache',
'python/pyyaml/lib',
'python/requests',
'python/slugid',
'python/py',
'python/pytest',
'python/pytoml',
'python/redo',
'python/voluptuous',
'build',
'build/pymake',
'config',
'dom/bindings',
'dom/bindings/parser',
'dom/media/test/external',
'layout/tools/reftest',
'other-licenses/ply',
'taskcluster',
'testing',
'testing/firefox-ui/harness',
'testing/marionette/client',
'testing/marionette/harness',
'testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py',
'testing/marionette/puppeteer/firefox',
'testing/mozbase/mozcrash',
'testing/mozbase/mozdebug',
'testing/mozbase/mozdevice',
'testing/mozbase/mozfile',
'testing/mozbase/mozhttpd',
'testing/mozbase/mozinfo',
'testing/mozbase/mozinstall',
'testing/mozbase/mozleak',
'testing/mozbase/mozlog',
'testing/mozbase/moznetwork',
'testing/mozbase/mozprocess',
'testing/mozbase/mozprofile',
'testing/mozbase/mozrunner',
'testing/mozbase/mozsystemmonitor',
'testing/mozbase/mozscreenshot',
'testing/mozbase/moztest',
'testing/mozbase/mozversion',
'testing/mozbase/manifestparser',
'testing/taskcluster',
'testing/tools/autotry',
'testing/web-platform',
'testing/web-platform/harness',
'testing/web-platform/tests/tools/wptserve',
'testing/web-platform/tests/tools/six',
'testing/xpcshell',
'xpcom/idl-parser',
]
# Individual files providing mach commands. # Individual files providing mach commands.
MACH_MODULES = [ MACH_MODULES = [
'addon-sdk/mach_commands.py', 'addon-sdk/mach_commands.py',
@ -184,6 +116,21 @@ CATEGORIES = {
TELEMETRY_SUBMISSION_FREQUENCY = 10 TELEMETRY_SUBMISSION_FREQUENCY = 10
def search_path(mozilla_dir, packages_txt):
with open(os.path.join(mozilla_dir, packages_txt)) as f:
packages = [line.rstrip().split(':') for line in f]
for package in packages:
if package[0] == 'packages.txt':
assert len(package) == 2
for p in search_path(mozilla_dir, package[1]):
yield os.path.join(mozilla_dir, p)
if package[0].endswith('.pth'):
assert len(package) == 2
yield os.path.join(mozilla_dir, package[1])
def bootstrap(topsrcdir, mozilla_dir=None): def bootstrap(topsrcdir, mozilla_dir=None):
if mozilla_dir is None: if mozilla_dir is None:
mozilla_dir = topsrcdir mozilla_dir = topsrcdir
@ -204,7 +151,9 @@ def bootstrap(topsrcdir, mozilla_dir=None):
# case. For default behavior, we educate users and give them an opportunity # case. For default behavior, we educate users and give them an opportunity
# to react. We always exit after creating the directory because users don't # to react. We always exit after creating the directory because users don't
# like surprises. # like surprises.
sys.path[0:0] = [os.path.join(mozilla_dir, path) for path in SEARCH_PATHS] sys.path[0:0] = [os.path.join(mozilla_dir, path)
for path in search_path(mozilla_dir,
'build/virtualenv_packages.txt')]
import mach.main import mach.main
from mozboot.util import get_state_dir from mozboot.util import get_state_dir

View file

@ -1,43 +1,56 @@
marionette_driver.pth:testing/marionette/client mozilla.pth:python/mach
marionette_harness.pth:testing/marionette/harness mozilla.pth:python/mozboot
browsermobproxy.pth:testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py mozilla.pth:python/mozbuild
six.pth:testing/web-platform/tests/tools/six mozilla.pth:python/mozlint
wptserve.pth:testing/web-platform/tests/tools/wptserve mozilla.pth:python/mozversioncontrol
blessings.pth:python/blessings mozilla.pth:python/blessings
configobj.pth:python/configobj mozilla.pth:python/compare-locales
jsmin.pth:python/jsmin mozilla.pth:python/configobj
mach.pth:python/mach mozilla.pth:python/dlmanager
mozbuild.pth:python/mozbuild mozilla.pth:python/futures
mozversioncontrol.pth:python/mozversioncontrol mozilla.pth:python/jsmin
mozlint.pth:python/mozlint
pymake.pth:build/pymake
optional:setup.py:python/psutil:build_ext:--inplace optional:setup.py:python/psutil:build_ext:--inplace
optional:psutil.pth:python/psutil mozilla.pth:python/psutil
which.pth:python/which mozilla.pth:python/pylru
ply.pth:other-licenses/ply/ mozilla.pth:python/which
mock.pth:python/mock-1.0.0 mozilla.pth:python/pystache
py.pth:python/py mozilla.pth:python/pyyaml/lib
pytest.pth:python/pytest mozilla.pth:python/requests
mozilla.pth:python/slugid
mozilla.pth:python/py
mozilla.pth:python/pytest
mozilla.pth:python/pytoml
mozilla.pth:python/redo
mozilla.pth:python/voluptuous
mozilla.pth:build mozilla.pth:build
objdir:build
mozilla.pth:build/pymake
mozilla.pth:config mozilla.pth:config
mozilla.pth:xpcom/typelib/xpt/tools
mozilla.pth:dom/bindings mozilla.pth:dom/bindings
mozilla.pth:dom/bindings/parser mozilla.pth:dom/bindings/parser
mozilla.pth:dom/media/test/external
mozilla.pth:layout/tools/reftest mozilla.pth:layout/tools/reftest
moztreedocs.pth:tools/docs mozilla.pth:other-licenses/ply/
mozilla.pth:taskcluster
mozilla.pth:testing
mozilla.pth:testing/firefox-ui/harness
mozilla.pth:testing/marionette/client
mozilla.pth:testing/marionette/harness
mozilla.pth:testing/marionette/harness/marionette_harness/runner/mixins/browsermob-proxy-py
mozilla.pth:testing/marionette/puppeteer/firefox
packages.txt:testing/mozbase/packages.txt packages.txt:testing/mozbase/packages.txt
objdir:build mozilla.pth:testing/taskcluster
gyp.pth:media/webrtc/trunk/tools/gyp/pylib mozilla.pth:testing/tools/autotry
pyasn1.pth:python/pyasn1 mozilla.pth:testing/web-platform
pyasn1_modules.pth:python/pyasn1-modules mozilla.pth:testing/web-platform/harness
redo.pth:python/redo mozilla.pth:testing/web-platform/tests/tools/wptserve
requests.pth:python/requests mozilla.pth:testing/web-platform/tests/tools/six
rsa.pth:python/rsa mozilla.pth:testing/xpcshell
futures.pth:python/futures mozilla.pth:python/mock-1.0.0
ecc.pth:python/PyECC mozilla.pth:xpcom/typelib/xpt/tools
xpcshell.pth:testing/xpcshell mozilla.pth:tools/docs
pyyaml.pth:python/pyyaml/lib mozilla.pth:media/webrtc/trunk/tools/gyp/pylib
pytoml.pth:python/pytoml mozilla.pth:python/pyasn1
pylru.pth:python/pylru mozilla.pth:python/pyasn1-modules
taskcluster.pth:taskcluster mozilla.pth:python/rsa
dlmanager.pth:python/dlmanager mozilla.pth:python/PyECC