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/README.md b/README.md index 382a437..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 ``` @@ -68,3 +68,52 @@ 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 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 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' +``` + +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 +``` +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 7344821..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", @@ -62,3 +62,14 @@ explicit = true 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*"] + +[tool.setuptools.dynamic] +version = {attr = "lighthouse.__version__"} 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"