- Notifications
You must be signed in to change notification settings - Fork 384
/
Copy pathenv_setup.py
55 lines (45 loc) · 1.91 KB
/
env_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------
"""Prepare development environment
"""
importsys
importargparse
fromsubprocessimportcheck_call, CalledProcessError
defpip_command(command, error_ok=False):
try:
print("Executing: "+command)
check_call([sys.executable, "-m", "pip"] +command.split())
print()
exceptCalledProcessErroraserr:
print(err)
ifnoterror_ok:
sys.exit(1)
if__name__=="__main__":
parser=argparse.ArgumentParser("Prepare environment")
parser.add_argument(
"--no_dev",
dest="dev_mode",
action="store_false",
help="Setup environment for running and testing ONLY",
)
args=parser.parse_args()
# Make sure pip is on the latest version
pip_command("install --upgrade pip")
# Install package
# Use an eager upgrade strategy to make sure we have all the latest dependencies.
# This way we will be running into any dependency-related bugs before customers do.
pip_command("install -U --upgrade-strategy eager -e .")
# Because we're just installing development environment libraries beyond this point, no need to
# be eager in upgrading, as these dependencies are not customer facing.
# Install testing environment dependencies
pip_command("install -U -r requirements_test.txt")
pip_command("install -e dev_utils")
ifargs.dev_mode:
# Install local development environment dependencies.
# These are not compatible on all platforms.
pip_command("install -U -r requirements_dev.txt")
print("Installing pre-commit")
check_call("pre-commit install", shell=True)