Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace inline pip install with pip install from requirements*.txt #21106

Merged
merged 13 commits into from
Jul 22, 2024
30 changes: 17 additions & 13 deletions tools/ci_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -870,14 +870,21 @@ def update_submodules(source_dir):
run_subprocess(["git", "submodule", "update", "--init", "--recursive"], cwd=source_dir)


def install_python_deps(numpy_version=""):
dep_packages = ["setuptools", "wheel", "pytest"]
dep_packages.append(f"numpy=={numpy_version}" if numpy_version else "numpy>=1.16.6")
dep_packages.append("sympy>=1.10")
dep_packages.append("packaging")
dep_packages.append("cerberus")
dep_packages.append("psutil")
run_subprocess([sys.executable, "-m", "pip", "install", *dep_packages])
def install_python_deps(requirements_file='requirements.txt',numpy_version=None):
snnn marked this conversation as resolved.
Show resolved Hide resolved
if numpy_version is not None and numpy_version != "":
# Remove current numpy version from requirements-pybind.txt and add the specified version
with open(requirements_file, 'r+') as file:
lines = file.readlines()
file.seek(0)
package_to_exclude = 'numpy'
filtered_lines = [line for line in lines if package_to_exclude not in line]
filtered_lines.append(f'numpy=={numpy_version}\n')
file.writelines(filtered_lines)
file.truncate()
run_subprocess(
[sys.executable, "-m", "pip", "install", "-r", requirements_file],
cwd=SCRIPT_DIR,
)


def setup_test_data(source_onnx_model_dir, dest_model_dir_name, build_dir, configs):
Expand Down Expand Up @@ -2146,10 +2153,7 @@ def run_onnxruntime_tests(args, source_dir, ctest_path, build_dir, configs):

numpy_init_version = numpy.__version__
pb_init_version = google.protobuf.__version__
run_subprocess(
[sys.executable, "-m", "pip", "install", "-r", "requirements-transformers-test.txt"],
cwd=SCRIPT_DIR,
)
install_python_deps('requirements/requirements-transformers-test.txt')
run_subprocess([sys.executable, "-m", "pytest", "transformers"], cwd=cwd)
# Restore initial numpy/protobuf version in case other tests use it
run_subprocess([sys.executable, "-m", "pip", "install", "numpy==" + numpy_init_version])
Expand Down Expand Up @@ -2810,7 +2814,7 @@ def main():
run_subprocess([emsdk_file, "activate", emsdk_version], cwd=emsdk_dir)

if args.enable_pybind and is_windows():
install_python_deps(args.numpy_version)
install_python_deps('requirements/requirements-pybind.txt', args.numpy_version)

if args.use_rocm and args.rocm_version is None:
args.rocm_version = ""
Expand Down
9 changes: 9 additions & 0 deletions tools/ci_build/requirements/requirements-pybind.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
setuptools
jchen351 marked this conversation as resolved.
Show resolved Hide resolved
wheel
pytest
numpy==1.24.0 ; python_version < '3.12'
numpy==1.26.0 ; python_version >= '3.12'
snnn marked this conversation as resolved.
Show resolved Hide resolved
sympy>=1.10
packaging
cerberus
psutil
Loading