aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorbors-servo <infra@servo.org>2023-05-21 06:24:16 +0200
committerGitHub <noreply@github.com>2023-05-21 06:24:16 +0200
commitbf0c80f75ea23b8abfccb67f420d94fc02c51cae (patch)
tree6c92e910809fac33d2be33f04367801b8d7f3b83 /python
parent1bb713521bc2f92526429622fa2da13d10f65200 (diff)
parent3875debfbfd5b335285a70780aa1aa3a775bb02a (diff)
downloadservo-bf0c80f75ea23b8abfccb67f420d94fc02c51cae.tar.gz
servo-bf0c80f75ea23b8abfccb67f420d94fc02c51cae.zip
Auto merge of #29762 - mrobinson:remove-unused-python-code, r=jdm
Remove some unused python code This change removes: - The custom `--dry-run` support for `cargo-update`. The real cargo command now has `--dry-run` support and this code was broken for Python 3. - The Python 2 version of TemporaryDirectory. This is no longer needed as we require Python 3. <!-- Please describe your changes on the following line: --> --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes do not require tests because they do not change behavior. <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
Diffstat (limited to 'python')
-rw-r--r--python/servo/devenv_commands.py65
-rw-r--r--python/servo/package_commands.py20
2 files changed, 9 insertions, 76 deletions
diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py
index 7d3481d1c19..4385fbb8794 100644
--- a/python/servo/devenv_commands.py
+++ b/python/servo/devenv_commands.py
@@ -10,7 +10,6 @@
from __future__ import print_function, unicode_literals
from os import path, listdir, getcwd
-import json
import signal
import subprocess
import sys
@@ -96,67 +95,19 @@ class MachCommands(CommandBase):
if not params:
params = []
- if dry_run:
- import toml
- import httplib
- import colorama
-
- cargo_file = open(path.join(self.context.topdir, "Cargo.lock"))
- content = toml.load(cargo_file)
-
- packages = {}
- outdated_packages = 0
- conn = httplib.HTTPSConnection("crates.io")
- for package in content.get("package", []):
- if "replace" in package:
- continue
- source = package.get("source", "")
- if source == r"registry+https://github.com/rust-lang/crates.io-index":
- version = package["version"]
- name = package["name"]
- if not packages.get(name, "") or packages[name] > version:
- packages[name] = package["version"]
- conn.request('GET', '/api/v1/crates/{}/versions'.format(package["name"]))
- r = conn.getresponse()
- json_content = json.load(r)
- for v in json_content.get("versions"):
- if not v.get("yanked"):
- max_version = v.get("num")
- break
-
- if version != max_version:
- outdated_packages += 1
- version_major, version_minor = (version.split("."))[:2]
- max_major, max_minor = (max_version.split("."))[:2]
-
- if version_major == max_major and version_minor == max_minor and "alpha" not in version:
- msg = "minor update"
- msg_color = "\033[93m"
- else:
- msg = "update, which may contain breaking changes"
- msg_color = "\033[91m"
-
- colorama.init()
- print("{}Outdated package `{}`, available {}\033[0m".format(msg_color, name, msg),
- "\n\tCurrent version: {}".format(version),
- "\n\t Latest version: {}".format(max_version))
- conn.close()
-
- print("\nFound {} outdated packages from crates.io".format(outdated_packages))
- elif package:
- params += ["-p", package]
- elif all_packages:
- params = []
- else:
+ if not package and not all_packages:
print("Please choose package to update with the --package (-p) ")
print("flag or update all packages with --all-packages (-a) flag")
sys.exit(1)
- if params or all_packages:
- self.ensure_bootstrapped()
+ if package:
+ params += ["-p", package]
+ if dry_run:
+ params.append("--dry-run")
- with cd(self.context.topdir):
- self.call_rustup_run(["cargo", "update"] + params, env=self.build_env())
+ self.ensure_bootstrapped()
+ with cd(self.context.topdir):
+ self.call_rustup_run(["cargo", "update"] + params, env=self.build_env())
@Command('rustc',
description='Run the Rust compiler',
diff --git a/python/servo/package_commands.py b/python/servo/package_commands.py
index 1f4e87f9830..1488eadbd3e 100644
--- a/python/servo/package_commands.py
+++ b/python/servo/package_commands.py
@@ -82,24 +82,6 @@ PACKAGES = {
}
-TemporaryDirectory = None
-if sys.version_info >= (3, 2):
- TemporaryDirectory = tempfile.TemporaryDirectory
-else:
- import contextlib
-
- # Not quite as robust as tempfile.TemporaryDirectory,
- # but good enough for most purposes
- @contextlib.contextmanager
- def TemporaryDirectory(**kwargs):
- dir_name = tempfile.mkdtemp(**kwargs)
- try:
- yield dir_name
- except Exception as e:
- shutil.rmtree(dir_name)
- raise e
-
-
def listfiles(directory):
return [f for f in os.listdir(directory)
if path.isfile(path.join(directory, f))]
@@ -683,7 +665,7 @@ class PackageCommands(CommandBase):
brew_version = timestamp.strftime('%Y.%m.%d')
- with TemporaryDirectory(prefix='homebrew-servo') as tmp_dir:
+ with tempfile.TemporaryDirectory(prefix='homebrew-servo') as tmp_dir:
def call_git(cmd, **kwargs):
subprocess.check_call(
['git', '-C', tmp_dir] + cmd,