author | Dorel Luca <dluca@mozilla.com> |
Thu, 10 May 2018 23:54:38 +0300 | |
changeset 417801 | bca28818826ba017ad63fc50a1ce2783b0c17d0a |
parent 417800 | 4defb0651db031c090f6805ccccf143753c81c57 |
child 417802 | b869cf66d81a7018cfc5e984ec941dd9e6876ea0 |
push id | 33980 |
push user | ebalazs@mozilla.com |
push date | Fri, 11 May 2018 09:35:12 +0000 |
treeherder | mozilla-central@8e9a4a323f0c [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1460402 |
milestone | 62.0a1 |
backs out | 5b40f3f18f42e292d68bad895bc08bad184e847c 17526c61b99579f9a1ae63f5234f82fba02e2771 e1caff997e5a61de20d04af799caa120f41ecb2f 06ceda084d694d1687a669995d457ebd6fd0b08e |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
build/sparse-profiles/docker-image | file | annotate | diff | comparison | revisions | |
python/mozlint/mozlint/util/__init__.py | file | annotate | diff | comparison | revisions | |
python/mozlint/mozlint/util/pip.py | file | annotate | diff | comparison | revisions | |
taskcluster/docker/lint/system-setup.sh | file | annotate | diff | comparison | revisions | |
tools/lint/python/__init__.py | file | annotate | diff | comparison | revisions | |
tools/lint/python/flake8.py | file | annotate | diff | comparison | revisions | |
tools/lint/spell/__init__.py | file | annotate | diff | comparison | revisions | |
tools/lint/spell/codespell_requirements.txt | file | annotate | diff | comparison | revisions |
--- a/build/sparse-profiles/docker-image +++ b/build/sparse-profiles/docker-image @@ -2,13 +2,13 @@ [include] path:taskcluster/ # Result from `grep -hr %include taskcluster/docker | grep -v " taskcluster/" | sort -u` path:python/mozbuild/mozbuild/action/tooltool.py path:testing/config/tooltool-manifests/linux64/releng.manifest path:testing/mozharness/external_tools/robustcheckout.py -path:tools/lint/spell/codespell_requirements.txt path:tools/lint/eslint/eslint-plugin-mozilla/manifest.tt path:tools/lint/eslint/manifest.tt path:tools/lint/python/flake8_requirements.txt path:tools/lint/tox/tox_requirements.txt +
deleted file mode 100644 --- a/python/mozlint/mozlint/util/pip.py +++ /dev/null @@ -1,34 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -from __future__ import print_function -from __future__ import absolute_import - -import subprocess - - -def _run_pip(*args): - """ - Helper function that runs pip with subprocess - """ - try: - subprocess.check_output(['pip'] + list(args), - stderr=subprocess.STDOUT) - return True - except subprocess.CalledProcessError as e: - print(e.output) - return False - - -def reinstall_program(REQ_PATH): - """ - Try to install flake8 at the target version, returns True on success - otherwise prints the otuput of the pip command and returns False - """ - if _run_pip('install', '-U', - '--require-hashes', '-r', - REQ_PATH): - return True - - return False
--- a/taskcluster/docker/lint/system-setup.sh +++ b/taskcluster/docker/lint/system-setup.sh @@ -5,16 +5,17 @@ export DEBIAN_FRONTEND=noninteractive set -ve test "$(whoami)" == 'root' mkdir -p /setup cd /setup apt_packages=() +apt_packages+=('codespell') apt_packages+=('curl') apt_packages+=('locales') apt_packages+=('git') apt_packages+=('python') apt_packages+=('python-pip') apt_packages+=('python3') apt_packages+=('python3-pip') apt_packages+=('shellcheck') @@ -83,24 +84,16 @@ mv fzf /usr/local/bin # Flake8 Setup ### cd /setup pip install --require-hashes -r /tmp/flake8_requirements.txt ### -# codespell Setup -### - -cd /setup - -pip install --require-hashes -r /tmp/codespell_requirements.txt - -### # tox Setup ### cd /setup pip install --require-hashes -r /tmp/tox_requirements.txt cd /
--- a/tools/lint/python/__init__.py +++ b/tools/lint/python/__init__.py @@ -1,22 +1,22 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import json import os import signal +import subprocess from collections import defaultdict import which from mozprocess import ProcessHandlerMixin from mozlint import result -from mozlint.util import pip from mozlint.pathutils import get_ancestors_by_name here = os.path.abspath(os.path.dirname(__file__)) FLAKE8_REQUIREMENTS_PATH = os.path.join(here, 'flake8_requirements.txt') FLAKE8_NOT_FOUND = """ Could not find flake8! Install flake8 and try again. @@ -100,28 +100,54 @@ def get_flake8_binary(): return binary try: return which.which('flake8') except which.WhichError: return None +def _run_pip(*args): + """ + Helper function that runs pip with subprocess + """ + try: + subprocess.check_output(['pip'] + list(args), + stderr=subprocess.STDOUT) + return True + except subprocess.CalledProcessError as e: + print(e.output) + return False + + +def reinstall_flake8(): + """ + Try to install flake8 at the target version, returns True on success + otherwise prints the otuput of the pip command and returns False + """ + if _run_pip('install', '-U', + '--require-hashes', '-r', + FLAKE8_REQUIREMENTS_PATH): + return True + + return False + + def run_process(config, cmd): proc = Flake8Process(config, cmd) proc.run() try: proc.wait() except KeyboardInterrupt: proc.kill() def lint(paths, config, **lintargs): - if not pip.reinstall_program(FLAKE8_REQUIREMENTS_PATH): + if not reinstall_flake8(): print(FLAKE8_INSTALL_ERROR) return 1 binary = get_flake8_binary() cmdargs = [ binary, '--format', '{"path":"%(path)s","lineno":%(row)s,'
--- a/tools/lint/python/flake8.py +++ b/tools/lint/python/flake8.py @@ -1,23 +1,23 @@ # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. import json import os import platform import signal +import subprocess import sys from collections import defaultdict from mozprocess import ProcessHandlerMixin from mozlint import result -from mozlint.util import pip from mozlint.pathutils import get_ancestors_by_name here = os.path.abspath(os.path.dirname(__file__)) FLAKE8_REQUIREMENTS_PATH = os.path.join(here, 'flake8_requirements.txt') FLAKE8_NOT_FOUND = """ Could not find flake8! Install flake8 and try again. @@ -93,28 +93,54 @@ class Flake8Process(ProcessHandlerMixin) def run(self, *args, **kwargs): # flake8 seems to handle SIGINT poorly. Handle it here instead # so we can kill the process without a cryptic traceback. orig = signal.signal(signal.SIGINT, signal.SIG_IGN) ProcessHandlerMixin.run(self, *args, **kwargs) signal.signal(signal.SIGINT, orig) +def _run_pip(*args): + """ + Helper function that runs pip with subprocess + """ + try: + subprocess.check_output([os.path.join(bindir, 'pip')] + list(args), + stderr=subprocess.STDOUT) + return True + except subprocess.CalledProcessError as e: + print(e.output) + return False + + +def reinstall_flake8(): + """ + Try to install flake8 at the target version, returns True on success + otherwise prints the otuput of the pip command and returns False + """ + if _run_pip('install', '-U', + '--require-hashes', '-r', + FLAKE8_REQUIREMENTS_PATH): + return True + + return False + + def run_process(config, cmd): proc = Flake8Process(config, cmd) proc.run() try: proc.wait() except KeyboardInterrupt: proc.kill() return 1 def setup(root): - if not pip.reinstall_program(FLAKE8_REQUIREMENTS_PATH): + if not reinstall_flake8(): print(FLAKE8_INSTALL_ERROR) return 1 def lint(paths, config, **lintargs): # TODO don't store results in a global global results results = []
--- a/tools/lint/spell/__init__.py +++ b/tools/lint/spell/__init__.py @@ -11,39 +11,32 @@ import re # Py3/Py2 compatibility. try: from json.decoder import JSONDecodeError except ImportError: JSONDecodeError = ValueError from mozlint import result -from mozlint.util import pip from mozprocess import ProcessHandlerMixin -here = os.path.abspath(os.path.dirname(__file__)) -CODESPELL_REQUIREMENTS_PATH = os.path.join(here, 'codespell_requirements.txt') CODESPELL_NOT_FOUND = """ -Could not find codespell! Install codespell and try again. - - $ pip install -U --require-hashes -r {} -""".strip().format(CODESPELL_REQUIREMENTS_PATH) - +Unable to locate codespell, please ensure it is installed and in +your PATH or set the CODESPELL environment variable. -CODESPELL_INSTALL_ERROR = """ -Unable to install correct version of codespell -Try to install it manually with: - $ pip install -U --require-hashes -r {} -""".strip().format(CODESPELL_REQUIREMENTS_PATH) +https://github.com/lucasdemarchi/codespell or your system's package manager. +""".strip() results = [] CODESPELL_FORMAT_REGEX = re.compile(r'(.*):(.*): (.*) ==> (.*)$') +here = os.path.abspath(os.path.dirname(__file__)) + class CodespellProcess(ProcessHandlerMixin): def __init__(self, config, *args, **kwargs): self.config = config kwargs['processOutputLine'] = [self.process_line] ProcessHandlerMixin.__init__(self, *args, **kwargs) def process_line(self, line): @@ -93,20 +86,16 @@ def get_codespell_binary(): try: return which.which('codespell') except which.WhichError: return None def lint(paths, config, fix=None, **lintargs): - if not pip.reinstall_program(CODESPELL_REQUIREMENTS_PATH): - print(CODESPELL_INSTALL_ERROR) - return 1 - binary = get_codespell_binary() if not binary: print(CODESPELL_NOT_FOUND) if 'MOZ_AUTOMATION' in os.environ: return 1 return []