Bug 1730712: Use consistent Python version throughout configure r=andi

It's possible for the `PYTHON3` config to point to a different Python
than that that is executing the configure scripts themselves.

This flexibility was needed for the Python 2->3 migration, but now that
it's complete, we can remove the extra configuration and just lean on
the Python interpreter used to run configure.

Differential Revision: https://phabricator.services.mozilla.com/D129863
This commit is contained in:
Mitchell Hentges
2021-11-04 21:41:33 +00:00
parent 5403fedaff
commit 75f9d0ea8e
3 changed files with 33 additions and 159 deletions

View File

@@ -22,6 +22,7 @@ sys.path.insert(0, os.path.join(base_dir, "python", "mozbuild"))
sys.path.insert(0, os.path.join(base_dir, "third_party", "python", "packaging"))
sys.path.insert(0, os.path.join(base_dir, "third_party", "python", "pyparsing"))
sys.path.insert(0, os.path.join(base_dir, "third_party", "python", "six"))
from mach.virtualenv import VirtualenvManager
from mozbuild.configure import (
ConfigureSandbox,
TRACE,
@@ -34,6 +35,7 @@ import six
def main(argv):
_activate_build_virtualenv()
config = {}
if "OLD_CONFIGURE" not in os.environ:
@@ -223,5 +225,26 @@ def config_status(config, execute=True):
return 0
def _activate_build_virtualenv():
version = ".".join(str(i) for i in sys.version_info[0:3])
print(f"Using Python {version} from {sys.executable}")
topobjdir = os.path.realpath(".")
topsrcdir = os.path.realpath(os.path.dirname(__file__))
if topobjdir.endswith("/js/src"):
topobjdir = topobjdir[:-7]
build_venv = VirtualenvManager(
topsrcdir,
os.path.join(topobjdir, "_virtualenvs"),
"build",
)
if not build_venv.up_to_date():
print("Creating Python 3 virtualenv")
build_venv.build()
build_venv.activate()
if __name__ == "__main__":
sys.exit(main(sys.argv))