@@ -42,9 +42,19 @@ def create_virtualenv():
42
42
# Create virtual environment
43
43
"python3 -m venv test_env" ,
44
44
]
45
- os .environ ["PATH" ] = (
46
- "/test_env/bin/" + os .pathsep + os .environ .get ("PATH" , "" )
45
+ os .environ ["PATH" ] = os .pathsep .join (
46
+ (
47
+ os .path .join (os .getcwd (), "test_env" , "bin" ),
48
+ os .environ .get ("PATH" , "" ),
49
+ )
47
50
)
51
+ if os .name == "nt" :
52
+ os .environ ["PATH" ] = os .pathsep .join (
53
+ (
54
+ os .path .join (os .getcwd (), "test_env" , "Scripts" ),
55
+ os .environ ["PATH" ],
56
+ )
57
+ )
48
58
run_commands_local (env_setup )
49
59
50
60
@@ -53,18 +63,17 @@ def manage_venv_installs(whl_path):
53
63
backend_pkg , backend_extra_url = BACKEND_REQ [backend .backend ()]
54
64
install_setup = [
55
65
# Installs the backend's package and common requirements
56
- "pip install " + backend_extra_url + backend_pkg ,
66
+ f "pip install { backend_extra_url } { backend_pkg } " ,
57
67
"pip install -r requirements-common.txt" ,
58
68
"pip install pytest" ,
59
69
# Ensure other backends are uninstalled
60
- "pip uninstall -y "
61
- + BACKEND_REQ [other_backends [0 ]][0 ]
62
- + " "
63
- + BACKEND_REQ [other_backends [1 ]][0 ]
64
- + " "
65
- + BACKEND_REQ [other_backends [2 ]][0 ],
70
+ "pip uninstall -y {0} {1} {2}" .format (
71
+ BACKEND_REQ [other_backends [0 ]][0 ],
72
+ BACKEND_REQ [other_backends [1 ]][0 ],
73
+ BACKEND_REQ [other_backends [2 ]][0 ],
74
+ ),
66
75
# Install `.whl` package
67
- "pip install " + whl_path ,
76
+ f "pip install { whl_path } " ,
68
77
]
69
78
# Install flax for JAX when NNX is enabled
70
79
if backend .backend () == "jax" and config .is_nnx_enabled ():
@@ -102,7 +111,11 @@ def run_commands_venv(commands):
102
111
for command in commands :
103
112
print (f"Running command: { command } " )
104
113
cmd_with_args = command .split (" " )
105
- cmd_with_args [0 ] = "test_env/bin/" + cmd_with_args [0 ]
114
+ cmd_with_args [0 ] = os .path .join (
115
+ "test_env" ,
116
+ "Scripts" if os .name == "nt" else "bin" ,
117
+ cmd_with_args [0 ],
118
+ )
106
119
p = subprocess .Popen (cmd_with_args )
107
120
assert p .wait () == 0
108
121
0 commit comments