-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy pathnoxfile.py
106 lines (85 loc) · 3.93 KB
/
noxfile.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Copyright 2017 Google Inc.
#
# 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
#
# http://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.
import os
import nox
HERE = os.path.abspath(os.path.dirname(__file__))
# -- REQUIRES: nox >= 2023.04.22
# SEE: https://nox.thea.codes/en/stable/index.html
USE_PYTHON_VERSIONS = os.environ.get("NOXFILE_PYTHON_VERSIONS", "").split()
if not USE_PYTHON_VERSIONS:
with open(os.path.join(HERE, ".python-versions-used"), "r") as file:
USE_PYTHON_VERSIONS = [x.strip() for x in file]
install_commands = (("pip", "install", "."), ("pip", "install", "-e", "."))
def install_packages(session, package_a, package_b, command_a, command_b):
env = {**os.environ, "PIP_CONSTRAINT": f"{HERE}/constraints.txt"}
session.install("--upgrade", "pip", env=env)
session.chdir(package_a)
session.run("rm", "-rf", "dist", "build", "*.egg-info")
session.run(*command_a, env=env)
session.chdir(HERE)
session.chdir(package_b)
session.run("rm", "-rf", "dist", "build", "*.egg-info")
session.run(*command_b, env=env)
session.chdir(HERE)
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize("command_a", install_commands)
@nox.parametrize("command_b", install_commands)
def session_pkgutil(session, command_a, command_b):
install_packages(session, "pkgutil/pkg_a", "pkgutil/pkg_b", command_a, command_b)
session.run("python", "verify_packages.py")
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize("command_a", install_commands)
@nox.parametrize("command_b", install_commands)
def session_pkg_resources(session, command_a, command_b):
install_packages(
session, "pkg_resources/pkg_a", "pkg_resources/pkg_b", command_a, command_b
)
session.run("python", "verify_packages.py")
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize("command_a", install_commands)
@nox.parametrize("command_b", install_commands)
def session_pep420(session, command_a, command_b):
install_packages(session, "native/pkg_a", "native/pkg_b", command_a, command_b)
session.run("python", "verify_packages.py")
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize("command_a", install_commands)
@nox.parametrize("command_b", install_commands)
def session_cross_pkg_resources_pkgutil(session, command_a, command_b):
install_packages(
session, "pkg_resources/pkg_a", "pkgutil/pkg_b", command_a, command_b
)
session.run("python", "-m", "pip", "list")
session.run("python", "verify_packages.py")
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize("command_a", install_commands)
@nox.parametrize("command_b", install_commands)
def session_cross_pep420_pkgutil(session, command_a, command_b):
install_packages(session, "native/pkg_a", "pkgutil/pkg_b", command_a, command_b)
session.run("python", "verify_packages.py")
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize('command_a', install_commands)
@nox.parametrize('command_b', install_commands)
def session_cross_pep420_pkg_resources(session, command_a, command_b):
install_packages(
session, 'native/pkg_a', 'pkg_resources/pkg_b', command_a, command_b
)
session.run("python", "verify_packages.py")
@nox.session(python=USE_PYTHON_VERSIONS)
@nox.parametrize('command_a', install_commands)
@nox.parametrize('command_b', install_commands)
def session_cross_pkg_resources_pep420(session, command_a, command_b):
install_packages(
session, 'pkg_resources/pkg_a', 'native/pkg_b', command_a, command_b
)
session.run("python", "verify_packages.py")