From 748e31e456b1af8870f5c8677a730b7e377e2778 Mon Sep 17 00:00:00 2001 From: dchigarev Date: Mon, 20 Oct 2025 10:37:55 +0000 Subject: [PATCH 1/4] Make lighthouse an installable python package Signed-off-by: dchigarev --- .gitignore | 9 +++++++++ pyproject.toml | 4 ++++ python/lighthouse/__init__.py | 1 + 3 files changed, 14 insertions(+) create mode 100644 .gitignore create mode 100644 python/lighthouse/__init__.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6ada2b0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Python caches +__pycache__/ +*.py[cod] +.pytest_cache + +# Lighthouse Python module builds +dist/ +python/lighthouse*.egg-info/ +*.whl diff --git a/pyproject.toml b/pyproject.toml index 7344821..14b6637 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,3 +62,7 @@ explicit = true name = "torch_mlir" url = "https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels" explicit = true + +[tool.setuptools.packages.find] +where = ["python"] +include = ["lighthouse*"] diff --git a/python/lighthouse/__init__.py b/python/lighthouse/__init__.py new file mode 100644 index 0000000..1ac008e --- /dev/null +++ b/python/lighthouse/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.0a1" From 8d193c2b3e4cd0a80885fde50b5e898e24b50844 Mon Sep 17 00:00:00 2001 From: dchigarev Date: Mon, 20 Oct 2025 10:43:58 +0000 Subject: [PATCH 2/4] update readme Signed-off-by: dchigarev --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 382a437..ddbd02b 100644 --- a/README.md +++ b/README.md @@ -68,3 +68,23 @@ For vendor-specific versions of `torch` use the targets `ingress-torch-nvidia`, To run the Python programs in this repo, either enter the virtual environment (`$ source .venv/bin/activate`) and execute a program _or_ execute each of the programs through `uv` (i.e. `$ uv run $EXE`), which will automatically run them inside the virtualenv. + +## Installing lighthouse as a python package + +You can also install lighthouse as a python package using `uv` and `pip`: + +``` +$ uv pip install . +$ python +Python 3.12.11 | packaged by conda-forge | (main, Jun 4 2025, 14:45:31) [GCC 13.3.0] on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> import lighthouse +>>> lighthouse.__version__ +'0.1.0a1' +``` + +In order to install the package including `ingress-torch` dependencies: + +``` +$ uv pip install .[ingress_torch_cpu] +``` From 8fcb8a2fb0a2a635bae80796d163415bcd5cd16f Mon Sep 17 00:00:00 2001 From: dchigarev Date: Mon, 20 Oct 2025 12:44:41 +0000 Subject: [PATCH 3/4] install lighthouse on 'uv sync' Signed-off-by: dchigarev --- README.md | 47 ++++++++++++++++++++++++++++++++++++++--------- pyproject.toml | 4 ++++ 2 files changed, 42 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ddbd02b..d09a4f8 100644 --- a/README.md +++ b/README.md @@ -53,10 +53,10 @@ The planned work is: ## Getting up and running For the time being, `lighthouse` depends on just the Python bindings for [`mlir`](https://github.com/llvm/eudsl/releases). -To install this dependency, obtain the [`uv`](https://docs.astral.sh/uv/getting-started/installation/#pypi) Python package manager and run the following in the root of the project: +To install this dependency along with `lighthouse` python package, obtain the [`uv`](https://docs.astral.sh/uv/getting-started/installation/#pypi) Python package manager and run the following in the root of the project: ``` $ uv venv # Create a .venv virtualenv -$ uv sync # Install the `mlir-python-bindings` dependency into the virtualenv +$ uv sync # Install the `mlir-python-bindings` and `lighthouse` into the virtualenv $ uv sync --extra ingress-torch-cpu # Optionally install the dependencies for torch ingress ``` @@ -69,22 +69,51 @@ For vendor-specific versions of `torch` use the targets `ingress-torch-nvidia`, To run the Python programs in this repo, either enter the virtual environment (`$ source .venv/bin/activate`) and execute a program _or_ execute each of the programs through `uv` (i.e. `$ uv run $EXE`), which will automatically run them inside the virtualenv. -## Installing lighthouse as a python package +## Installing Lighthouse as a Python package -You can also install lighthouse as a python package using `uv` and `pip`: +You can install `lighthouse` as a Python package using `uv` or `pip`: + +#### Installing via `uv` + +If you've run the steps from the [Getting up and running](#getting-up-and-running) section, +you already have `lighthouse` installed in your virtual environment: ``` -$ uv pip install . -$ python -Python 3.12.11 | packaged by conda-forge | (main, Jun 4 2025, 14:45:31) [GCC 13.3.0] on linux +$ uv run python +Python 3.12.11 | (main, Jun 4 2025, 14:45:31) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import lighthouse >>> lighthouse.__version__ '0.1.0a1' ``` -In order to install the package including `ingress-torch` dependencies: +If you don't want to use the virtual environment created by `uv`, you can skip `uv venv; uv sync` steps and install Lighthouse in your current environment using: + +``` +$ source ../my_custom_venv/bin/activate # or conda activate my-venv +(my-venv) $ uv pip install . # installs Lighthouse along with its basic dependencies +(my-venv) $ uv pip install .[ingress_torch_cpu] # installs Lighthouse along with its torch-ingress dependencies +``` + +#### Installing via `pip` + +If you don't want to use `uv` to install the package, you can install it directly with `pip`. +You'll need to specify the custom sources so `pip` can find all required dependencies (e.g., mlir-bindings). The sources are listed in the `pyproject.toml` file. + +Here are some common installation examples: + +1. Install Lighthouse only +``` +pip install . \ + --find-links https://llvm.github.io/eudsl/ \ + --only-binary :all: +``` +2. Install Lighthouse and torch-ingress dependencies ``` -$ uv pip install .[ingress_torch_cpu] +pip install .[ingress_torch_cpu] \ + --find-links https://llvm.github.io/eudsl/ \ + --find-links https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels \ + --extra-index-url https://download.pytorch.org/whl \ + --only-binary :all: ``` diff --git a/pyproject.toml b/pyproject.toml index 14b6637..508ee46 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -63,6 +63,10 @@ name = "torch_mlir" url = "https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels" explicit = true +[build-system] +requires = ["setuptools>=68", "wheel"] +build-backend = "setuptools.build_meta" + [tool.setuptools.packages.find] where = ["python"] include = ["lighthouse*"] From 6bec44edf86a7bc2a0a75863ba2b099b19be03e2 Mon Sep 17 00:00:00 2001 From: dchigarev Date: Mon, 20 Oct 2025 13:29:11 +0000 Subject: [PATCH 4/4] use dynamic version in pyproject.toml Signed-off-by: dchigarev --- pyproject.toml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 508ee46..93b3a74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lighthouse" -version = "0.1.0a1" +dynamic = ["version"] requires-python = ">=3.10,<3.13" # Bounds are due to torch-mlir's packaging dependencies = [ "mlir-python-bindings==20251011+3af43e303", @@ -70,3 +70,6 @@ build-backend = "setuptools.build_meta" [tool.setuptools.packages.find] where = ["python"] include = ["lighthouse*"] + +[tool.setuptools.dynamic] +version = {attr = "lighthouse.__version__"}