Skip to content

Commit

Permalink
Switch instructions & metadata files to use a modern uv workflow (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
sampsyo authored Dec 30, 2024
2 parents ae5d6b6 + 994e28c commit 9adcdd8
Show file tree
Hide file tree
Showing 11 changed files with 269 additions and 53 deletions.
14 changes: 4 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,14 @@ jobs:
with:
path: ~/.cache/uv
key: ${{ runner.os }}-python-${{ matrix.python-version }}-uv
- name: Create and activate virtualenv with uv
- name: uv sync and activate
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv sync
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Install Python tools
run: uv pip install -r requirements.txt
# Set up for tests.
- name: Install Turnt
run: uv pip install turnt
- name: Problem matcher
run: echo '::add-matcher::.github/tap-matcher.json'
- name: Fetch test data
Expand Down Expand Up @@ -70,14 +66,12 @@ jobs:
with:
path: ~/.cache/uv
key: ${{ runner.os }}-python-${{ matrix.python-version }}-uv
- name: Create and activate virtualenv with uv
- name: uv sync and activate
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv
uv sync
echo "VIRTUAL_ENV=.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Install Python tools
run: uv pip install -r requirements.txt
# Install odgi
- name: Pull odgi container
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ Similarly, `slow_odgi` is a set of GFA analyses based on `mygfa`; it's meant to

To set up both of them from this repository, try using [uv][]:

$ uv venv
$ uv pip install -r requirements.txt
$ source .venv/bin/activate
$ uv run slow_odgi --help

Or, alternatively, you can set up and activate the environment manually:

Now type `slow_odgi --help` to see if everything's working.
$ uv sync
$ source .venv/bin/activate
$ slow_odgi --help

[uv]: https://github.com/astral-sh/uv
[mygfa-docs]: http://cucapra.github.io/pollen/mygfa/
Expand Down
7 changes: 7 additions & 0 deletions flatgfa-py/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 5 additions & 17 deletions flatgfa-py/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,20 @@ Then, read [the API documentation][flatgfa-py-docs] for details about what it ca
Development
-----------

To build this library, first install [Maturin][]:
The easiest way to get started is with [uv][]:

$ pipx install maturin
$ uv run --package flatgfa python example.py

Next, we'll build and install the Python library in our virtualenv.
Starting from the repository root:

$ uv venv # Unless you already created the virtualenv.
$ uv pip install pip # Maturin depends on pip.
$ source .venv/bin/activate
$ cd flatgfa-py
$ maturin develop

Now the `flatgfa` module is available to Python programs.
Try our [example][]:

$ python example.py
That should build and install the package and then run our `example.py` script.

Or run the tests:

$ uv pip install pytest
$ pytest
$ uv run --package flatgfa pytest

[maturin]: https://www.maturin.rs
[flatgfa-py-docs]: https://cucapra.github.io/pollen/flatgfa/
[flatgfa]: https://github.com/cucapra/pollen/tree/main/flatgfa
[gfa]: https://github.com/GFA-spec/GFA-spec/blob/master/GFA1.md
[flatgfa-pypi]: https://pypi.org/project/flatgfa/
[example]: https://github.com/cucapra/pollen/blob/main/flatgfa-py/example.py
[uv]: https://docs.astral.sh/uv/
4 changes: 2 additions & 2 deletions flatgfa-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ classifiers = [
repository = "https://github.com/cucapra/pollen"
documentation = "https://cucapra.github.io/pollen/flatgfa/"

[project.optional-dependencies]
test = ["pytest"]
[dependency-groups]
dev = ["pytest>=8.3.0"]

[build-system]
requires = ["maturin>=1.0,<2.0"]
Expand Down
3 changes: 1 addition & 2 deletions pollen_py/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ Clone this repository:

And then install the Python tools using [uv][]:

$ uv venv
$ uv pip install -r requirements.txt
$ uv sync
$ source .venv/bin/activate

[calyx]: https://calyxir.org
Expand Down
19 changes: 9 additions & 10 deletions pollen_py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[build-system]
requires = ["flit_core >=2,<4"]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"

[tool.flit.metadata]
module = "pollen"
author = "Susan Garry"
author-email = "[email protected]"
home-page = "https://github.com/cucapra/pollen"
description-file = "README.md"
requires-python = ">=3.8"
requires = []
[project]
name = "pollen"
authors = [
{ name = "Susan Garry", email = "[email protected]" }
]
readme = "README.md"
dynamic = ["version", "description"]

[tool.flit.scripts]
[project.scripts]
exine = "pollen.main:main"
27 changes: 27 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[project]
name = "pollen_workspace"
version = "0.0.0"
requires-python = ">=3.8"
dependencies = [
"mygfa",
"slow_odgi",
"pollen",
"pollen_data_gen",
"turnt>=1.11.0",
]

[tool.uv.sources]
mygfa = { workspace = true }
slow_odgi = { workspace = true }
pollen = { workspace = true }
pollen_data_gen = { workspace = true }
flatgfa = { workspace = true }

[tool.uv.workspace]
members = [
"mygfa",
"slow_odgi",
"pollen_py",
"pollen_data_gen",
"flatgfa-py",
]
5 changes: 0 additions & 5 deletions requirements.txt

This file was deleted.

5 changes: 2 additions & 3 deletions slow_odgi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ Think of it as a code-forward spec for `odgi` commands.

One easy way to install everything in the Pollen repo is to use [uv][]:

$ uv venv
$ uv pip install -r requirements.txt
$ uv sync
$ source .venv/bin/activate

[uv]: https://github.com/astral-sh/uv
Expand All @@ -30,7 +29,7 @@ To test `slow_odgi`, we treat odgi as an oracle and compare our outputs against
To run these tests, you will need:

1. [Odgi][]. Our tests were run against a built-from-source copy of odgi (commit `34f006f`).
2. [Turnt][]. This is installed automatically if you use `requirements.txt` as above.
2. [Turnt][]. This is installed automatically if you use `uv` as above.

With these in place, run `make test-slow-odgi`. The "oracle" files will be generated first, and this will toss up a large number of warnings which can all be ignored. Then the tests will begin to run, and the `ok`/`not ok` signals there are actually of interest.

Expand Down
Loading

0 comments on commit 9adcdd8

Please sign in to comment.