Show More
@@ -1,74 +1,74 b'' | |||||
1 | #!/usr/bin/env python3 |
|
1 | #!/usr/bin/env python3 | |
2 | # |
|
2 | # | |
3 | # packaging.py - Mercurial packaging functionality |
|
3 | # packaging.py - Mercurial packaging functionality | |
4 | # |
|
4 | # | |
5 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> |
|
5 | # Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com> | |
6 | # |
|
6 | # | |
7 | # This software may be used and distributed according to the terms of the |
|
7 | # This software may be used and distributed according to the terms of the | |
8 | # GNU General Public License version 2 or any later version. |
|
8 | # GNU General Public License version 2 or any later version. | |
9 |
|
9 | |||
10 | import os |
|
10 | import os | |
11 | import pathlib |
|
11 | import pathlib | |
12 | import subprocess |
|
12 | import subprocess | |
13 | import sys |
|
13 | import sys | |
14 | import venv |
|
14 | import venv | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | HERE = pathlib.Path(os.path.abspath(__file__)).parent |
|
17 | HERE = pathlib.Path(os.path.abspath(__file__)).parent | |
18 | REQUIREMENTS_TXT = HERE / "requirements.txt" |
|
18 | REQUIREMENTS_TXT = HERE / "requirements.txt" | |
19 | SOURCE_DIR = HERE.parent.parent |
|
19 | SOURCE_DIR = HERE.parent.parent | |
20 | VENV = SOURCE_DIR / "build" / "venv-packaging" |
|
20 | VENV = SOURCE_DIR / "build" / "venv-packaging" | |
21 |
|
21 | |||
22 |
|
22 | |||
23 | def bootstrap(): |
|
23 | def bootstrap(): | |
24 | venv_created = not VENV.exists() |
|
24 | venv_created = not VENV.exists() | |
25 |
|
25 | |||
26 | VENV.parent.mkdir(exist_ok=True) |
|
26 | VENV.parent.mkdir(exist_ok=True) | |
27 |
|
27 | |||
28 | venv.create(VENV, with_pip=True) |
|
28 | venv.create(VENV, with_pip=True) | |
29 |
|
29 | |||
30 | if os.name == "nt": |
|
30 | if os.name == "nt": | |
31 | venv_bin = VENV / "Scripts" |
|
31 | venv_bin = VENV / "Scripts" | |
32 | pip = venv_bin / "pip.exe" |
|
32 | pip = venv_bin / "pip.exe" | |
33 | python = venv_bin / "python.exe" |
|
33 | python = venv_bin / "python.exe" | |
34 | else: |
|
34 | else: | |
35 | venv_bin = VENV / "bin" |
|
35 | venv_bin = VENV / "bin" | |
36 | pip = venv_bin / "pip" |
|
36 | pip = venv_bin / "pip" | |
37 | python = venv_bin / "python" |
|
37 | python = venv_bin / "python" | |
38 |
|
38 | |||
39 | args = [ |
|
39 | args = [ | |
40 | str(pip), |
|
40 | str(pip), | |
41 | "install", |
|
41 | "install", | |
42 | "-r", |
|
42 | "-r", | |
43 | str(REQUIREMENTS_TXT), |
|
43 | str(REQUIREMENTS_TXT), | |
44 | "--disable-pip-version-check", |
|
44 | "--disable-pip-version-check", | |
45 | ] |
|
45 | ] | |
46 |
|
46 | |||
47 | if not venv_created: |
|
47 | if not venv_created: | |
48 | args.append("-q") |
|
48 | args.append("-q") | |
49 |
|
49 | |||
50 | subprocess.run(args, check=True) |
|
50 | subprocess.run(args, check=True) | |
51 |
|
51 | |||
52 | os.environ["HGPACKAGING_BOOTSTRAPPED"] = "1" |
|
52 | os.environ["HGPACKAGING_BOOTSTRAPPED"] = "1" | |
53 | os.environ["PATH"] = "%s%s%s" % (venv_bin, os.pathsep, os.environ["PATH"]) |
|
53 | os.environ["PATH"] = "%s%s%s" % (venv_bin, os.pathsep, os.environ["PATH"]) | |
54 |
|
54 | |||
55 | subprocess.run([str(python), __file__] + sys.argv[1:], check=True) |
|
55 | subprocess.run([str(python), __file__] + sys.argv[1:], check=True) | |
56 |
|
56 | |||
57 |
|
57 | |||
58 | def run(): |
|
58 | def run(): | |
59 | import hgpackaging.cli as cli |
|
59 | import hgpackaging.cli as cli | |
60 |
|
60 | |||
61 | # Need to strip off main Python executable. |
|
61 | # Need to strip off main Python executable. | |
62 | cli.main() |
|
62 | cli.main() | |
63 |
|
63 | |||
64 |
|
64 | |||
65 | if __name__ == "__main__": |
|
65 | if __name__ == "__main__": | |
66 | try: |
|
66 | try: | |
67 | if "HGPACKAGING_BOOTSTRAPPED" not in os.environ: |
|
67 | if "HGPACKAGING_BOOTSTRAPPED" not in os.environ: | |
68 | bootstrap() |
|
68 | bootstrap() | |
69 | else: |
|
69 | else: | |
70 | run() |
|
70 | run() | |
71 | except subprocess.CalledProcessError as e: |
|
71 | except subprocess.CalledProcessError as e: | |
72 | sys.exit(e.returncode) |
|
72 | sys.exit(e.returncode) | |
73 | except KeyboardInterrupt: |
|
73 | except KeyboardInterrupt: | |
74 | sys.exit(1) |
|
74 | sys.exit(1) |
@@ -1,12 +1,12 b'' | |||||
1 |
# |
|
1 | # | |
2 |
# This file is autogenerated by pip-compile |
|
2 | # This file is autogenerated by pip-compile | |
3 |
# To update, run: |
|
3 | # To update, run: | |
4 |
# |
|
4 | # | |
5 |
# pip-compile --generate-hashes --output-file=contrib/packaging/requirements.txt contrib/packaging/requirements.txt.in |
|
5 | # pip-compile --generate-hashes --output-file=contrib/packaging/requirements.txt contrib/packaging/requirements.txt.in | |
6 |
# |
|
6 | # | |
7 | jinja2==2.10.3 \ |
|
7 | jinja2==2.10.3 \ | |
8 | --hash=sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f \ |
|
8 | --hash=sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f \ | |
9 |
--hash=sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de |
|
9 | --hash=sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de | |
10 | markupsafe==1.1.1 \ |
|
10 | markupsafe==1.1.1 \ | |
11 | --hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \ |
|
11 | --hash=sha256:00bc623926325b26bb9605ae9eae8a215691f33cae5df11ca5424f06f2d1f473 \ | |
12 | --hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \ |
|
12 | --hash=sha256:09027a7803a62ca78792ad89403b1b7a73a01c8cb65909cd876f7fcebd79b161 \ | |
@@ -36,4 +36,4 b' markupsafe==1.1.1 \\' | |||||
36 | --hash=sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f \ |
|
36 | --hash=sha256:c8716a48d94b06bb3b2524c2b77e055fb313aeb4ea620c8dd03a105574ba704f \ | |
37 | --hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \ |
|
37 | --hash=sha256:cd5df75523866410809ca100dc9681e301e3c27567cf498077e8551b6d20e42f \ | |
38 | --hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \ |
|
38 | --hash=sha256:e249096428b3ae81b08327a63a485ad0878de3fb939049038579ac0ef61e17e7 \ | |
39 |
# via jinja2 |
|
39 | # via jinja2 |
General Comments 0
You need to be logged in to leave comments.
Login now