Skip to content

Commit 2b209d5

Browse files
authored
Make lighthouse an installable python package (#7)
The PR modifies `pyproject.toml` to make the content of `python/lighthouse` to be installable via `uv pip install .` For now the package is empty, but after #4 is merged users would be able to access ingress helper functions as part of the package: ```python from lighthouse.ingress.torch import import_from_file ... ``` * install lighthouse on 'uv sync' Signed-off-by: dchigarev <dmitry.chigarev@intel.com> * use dynamic version in pyproject.toml Signed-off-by: dchigarev <dmitry.chigarev@intel.com> --------- Signed-off-by: dchigarev <dmitry.chigarev@intel.com>
1 parent 8d6bed1 commit 2b209d5

File tree

4 files changed

+73
-3
lines changed

4 files changed

+73
-3
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Python caches
2+
__pycache__/
3+
*.py[cod]
4+
.pytest_cache
5+
6+
# Lighthouse Python module builds
7+
dist/
8+
python/lighthouse*.egg-info/
9+
*.whl

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ The planned work is:
5353
## Getting up and running
5454

5555
For the time being, `lighthouse` depends on just the Python bindings for [`mlir`](https://github.com/llvm/eudsl/releases).
56-
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:
56+
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:
5757
```
5858
$ uv venv # Create a .venv virtualenv
59-
$ uv sync # Install the `mlir-python-bindings` dependency into the virtualenv
59+
$ uv sync # Install the `mlir-python-bindings` and `lighthouse` into the virtualenv
6060
$ uv sync --extra ingress-torch-cpu # Optionally install the dependencies for torch ingress
6161
```
6262

@@ -68,3 +68,52 @@ For vendor-specific versions of `torch` use the targets `ingress-torch-nvidia`,
6868
</details>
6969

7070
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.
71+
72+
## Installing Lighthouse as a Python package
73+
74+
You can install `lighthouse` as a Python package using `uv` or `pip`:
75+
76+
#### Installing via `uv`
77+
78+
If you've run the steps from the [Getting up and running](#getting-up-and-running) section,
79+
you already have `lighthouse` installed in your virtual environment:
80+
81+
```
82+
$ uv run python
83+
Python 3.12.11 | (main, Jun 4 2025, 14:45:31) [GCC 13.3.0] on linux
84+
Type "help", "copyright", "credits" or "license" for more information.
85+
>>> import lighthouse
86+
>>> lighthouse.__version__
87+
'0.1.0a1'
88+
```
89+
90+
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:
91+
92+
```
93+
$ source ../my_custom_venv/bin/activate # or conda activate my-venv
94+
(my-venv) $ uv pip install . # installs Lighthouse along with its basic dependencies
95+
(my-venv) $ uv pip install .[ingress_torch_cpu] # installs Lighthouse along with its torch-ingress dependencies
96+
```
97+
98+
#### Installing via `pip`
99+
100+
If you don't want to use `uv` to install the package, you can install it directly with `pip`.
101+
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.
102+
103+
Here are some common installation examples:
104+
105+
1. Install Lighthouse only
106+
```
107+
pip install . \
108+
--find-links https://llvm.github.io/eudsl/ \
109+
--only-binary :all:
110+
```
111+
112+
2. Install Lighthouse and torch-ingress dependencies
113+
```
114+
pip install .[ingress_torch_cpu] \
115+
--find-links https://llvm.github.io/eudsl/ \
116+
--find-links https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels \
117+
--extra-index-url https://download.pytorch.org/whl \
118+
--only-binary :all:
119+
```

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "lighthouse"
3-
version = "0.1.0a1"
3+
dynamic = ["version"]
44
requires-python = ">=3.10,<3.13" # Bounds are due to torch-mlir's packaging
55
dependencies = [
66
"mlir-python-bindings==20251011+3af43e303",
@@ -62,3 +62,14 @@ explicit = true
6262
name = "torch_mlir"
6363
url = "https://github.com/llvm/torch-mlir-release/releases/expanded_assets/dev-wheels"
6464
explicit = true
65+
66+
[build-system]
67+
requires = ["setuptools>=68", "wheel"]
68+
build-backend = "setuptools.build_meta"
69+
70+
[tool.setuptools.packages.find]
71+
where = ["python"]
72+
include = ["lighthouse*"]
73+
74+
[tool.setuptools.dynamic]
75+
version = {attr = "lighthouse.__version__"}

python/lighthouse/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.1.0a1"

0 commit comments

Comments
 (0)