Skip to content

Commit 677e661

Browse files
authored
fix(deps): use python 3.12
* Update Rust complication strategy. * Reorganize code and tests. * Use latest Maturin and update Rust compilation strategy. * Use latest Bowtie2.
1 parent 3bb0429 commit 677e661

File tree

23 files changed

+1152
-1106
lines changed

23 files changed

+1152
-1106
lines changed

.devcontainer/Dockerfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
FROM debian:bookworm as bowtie2
2+
WORKDIR /build
3+
RUN apt-get update && apt-get install -y build-essential cmake wget zlib1g-dev
4+
RUN wget https://github.com/BenLangmead/bowtie2/archive/refs/tags/v2.5.4.tar.gz
5+
RUN tar -xvf v2.5.4.tar.gz
6+
WORKDIR bowtie2-2.5.4
7+
RUN make
8+
RUN mkdir /build/bowtie2
9+
RUN cp bowtie2* /build/bowtie2/
10+
11+
FROM debian:bookworm as pigz
12+
WORKDIR /build
13+
RUN apt-get update && apt-get install -y gcc make wget zlib1g-dev
14+
RUN wget https://zlib.net/pigz/pigz-2.8.tar.gz && \
15+
tar -xzvf pigz-2.8.tar.gz && \
16+
cd pigz-2.8 && \
17+
make
18+
19+
FROM python:3.12-bookworm
20+
COPY --from=bowtie2 /build/bowtie2/* /usr/local/bin/
21+
COPY --from=ghcr.io/virtool/workflow-tools:2.0.1 /opt/fastqc /opt/fastqc
22+
COPY --from=ghcr.io/virtool/workflow-tools:2.0.1 /opt/hmmer /opt/hmmer
23+
COPY --from=ghcr.io/virtool/workflow-tools:2.0.1 /usr/local/bin/pigz /usr/local/bin/
24+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
25+
RUN curl -sSL https://install.python-poetry.org | python -
26+
ENV PATH="/root/.local/bin:/root/.cargo/bin:${PATH}"

.devcontainer/devcontainer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "pathoscope-test",
3+
"build": {
4+
"dockerfile": "Dockerfile",
5+
"context": "."
6+
},
7+
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
load: true
3636
target: test
3737
- name: Test
38-
run: docker run --rm -t ${{ steps.build.outputs.imageid }} pytest
38+
run: docker run --rm -t ${{ steps.build.outputs.imageid }} poetry run pytest
3939
release:
4040
runs-on: ubuntu-22.04
4141
needs: [commitlint, test]

.github/workflows/publish.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ jobs:
1616
if: github.repository_owner == 'Virtool'
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@v3
19+
uses: actions/checkout@v4
2020
- name: Write VERSION file
2121
run: echo ${{ github.event.release.tag_name }} > VERSION
22-
- name: Update pyproject.toml version
23-
run: sed -i 's/0\.0\.0/${{ github.event.release.tag_name }}/' pyproject.toml
2422
- name: Login to Registry
2523
uses: docker/login-action@v3
2624
with:
@@ -33,11 +31,10 @@ jobs:
3331
with:
3432
images: ${{ env.REGISTRY }}/virtool/pathoscope
3533
- name: Build and Push
36-
uses: docker/build-push-action@v4
34+
uses: docker/build-push-action@v5
3735
with:
3836
context: .
3937
labels: ${{ steps.meta.outputs.labels }}
4038
push: true
4139
tags: ${{ steps.meta.outputs.tags }}
4240
target: "base"
43-

Cargo.lock

Lines changed: 53 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
[package]
2-
name = "rust_utils"
3-
version = "0.1.0"
4-
edition = "2021"
5-
authors = ["Markus Swoveland"]
2+
name = "workflowpathoscope"
3+
version = "0.0.0"
4+
edition = "2021"
5+
authors = ["Markus Swoveland"]
6+
7+
[lib]
8+
name = "workflow_pathoscope"
9+
# "cdylib" is necessary to produce a shared library for Python to import from.
10+
crate-type = ["cdylib"]
611

712
[dependencies]
813
yaml-rust = "0.4.5"
914

10-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11-
1215
[dependencies.pyo3]
13-
version = "0.16.3"
14-
15-
[features]
16-
extension-module = ["pyo3/extension-module"]
17-
default = ["extension-module"]
16+
version = "^0.20.0"
17+
# "abi3-py38" tells pyo3 (and maturin) to build using the stable ABI with minimum
18+
# Python version 3.12
19+
features = ["abi3-py312"]

Dockerfile

Lines changed: 50 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,66 @@
1-
FROM debian:buster as prep
1+
FROM debian:bookworm as bowtie2
22
WORKDIR /build
3-
RUN apt-get update && apt-get install -y make gcc zlib1g-dev wget unzip
3+
RUN apt-get update && apt-get install -y build-essential cmake wget zlib1g-dev
4+
RUN wget https://github.com/BenLangmead/bowtie2/archive/refs/tags/v2.5.4.tar.gz
5+
RUN tar -xvf v2.5.4.tar.gz
6+
WORKDIR bowtie2-2.5.4
7+
RUN make
8+
RUN mkdir /build/bowtie2
9+
RUN cp bowtie2* /build/bowtie2/
10+
11+
FROM debian:bookworm as pigz
12+
WORKDIR /build
13+
RUN apt-get update && apt-get install -y gcc make wget zlib1g-dev
414
RUN wget https://zlib.net/pigz/pigz-2.8.tar.gz && \
515
tar -xzvf pigz-2.8.tar.gz && \
616
cd pigz-2.8 && \
717
make
8-
RUN wget https://www.bioinformatics.babraham.ac.uk/projects/fastqc/fastqc_v0.11.9.zip && \
9-
unzip fastqc_v0.11.9.zip
10-
RUN wget https://github.com/BenLangmead/bowtie2/releases/download/v2.3.2/bowtie2-2.3.2-legacy-linux-x86_64.zip && \
11-
unzip bowtie2-2.3.2-legacy-linux-x86_64.zip && \
12-
mkdir bowtie2 && \
13-
cp bowtie2-2.3.2-legacy/bowtie2* bowtie2
14-
1518

16-
FROM python:3.10-buster as base
19+
FROM python:3.12-bookworm as deps
1720
WORKDIR /app
18-
COPY --from=prep /build/bowtie2/* /usr/local/bin/
19-
COPY --from=prep /build/FastQC /opt/fastqc
20-
COPY --from=prep /build/pigz-2.8/pigz /usr/local/bin/pigz
21-
RUN chmod ugo+x /opt/fastqc/fastqc && \
22-
ln -fs /opt/fastqc/fastqc /usr/local/bin/fastqc && \
23-
for file in `ls /opt/hmmer/bin`; do ln -fs /opt/hmmer/bin/${file} /usr/local/bin/${file}; done
21+
COPY --from=bowtie2 /build/bowtie2/* /usr/local/bin/
22+
COPY --from=ghcr.io/virtool/workflow-tools:2.0.1 /opt/fastqc /opt/fastqc
23+
COPY --from=ghcr.io/virtool/workflow-tools:2.0.1 /opt/hmmer /opt/hmmer
24+
COPY --from=ghcr.io/virtool/workflow-tools:2.0.1 /usr/local/bin/pigz /usr/local/bin/
2425
RUN apt-get update && \
25-
apt-get install -y --no-install-recommends curl build-essential default-jre && \
26+
apt-get install -y --no-install-recommends default-jre && \
2627
rm -rf /var/lib/apt/lists/* && \
2728
apt-get clean
29+
30+
FROM python:3.12-bookworm as poetry
31+
WORKDIR /app
2832
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2933
RUN curl -sSL https://install.python-poetry.org | python -
30-
ENV PATH="/root/.cargo/bin:/root/.local/bin:${PATH}"
31-
RUN pip install --upgrade pip
32-
RUN pip install maturin==0.14.5
33-
COPY src src
34-
COPY Cargo.toml Cargo.lock fixtures.py utils.py poetry.lock pyproject.toml workflow.py ./
35-
RUN maturin build --release
36-
RUN poetry export > requirements.txt
37-
RUN pip install -r requirements.txt
38-
RUN pip install /app/target/wheels/rust_utils*.whl
39-
COPY VERSION* ./
34+
ENV PATH="/root/.local/bin:/root/.cargo/bin:${PATH}" \
35+
POETRY_CACHE_DIR='/tmp/poetry_cache' \
36+
POETRY_NO_INTERACTION=1 \
37+
POETRY_VIRTUALENVS_IN_PROJECT=1 \
38+
POETRY_VIRTUALENVS_CREATE=1
39+
COPY Cargo.toml Cargo.lock poetry.lock pyproject.toml ./
40+
COPY python/ ./python
41+
COPY src ./src
42+
RUN poetry install
43+
RUN poetry run maturin develop --release
4044

41-
FROM base as test
45+
FROM deps as base
4246
WORKDIR /app
43-
RUN poetry export --with dev > requirements.txt
44-
RUN pip install -r requirements.txt
47+
ENV VIRTUAL_ENV=/app/.venv \
48+
PATH="/app/.venv/bin:/opt/fastqc:/opt/hmmer/bin:${PATH}"
49+
RUN chmod ugo+x /opt/fastqc/fastqc
50+
COPY --from=poetry /app/.venv /app/.venv
51+
COPY --from=poetry /app/python /app/python
52+
COPY fixtures.py workflow.py VERSION* ./
53+
54+
FROM deps as test
55+
WORKDIR /app
56+
ENV PATH="/root/.local/bin:/root/.cargo/bin:${PATH}"
57+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
58+
RUN curl -sSL https://install.python-poetry.org | python -
59+
COPY Cargo.lock Cargo.toml pyproject.toml poetry.lock ./
60+
COPY src ./src
61+
COPY python ./python
62+
RUN poetry install
63+
RUN poetry run maturin develop --release
4564
COPY example ./example
4665
COPY tests ./tests
66+
COPY fixtures.py workflow.py VERSION* ./
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)