https://github.com/cormacrelf/elk
Generate BUCK build files from poetry dependencies
https://github.com/cormacrelf/elk
buck2 poetry-plugin python
Last synced: 10 months ago
JSON representation
Generate BUCK build files from poetry dependencies
- Host: GitHub
- URL: https://github.com/cormacrelf/elk
- Owner: cormacrelf
- License: mit
- Created: 2024-06-01T08:09:21.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2024-06-02T03:59:45.000Z (about 2 years ago)
- Last Synced: 2025-01-11T19:44:30.267Z (over 1 year ago)
- Topics: buck2, poetry-plugin, python
- Language: Python
- Homepage:
- Size: 92.8 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Elk
Generate [Buck](https://buck2.build) build files from Python +
[Poetry](https://python-poetry.org) dependencies.
Much like [`reindeer`](https://github.com/facebookincubator/reindeer).
### Status: experimental
Not seriously tested on a big python codebase. But it does do toy examples.
It will probably break if there is more than one version of a particular
dependency.
### Install
```sh
pipx install poetry
pipx inject poetry .
```
### Quick start
Just follow along with the `example` folder. You'll probably want to copy the
`elk.toml` and `platform.bzl` files.
### Use buck2 to assemble the virtualenv for e.g. code completion
See `example/venv.sh`.
Configure `pyright` as usual, then:
```sh
cd example
./venv.sh :main nvim main.py
```
Your editor will reflect the dependencies added in example/BUCK.
So if you edit the other target, you won't get access to the packages
`cowsay` and `colorama`:
```sh
./venv.sh :other nvim other.py
```
### Using the poetry virtualenv for e.g. code completion
Poetry still works, and you can just hook into that.
Configure `pyright` as usual, then:
cd example
poetry -C pypi run nvim
Or otherwise use poetry to enter a shell with the virtualenv in it.
If you have a lot of python packages, and you've used `elk`
to place all their dependencies in a single BUCK file, then you will
get too many packages available in your language server, but Buck will
still precisely set up the paths when you `buck2 run`. Overall this might
be less annoying than getting the virtualenv path from buck.