Skip to content

Commit

Permalink
chore: make in venv
Browse files Browse the repository at this point in the history
  • Loading branch information
bojiang committed Aug 2, 2024
1 parent 9f83818 commit 607207b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
47 changes: 46 additions & 1 deletion src/make.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,49 @@ def hash_directory(directory_path):
return hasher.hexdigest()


def ensure_venv(project, venv_dir):
req_hash = hash_file(project / "requirements.txt")
venv_path = venv_dir / req_hash[:7]
if not venv_path.exists():
subprocess.run(
[
sys.executable,
"-m",
"venv",
venv_path,
],
check=True,
)
subprocess.run(
[
sys.executable,
"-m",
"uv",
"pip",
"install",
"bentoml",
"-p",
venv_path/"bin"/"python",
],
check=True,
)
subprocess.run(
[
sys.executable,
"-m",
"uv",
"pip",
"install",
"-r",
project / "requirements.txt",
"-p",
venv_path/"bin"/"python",
],
check=True,
)
return venv_path


if __name__ == "__main__":
if len(sys.argv) == 2:
specified_model = sys.argv[1]
Expand Down Expand Up @@ -93,9 +136,11 @@ def hash_directory(directory_path):
)
continue

version_path = ensure_venv(tempdir, pathlib.Path(project).absolute() / "venv")

subprocess.run(
[
sys.executable,
version_path / "bin" / "python",
"-m",
"bentoml",
"build",
Expand Down
2 changes: 2 additions & 0 deletions src/make_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
uv
pyyaml

0 comments on commit 607207b

Please sign in to comment.