Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"
- uses: dtolnay/rust-toolchain@1.95.0 # pinned; keep in sync with rust-toolchain.toml
- run: uv sync --frozen
- run: PYTHONPATH=. uv run pytest --collect-only -q
- run: PYTHONPATH=. uv run pytest -m unit --no-cov -q
Expand All @@ -34,5 +35,6 @@ jobs:
- uses: astral-sh/setup-uv@v7
with:
python-version: "3.11"
- uses: dtolnay/rust-toolchain@1.95.0 # pinned; keep in sync with rust-toolchain.toml
- run: uv sync --frozen
- run: PYTHONPATH=. uv run pytest --network -m "unit or network or slow" --no-cov -q
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,10 @@ docs/sources/*/impact-report/modified-cliques.json
.coverage
.coverage.*
htmlcov/

# maturin / Rust build artifacts
rust/target/
# native extension dropped into src/ by `maturin develop` (don't commit compiled binaries)
src/rs.*.so
src/rs.*.pyd
src/rs.*.dylib
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ RUN adduser --home ${ROOT} --uid 1000 nru
# Set up a $ROOT directory with the source code to work in.
RUN mkdir -p ${ROOT}
WORKDIR ${ROOT}

# Rust toolchain — required because the build backend is maturin (compiles a native extension).
RUN apt-get update && apt-get install -y cargo

Comment thread
SkyeAv marked this conversation as resolved.
USER nru
COPY --chown=nru . ${ROOT}

# Install and run `uv sync` to install packages.
# Install uv and sync packages. `--frozen` installs exactly the committed uv.lock
# (no re-resolution), keeping the image reproducible and matching CI's `uv sync --frozen`.
RUN pipx install uv
ENV PATH="${ROOT}/.local/bin:${PATH}"
RUN uv sync
RUN uv sync --frozen

# Our default entrypoint is to start the Babel run.
ENTRYPOINT ["bash", "-c", "uv run snakemake --cores ${CORES}"]
22 changes: 17 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Issues = "https://github.com/NCATSTranslator/Babel/issues"
[dependency-groups]
dev = [
"ipykernel>=7.1.0",
"maturin>=1.0,<2.0",
"py-spy>=0.4.2",
"ruff>=0.14.14",
"rumdl>=0.2.4",
Expand All @@ -55,12 +56,16 @@ source-impact-report = "src.tools.source_impact_report.cli:main"
package = true

[build-system]
requires = ["setuptools>=83.0.0"]
build-backend = "setuptools.build_meta"
requires = ["maturin>=1.0,<2.0"]
build-backend = "maturin"

[tool.setuptools.packages.find]
where = ["."]
include = ["src", "src.*"]
[tool.maturin]
# The importable Python package is literally named `src` (flat layout). A dotted module-name
# places the compiled extension at `src/rs.*` and tells maturin the package to bundle is `src`
# (auto-resolved to the repo root since src-layout detection won't fire).
module-name = "src.rs"
# Rust source lives under rust/ so Cargo never collides with the Python `src/` dir.
manifest-path = "rust/Cargo.toml"


# Linting/formatting configuration
Expand All @@ -84,6 +89,13 @@ ignore = [
fixable = ["ALL"]
unfixable = []

[tool.ruff.format]
# Ruff 0.16.0 began formatting Python code fences inside Markdown, which overlaps with the
# dedicated rumdl Markdown check and broke CI when astral-sh/ruff-action@v3 floated to 0.16.0
# (pyproject pins only a floor, >=0.14.14). Keep ruff's formatter scoped to Python source and
# leave Markdown to rumdl so formatting CI stays deterministic across ruff releases.
exclude = ["*.md"]

[tool.snakefmt]
line_length = 120
include = '\.snakefile$|^Snakefile'
Expand Down
6 changes: 6 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Pin the Rust toolchain so local builds, CI, and any rustup-based environment all
# compile the maturin/PyO3 extension with the same compiler version. The CI action ref
# (dtolnay/rust-toolchain in .github/workflows/test.yml) is pinned to match this; bump
# both together when upgrading Rust.
[toolchain]
channel = "1.95.0"
180 changes: 180 additions & 0 deletions rust/Cargo.lock

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

11 changes: 11 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "babel-pipeline"
version = "1.17.0" # valid SemVer (3 parts); published version is "1.17" from root pyproject
edition = "2021"

[lib]
name = "rs" # matches the #[pymodule] fn + module-name's last component
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.23", features = ["abi3-py311", "extension-module"] }
13 changes: 13 additions & 0 deletions rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Placeholder native extension for babel-pipeline.
//!
//! The build backend is maturin; this empty module exists only so the project builds as a
//! mixed Rust/Python package. Real functionality will land in a follow-up PR.

use pyo3::prelude::*;

/// Empty pyo3 module, importable as `from src import rs`. Name must match the last component
/// of `[tool.maturin] module-name` ("src.rs" → `rs`).
#[pymodule]
fn rs(_m: &Bound<'_, PyModule>) -> PyResult<()> {
Ok(())
}
23 changes: 23 additions & 0 deletions uv.lock

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