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

fix build hook #14

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ To install `ell`, follow these steps:
```sh
poetry install
poetry run build-hook
poetry shell
```

This will install `ell` and its dependencies, including building the necessary frontend components for `ell-studio`.
Expand Down
28 changes: 23 additions & 5 deletions build_hook.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import os
import subprocess
import shutil
import sys
import toml


def run_command(command, cwd=None):
Expand All @@ -12,9 +14,13 @@ def run_command(command, cwd=None):


def sync_version():
version = (
subprocess.check_output(["poetry", "version", "-s"]).strip().decode("utf-8")
)
with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)
version = pyproject.get("tool", {}).get("poetry", {}).get("version")
if not version:
raise ValueError("Version not found in pyproject.toml")
version = "v" + version
print(f"setting {version=}")
run_command(f"git tag -f {version}")


Expand All @@ -25,8 +31,16 @@ def python_install():
run_command("pip uninstall -y ell")
run_command("poetry install")
run_command("poetry build")
run_command("pip install dist/*.whl")
shutil.rmtree("dist", ignore_errors=True)
# Use a wildcard pattern that works on both Windows and Unix-like systems
dist_dir = "dist"
dist_files = [
os.path.join(dist_dir, f) for f in os.listdir(dist_dir) if f.endswith(".whl")
]
if not dist_files:
raise RuntimeError("No .whl files found in dist directory")
for file in dist_files:
run_command(f"pip install {file}")
shutil.rmtree(dist_dir, ignore_errors=True)


def npm_install():
Expand All @@ -49,3 +63,7 @@ def main():
npm_install()
npm_build()
python_install()


if __name__ == "__main__":
main()
15 changes: 13 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ include = [
]

[tool.poetry.dependencies]
python = ">=3.9"
python = ">=3.9,<=3.13"
fastapi = "^0.111.1"
numpy = "^2.0.1"
dill = "^0.3.8"
Expand All @@ -39,6 +39,7 @@ typing-extensions = "^4.12.2"

[tool.poetry.group.dev.dependencies]
pytest = "^8.3.2"
toml = "^0.10.2"

[build-system]
requires = ["poetry-core>=1.0.0", "poetry-dynamic-versioning>=1.0.0,<2.0.0"]
Expand Down