servo: Merge #20227 - Fix mach build for Servo in Firefox tree (from upsuper:in-firefox-build); r=jdm

Running `mach build` in servo directory in Firefox tree currently doesn't work due to several errors when importing modules.

First error:
```text
Traceback (most recent call last):
  File "mach", line 93, in <module>
    main(sys.argv)
  File "mach", line 23, in main
    mach = mach_bootstrap.bootstrap(topdir)
  File "servo/python/mach_bootstrap.py", line 280, in bootstrap
    mach.load_commands_from_file(os.path.join(topdir, path))
  File "servo/python/_virtualenv/Lib/site-packages/mach/main.py", line 265, in load_commands_from_file
    imp.load_source(module_name, path)
  File "servo/python/servo/testing_commands.py", line 42, in <module>
    from update import updatecommandline
  File "servo/../testing/web-platform/update/__init__.py", line 17, in <module>
    from wptrunner.update import setup_logging, WPTUpdate
  File "servo/../testing/web-platform/tests/tools/wptrunner/wptrunner/update/__init__.py", line 8, in <module>
    from update import WPTUpdate
  File "servo/../testing/web-platform/tests/tools/wptrunner/wptrunner/update/update.py", line 8, in <module>
    from .. import environment as env
  File "servo/../testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py", line 12, in <module>
    from wptserve.handlers import StringHandler
ImportError: No module named wptserve.handlers
```

Second error:
```text
Traceback (most recent call last):
  File "mach", line 93, in <module>
    main(sys.argv)
  File "mach", line 23, in main
    mach = mach_bootstrap.bootstrap(topdir)
  File "servo/python/mach_bootstrap.py", line 291, in bootstrap
    mach.load_commands_from_file(os.path.join(topdir, path))
  File "servo/python/_virtualenv/Lib/site-packages/mach/main.py", line 265, in load_commands_from_file
    imp.load_source(module_name, path)
  File "servo/python/servo/testing_commands.py", line 43, in <module>
    from servo_tidy import tidy
  File "servo/python/tidy/servo_tidy/tidy.py", line 34, in <module>
    from wptmanifest import parser, node
ImportError: No module named wptmanifest
```

The two commits fix these two errors respectively.

Source-Repo: https://github.com/servo/servo
Source-Revision: 4e2f8ec8e162fe707240eff223ec225790bf29fd
This commit is contained in:
Xidorn Quan
2018-03-07 09:19:25 -05:00
parent 36cb8e0a60
commit 6a2211c267
2 changed files with 26 additions and 9 deletions

View File

@@ -131,7 +131,7 @@ def wpt_path(is_firefox, topdir, *paths):
return os.path.join(topdir, rel, *paths)
def wpt_harness_path(is_firefox, topdir, *paths):
def wptrunner_path(is_firefox, topdir, *paths):
wpt_root = wpt_path(is_firefox, topdir)
if is_firefox:
rel = os.path.join(wpt_root, "tests", "tools", "wptrunner")
@@ -141,6 +141,16 @@ def wpt_harness_path(is_firefox, topdir, *paths):
return os.path.join(topdir, rel, *paths)
def wptserve_path(is_firefox, topdir, *paths):
wpt_root = wpt_path(is_firefox, topdir)
if is_firefox:
rel = os.path.join(wpt_root, "tests", "tools", "wptserve")
else:
rel = os.path.join(wpt_root, "web-platform-tests", "tools", "wptserve")
return os.path.join(topdir, rel, *paths)
def _activate_virtualenv(topdir, is_firefox):
virtualenv_path = os.path.join(topdir, "python", "_virtualenv")
check_exec_path = lambda path: path.startswith(virtualenv_path)
@@ -175,9 +185,9 @@ def _activate_virtualenv(topdir, is_firefox):
# and it will check for conflicts.
requirements_paths = [
os.path.join("python", "requirements.txt"),
wpt_harness_path(is_firefox, topdir, "requirements.txt",),
wpt_harness_path(is_firefox, topdir, "requirements_firefox.txt"),
wpt_harness_path(is_firefox, topdir, "requirements_servo.txt"),
wptrunner_path(is_firefox, topdir, "requirements.txt",),
wptrunner_path(is_firefox, topdir, "requirements_firefox.txt"),
wptrunner_path(is_firefox, topdir, "requirements_servo.txt"),
]
if need_pip_upgrade:
@@ -267,7 +277,8 @@ def bootstrap(topdir):
sys.path[0:0] = [os.path.join(topdir, path) for path in SEARCH_PATHS]
sys.path[0:0] = [wpt_path(is_firefox, topdir),
wpt_harness_path(is_firefox, topdir)]
wptrunner_path(is_firefox, topdir),
wptserve_path(is_firefox, topdir)]
import mach.main
mach = mach.main.Mach(os.getcwd())