Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/andrewguenther/rules_python_poetry
Poetry lockfile support for Bazel
https://github.com/andrewguenther/rules_python_poetry
bazel poetry python
Last synced: about 4 hours ago
JSON representation
Poetry lockfile support for Bazel
- Host: GitHub
- URL: https://github.com/andrewguenther/rules_python_poetry
- Owner: AndrewGuenther
- License: mit
- Created: 2021-12-29T01:13:45.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-12-18T18:35:18.000Z (11 months ago)
- Last Synced: 2024-05-21T06:17:01.253Z (6 months ago)
- Topics: bazel, poetry, python
- Language: Starlark
- Homepage:
- Size: 34.2 KB
- Stars: 18
- Watchers: 4
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Poetry Bazel Rule
This repository provides a rule for Poetry integration with Bazel's
own [`rules_python`](https://github.com/bazelbuild/rules_python). It does so
by calling `poetry export` to generate a requirements file which can then be
fed into the `pip_install` or `pip_parse` rules.## Installation
### Prerequisites
* Poetry 1.2 or higher
* `rules_python` 0.5.0 or higher
* Bazel 3.0 or higher### Add rules_python_poetry to your WORKSPACE
```starlark
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "rules_python",
sha256 = "8c8fe44ef0a9afc256d1e75ad5f448bb59b81aba149b8958f02f7b3a98f5d9b4",
strip_prefix = "rules_python-0.13.0",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.13.0.tar.gz",
)# Rules for Poetry
http_archive(
name = "rules_python_poetry",
sha256 = "d6d1d09ffcfcec5eccd4c91d6cb85bfc3c2014f97ad9dc51843c0fe70575bcf8",
strip_prefix = "rules_python_poetry-1fc695ec467e01e1be11e8feb1b6b7fda614ecb7",
urls = ["https://github.com/AndrewGuenther/rules_python_poetry/archive/1fc695ec467e01e1be11e8feb1b6b7fda614ecb7.tar.gz"],
)load("@rules_python_poetry//rules_python_poetry:poetry.bzl", "poetry_lock")
# Generate a requirements lock file from our poetry lock
poetry_lock(
name = "requirements",
lockfile = "//:poetry.lock",
)load("@rules_python//python:pip.bzl", "pip_parse")
# Create a central repo that knows about the dependencies needed from
# requirements_lock.txt.
pip_parse(
name = "python_deps",
requirements_lock = "@requirements//:requirements_lock.txt",
)# Load the starlark macro which will define your dependencies.
load("@python_deps//:requirements.bzl", "install_deps")# Call it to define repos for your requirements.
install_deps()
```