Skip to content

Commit

Permalink
Bug 1666347 - Delete assorted dead code after removal of vendored `ps…
Browse files Browse the repository at this point in the history
…util` r=firefox-build-system-reviewers,rstewart

Most of the deletions here come from bug 1481612, the `--with-windows-wheel` option to `mach vendor python`, which according to that commit message "is very single-purpose: it's intended to let us vendor an unpacked
wheel for psutil on Windows". Since vendoring `psutil` is something we're no longer doing, we can safely just delete that added code.

Differential Revision: https://phabricator.services.mozilla.com/D90919
  • Loading branch information
Ricky Stewart committed Nov 27, 2020
1 parent 0831863 commit d2ecfce
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 69 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,6 @@ parser/html/java/translator.jar
# Local Gradle configuration properties.
/local.properties

# Python virtualenv artifacts.
third_party/python/psutil/**/*.so
third_party/python/psutil/**/*.pyd
third_party/python/psutil/build/
third_party/python/psutil/tmp/

# Ignore chrome.manifest files from the devtools loader
devtools/client/chrome.manifest
devtools/shared/chrome.manifest
Expand Down
6 changes: 0 additions & 6 deletions .hgignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ _OPT\.OBJ/
# Local Gradle configuration properties.
^local.properties$

# Python stuff installed at build time.
^third_party/python/psutil/.*\.so
^third_party/python/psutil/.*\.pyd
^third_party/python/psutil/build/
^third_party/python/psutil/tmp/

# Git repositories
.git/

Expand Down
11 changes: 10 additions & 1 deletion build/mach_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import math
import os
import platform
import shutil
import subprocess
import sys
import uuid
Expand Down Expand Up @@ -197,6 +198,13 @@ def bootstrap(topsrcdir, mozilla_dir=None):
print("You are running Python", platform.python_version())
sys.exit(1)

# This directory was deleted in bug 1666345, but there may be some ignored
# files here. We can safely just delete it for the user so they don't have
# to clean the repo themselves.
deleted_dir = os.path.join(topsrcdir, "third_party", "python", "psutil")
if os.path.exists(deleted_dir):
shutil.rmtree(deleted_dir)

# Global build system and mach state is stored in a central directory. By
# default, this is ~/.mozbuild. However, it can be defined via an
# environment variable. We detect first run (by lack of this directory
Expand Down Expand Up @@ -503,7 +511,8 @@ def _finalize_telemetry_glean(telemetry, is_bootstrap, success):

has_psutil, logical_cores, physical_cores, memory_total = get_psutil_stats()
if has_psutil:
# psutil may not be available if a successful build hasn't occurred yet.
# psutil may not be available (we allow `mach create-mach-environment`
# to fail to install it).
system_metrics.logical_cores.add(logical_cores)
system_metrics.physical_cores.add(physical_cores)
if memory_total is not None:
Expand Down
6 changes: 0 additions & 6 deletions python/mozbuild/mozbuild/vendor/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ def vendor_rust(self, **kwargs):
description="Vendor Python packages from pypi.org into third_party/python. "
"Some extra files like docs and tests will automatically be excluded.",
)
@CommandArgument(
"--with-windows-wheel",
action="store_true",
help="Vendor a wheel for Windows along with the source package",
default=False,
)
@CommandArgument(
"--keep-extra-files",
action="store_true",
Expand Down
59 changes: 9 additions & 50 deletions python/mozbuild/mozbuild/vendor/vendor_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@


class VendorPython(MozbuildObject):
def vendor(self, packages=None, with_windows_wheel=False, keep_extra_files=False):
def vendor(self, packages=None, keep_extra_files=False):
self.populate_logger()
self.log_manager.enable_unstructured()

vendor_dir = mozpath.join(self.topsrcdir, os.path.join("third_party", "python"))

packages = packages or []
if with_windows_wheel and len(packages) != 1:
raise Exception(
"--with-windows-wheel is only supported for a single package!"
)

self.activate_virtualenv()
pip_compile = os.path.join(self.virtualenv_manager.bin_path, "pip-compile")
Expand Down Expand Up @@ -75,30 +71,6 @@ def vendor(self, packages=None, with_windows_wheel=False, keep_extra_files=False
"--disable-pip-version-check",
]
)
if with_windows_wheel:
# This is hardcoded to CPython 2.7 for win64, which is good
# enough for what we need currently. If we need psutil for Python 3
# in the future that could be added here as well.
self.virtualenv_manager._run_pip(
[
"download",
"--dest",
tmp,
"--no-deps",
"--only-binary",
":all:",
"--platform",
"win_amd64",
"--implementation",
"cp",
"--python-version",
"27",
"--abi",
"none",
"--disable-pip-version-check",
packages[0],
]
)
self._extract(tmp, vendor_dir, keep_extra_files)

shutil.copyfile(tmpspec_absolute, spec)
Expand Down Expand Up @@ -147,27 +119,14 @@ def _extract(self, src, dest, keep_extra_files=False):
finder = FileFinder(src)
for path, _ in finder.find("*"):
base, ext = os.path.splitext(path)
if ext == ".whl":
# Wheels would extract into a directory with the name of the package, but
# we want the platform signifiers, minus the version number.
# Wheel filenames look like:
# {distribution}-{version}(-{build tag})?-{python tag}-{abi tag}-{platform tag}
bits = base.split("-")

# Remove the version number.
bits.pop(1)
target = os.path.join(dest, "-".join(bits))
mozfile.remove(target) # remove existing version of vendored package
os.mkdir(target)
mozfile.extract(os.path.join(finder.base, path), target, ignore=ignore)
else:
# packages extract into package-version directory name and we strip the version
tld = mozfile.extract(
os.path.join(finder.base, path), dest, ignore=ignore
)[0]
target = os.path.join(dest, tld.rpartition("-")[0])
mozfile.remove(target) # remove existing version of vendored package
mozfile.move(tld, target)
# packages extract into package-version directory name and we strip the version
tld = mozfile.extract(os.path.join(finder.base, path), dest, ignore=ignore)[
0
]
target = os.path.join(dest, tld.rpartition("-")[0])
mozfile.remove(target) # remove existing version of vendored package
mozfile.move(tld, target)

# If any files inside the vendored package were symlinks, turn them into normal files
# because hg.mozilla.org forbids symlinks in the repository.
link_finder = FileFinder(target)
Expand Down

0 comments on commit d2ecfce

Please sign in to comment.