aboutsummaryrefslogtreecommitdiff
path: root/pw_presubmit
diff options
context:
space:
mode:
authorRob Mohr <mohrr@google.com>2021-06-21 10:32:35 -0700
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2021-06-21 21:52:12 +0000
commit10806d36e974257848ba1dbecca2b1964bcd7490 (patch)
tree4461c519266d5723ba34fc82b380e927ac3f6e3e /pw_presubmit
parent916bcc1b22bc77746d8b515e1894cc2437af996b (diff)
downloadpigweed-10806d36e974257848ba1dbecca2b1964bcd7490.tar.gz
pw_presubmit: Remove environment.py
Change-Id: I5d09d3af45ab3b6f9f624176ffbdf4e36e626724 Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/50220 Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com> Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com> Reviewed-by: Alexei Frolov <frolv@google.com>
Diffstat (limited to 'pw_presubmit')
-rw-r--r--pw_presubmit/py/BUILD.gn1
-rw-r--r--pw_presubmit/py/pw_presubmit/environment.py91
2 files changed, 0 insertions, 92 deletions
diff --git a/pw_presubmit/py/BUILD.gn b/pw_presubmit/py/BUILD.gn
index f49fbebe0..8c612c9f1 100644
--- a/pw_presubmit/py/BUILD.gn
+++ b/pw_presubmit/py/BUILD.gn
@@ -22,7 +22,6 @@ pw_python_package("py") {
"pw_presubmit/__init__.py",
"pw_presubmit/build.py",
"pw_presubmit/cli.py",
- "pw_presubmit/environment.py",
"pw_presubmit/format_code.py",
"pw_presubmit/git_repo.py",
"pw_presubmit/inclusive_language.py",
diff --git a/pw_presubmit/py/pw_presubmit/environment.py b/pw_presubmit/py/pw_presubmit/environment.py
deleted file mode 100644
index 7af5d52ca..000000000
--- a/pw_presubmit/py/pw_presubmit/environment.py
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright 2020 The Pigweed Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License"); you may not
-# use this file except in compliance with the License. You may obtain a copy of
-# the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-# License for the specific language governing permissions and limitations under
-# the License.
-"""Functions for initializing CIPD and the Pigweed virtualenv."""
-
-import logging
-import os
-from pathlib import Path
-import sys
-from typing import Iterable, Union
-
-from pw_presubmit import call
-
-_LOG = logging.getLogger(__name__)
-
-
-def init_cipd(
- pigweed_root: Path,
- output_directory: Path,
- package_files: Iterable[Path] = ()) -> None:
- """Runs CIPD."""
-
- # TODO(mohrr): invoke by importing rather than by subprocess.
-
- cmd = [
- sys.executable,
- pigweed_root.joinpath('pw_env_setup', 'py', 'pw_env_setup',
- 'cipd_setup', 'update.py'),
- '--install-dir', output_directory,
- ] # yapf: disable
-
- final_package_files = list(
- pigweed_root.joinpath('pw_env_setup', 'py', 'pw_env_setup',
- 'cipd_setup').glob('*.json'))
- final_package_files.extend(package_files)
-
- for package_file in final_package_files:
- cmd.extend(('--package-file', package_file))
-
- call(*cmd)
-
- paths = [output_directory, output_directory.joinpath('bin')]
- for base in output_directory.glob('*'):
- paths.append(base)
- paths.append(base.joinpath('bin'))
-
- paths.append(Path(os.environ['PATH']))
-
- os.environ['PATH'] = os.pathsep.join(str(x) for x in paths)
- _LOG.debug('PATH %s', os.environ['PATH'])
-
-
-def init_virtualenv(
- pigweed_root: Path,
- output_directory: Path,
- requirements: Iterable[Union[Path, str]] = (),
- gn_targets: Iterable[str] = (),
-) -> None:
- """Sets up a virtualenv, assumes recent Python 3 is already installed."""
- virtualenv_source = pigweed_root.joinpath('pw_env_setup', 'py',
- 'pw_env_setup',
- 'virtualenv_setup')
-
- # Need to set VIRTUAL_ENV before invoking GN because the GN targets install
- # directly to the current virtual env.
- os.environ['VIRTUAL_ENV'] = str(output_directory)
- os.environ['PATH'] = os.pathsep.join((
- str(output_directory.joinpath('bin')),
- os.environ['PATH'],
- ))
-
- if not gn_targets:
- gn_targets = (f'{os.environ["PW_ROOT"]}#:python.install', )
-
- call(
- 'python3',
- virtualenv_source,
- f'--venv_path={output_directory}',
- *(f'--requirements={x}' for x in requirements),
- *(f'--gn-target={t}' for t in gn_targets),
- )