FROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Set workdir to build in source tree
WORKDIR /src
# Copy the repository source code
COPY . /src
# Build both source tarball and wheel from the source
RUN python -m build --sdist
RUN python -m build --wheel
# Install the freshly built distribution(s)
RUN python -m pip install --no-cache-dir dist/*
# Optional: clean up build artifacts to keep the final image small
RUN rm -rf dist Biopython.egg-info __pycache__ tests .tox \
*/__pycache__ */*.pyc
# Default command: quick import test to verify installation
CMD ["bash", "-lc", "python -c 'import Bio, sys; print(\"Biopython version:\", Bio.__version__)'"]
__pycache__/ *.pyc .dist/ build/ dist/ *.egg-info/ .eggs/ .eggs-info/ *.tox/ .cache/ *.pytest_cache/ .DS_Store node_modules/ .venv/ venv/
- Exact error message and exit code - /usr/local/bin/python: No module named build - exit code: 1 - Failing command/step - [5/8] RUN python -m build --sdist - Missing packages or files mentioned - The Python module "build" is not installed (No module named build). This indicates the PyPI package named build (for PEP 517 builds) is missing from the image. - Version mismatch information - The apt-get install step on a Python 3.12 base installs Python 3.11-related packages (libpython3.11, libpython3.11-dev, python3.11-dev) alongside Python 3.12 components, indicating a version mismatch between the base Python (3.12) and the installed Python 3.11 dev libs. This can contribute to a non-ideal build environment when attempting to run python -m build. - Additional note - To resolve, ensure the build tool is installed in the image before running python -m build, e.g., pip install build (or include a dedicated Build system step in the Dockerfile).
FROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set workdir to build in source tree
WORKDIR /src
# Copy the repository source code
COPY . /src
# Build both source tarball and wheel from the source
RUN python -m build --sdist
RUN python -m build --wheel
# Install the freshly built distribution(s)
RUN python -m pip install --no-cache-dir dist/*
# Optional: clean up build artifacts to keep the final image small
RUN rm -rf dist Biopython.egg-info __pycache__ tests .tox \
*/__pycache__ */*.pyc
# Default command: quick import test to verify installation
CMD ["bash", "-lc", "python -c 'import Bio, sys; print(\"Biopython version:\", Bio.__version__)'"]
__pycache__/ *.pyc .dist/ build/ dist/ *.egg-info/ .eggs/ .eggs-info/ *.tox/ .cache/ *.pytest_cache/ .DS_Store node_modules/ .venv/ venv/
- Build status: VerifyBuild status: build_failed - Failing step: [ 9/10] RUN python -m pip install --no-cache-dir dist/* - Command: python -m pip install --no-cache-dir dist/* - Exit: 1 - Error: Cannot install biopython 1.87.dev0 (from /src/dist/biopython-1.87.dev0-cp312-cp312-linux_x86_64.whl) and biopython 1.87.dev0 (from /src/dist/biopython-1.87.dev0.tar.gz) because these package versions have conflicting dependencies - Conflict details: The user requested biopython 1.87.dev0 from both the wheel and the tar.gz - Additional issue: Some packages in these conflicts have no matching distributions available for your environment: biopython - Resolution suggestions: 1) loosen the range of package versions you've specified 2) remove package versions to allow pip to attempt to solve the dependency conflict - Note: ERROR: ResolutionImpossible; see https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts - Repeated message: The user also sees biopython 1.87.dev0 from tar.gz and similarly from the wheel path (reiterated) - Missing/conflicting distributions present in dist/: biopython-1.87.dev0-cp312-cp312-linux_x86_64.whl and biopython-1.87.dev0.tar.gz - Environment details: Python 3.12 (cp312); wheel tar built for cp312-cp312; conflict from attempting to install both artifacts of the same version - Build concern: Installing both sdist and wheel via dist/* may trigger building from the sdist before the wheel; could optimize by installing only the wheel (dist/*.whl) - Debian note: python3-dev package name may vary across Debian; ensure python3-dev matches Python 3.12 in the base image
FROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set workdir to build in source tree
WORKDIR /src
# Copy the repository source code
COPY . /src
# Build both source tarball and wheel from the source
RUN python -m build --sdist
RUN python -m build --wheel
# Install only the wheel to avoid conflicts with the sdist
RUN python -m pip install --no-cache-dir dist/*.whl
# Remove the source distribution tarball to keep the image clean
RUN rm -f dist/*.tar.gz
# Optional: clean up build artifacts to keep the final image small
# (the wheel is kept because it's installed)
RUN rm -rf Biopython.egg-info __pycache__ tests .tox \
*/__pycache__ */*.pyc
# Default command: quick import test to verify installation
CMD ["bash", "-lc", "python -c 'import Bio, sys; print(\"Biopython version:\", Bio.__version__)'"]
Concerns: The container smoke test relies on Bio.__version__ existing; if Biopython changes packaging, this attribute might not be available., Building Biopython from source increases image build time and may require additional system libraries on some bases; consider ensuring wheels are available for CI if permitted. Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__) Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: python -c 'from Bio import Seq Output: sh: 1: Syntax error: Unterminated quoted string
FROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set workdir to build in source tree
WORKDIR /src
# Copy the repository source code
COPY . /src
# Build both source tarball and wheel from the source
RUN python -m build --sdist
RUN python -m build --wheel
# Install only the wheel to avoid conflicts with the sdist
RUN python -m pip install --no-cache-dir dist/*.whl
# Remove the source distribution tarball to keep the image clean
RUN rm -f dist/*.tar.gz
# Optional: clean up build artifacts to keep the final image small
# (the wheel is kept because it's installed)
RUN rm -rf Biopython.egg-info __pycache__ tests .tox \
*/__pycache__ */*.pyc
# Default command: quick import test to verify installation
CMD ["python", "-c", "import Bio; print(Bio.__version__)"]
Concerns: No .dockerignore is shown; building includes the full repo context which can slow down builds and introduce unnecessary files. Consider adding a dockerignore to exclude tests, docs, and VCS metadata., CMD runs a version print via Bio.__version__; if __version__ is not defined in a given Biopython release, this could fail. Consider a simpler import test or add a fallback., The image cleans up some build artifacts but retains the wheel in the image; this is fine for runtime, but if minimizing image size is critical, you could remove the wheel after installation (note: you’d need to reinstall from the wheel during tests).
Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'from Bio.Seq import Seq; s = Seq("ACGT"); print(str(s))
Output: sh: 1: Syntax error: Unterminated quoted stringFROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set workdir to build in source tree
WORKDIR /src
# Copy the repository source code
COPY . /src
# Build both source tarball and wheel from the source
RUN python -m build --sdist
RUN python -m build --wheel
# Install only the wheel to avoid conflicts with the sdist
RUN python -m pip install --no-cache-dir dist/*.whl
# Remove the source distribution tarball to keep the image clean
RUN rm -f dist/*.tar.gz
# Create a tiny verification script to avoid shell-quoting issues in CMD
RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"\
import Bio\nprint("Biopython version:", getattr(Bio, "__version__", "unknown"))\nPY' \
&& chmod +x /usr/local/bin/verify_bio.py
# Default command: run the verification script
CMD ["python", "/usr/local/bin/verify_bio.py"]
Concerns: The RUN command that creates /usr/local/bin/verify_bio.py attempts to embed a Python script by writing a here-doc with literal "\n" sequences. This will produce a syntax error in the produced Python file; the script content is not multi-line as required., The here-doc construction is malformed: using a backslash and an inline 'PY' delimiter inside a single-quoted Bash string can lead to the content being misformatted. Use a proper EOF heredoc without escaping, e.g.: cat > /usr/local/bin/verify_bio.py << 'PY'
import Bio
print("Biopython version:", getattr(Bio, "__version__", "unknown"))
PY, Potential fragility: If Biopython's __version__ is not exposed as Bio.__version__, the verification will print 'unknown'. It would be more robust to import and print Bio.__version__ directly or adapt the test to the actual packaging outcome.FROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set workdir to build in source tree
WORKDIR /src
# Copy the repository source code
COPY . /src
# Build both source tarball and wheel from the source
RUN python -m build --sdist
RUN python -m build --wheel
# Install only the wheel to avoid conflicts with the sdist
RUN python -m pip install --no-cache-dir dist/*.whl
# Remove the source distribution tarball to keep the image clean
RUN rm -f dist/*.tar.gz
# Add a simple verification script to run at container start
RUN printf '%s\n' 'import Bio' 'print("Biopython version:", getattr(Bio, "__version__", "unknown"))' > /usr/local/bin/verify_bio.py \
&& chmod +x /usr/local/bin/verify_bio.py
# Default command: run the verification script
CMD ["python", "/usr/local/bin/verify_bio.py"]
Smoke [FAIL]: python -c "import Bio; print('ok')
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c "from Bio.Seq import Seq; s = Seq('ACGT'); print(s.reverse_complement())
Output: sh: 1: Syntax error: Unterminated quoted stringFROM python:3.12.13-bookworm
# Build dependencies for Biopython (C extensions etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Upgrade packaging tools
RUN python -m pip install --upgrade pip setuptools wheel
# Set workdir and copy source
WORKDIR /src
COPY . /src
# Install the package from source (builds as needed)
RUN python -m pip install --no-cache-dir .
# Smoke test: verify import and version
CMD ["python", "-c", "import Bio; print(Bio.__version__)" ]
Concerns: Biopython's __version__ attribute may not be exposed as Bio.__version__ in all builds, which could cause the smoke test to fail if the version is not accessible., Python 3.12 compatibility for Biopython could be an issue; the package may require additional dependencies or face build issues with the C extensions on this Python version.
Smoke [FAIL]: python -c \"import Bio; print(Bio.__version_)\
Output: sh: 1: Syntax error: word unexpected (expecting ")")
Smoke [FAIL]: python -c \"from Bio.Seq import Seq; s = Seq('ACGT'); print(len(s))\
Output: sh: 1: Syntax error: "(" unexpectedFROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions,
# and other compilation needs)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Ensure modern packaging tools are available
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel
# Set build context
WORKDIR /src
# Copy source code
COPY . /src
# Build a wheel from source
RUN python -m build --wheel
# Install the wheel into the image
RUN python -m pip install --no-cache-dir dist/*.whl
# Clean up wheel after install to minimize image size (keep the installed package)
RUN rm -f dist/*.whl dist/*.tar.gz || true
# Verification script to ensure Bio is importable
RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"
import Bio
print("Biopython version:", getattr(Bio, "__version__", "unknown"))
PY' \
&& chmod +x /usr/local/bin/verify_bio.py
# Default command: run the verification script
CMD ["/usr/local/bin/verify_bio.py"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 1.08kB done
#1 DONE 0.1s
Dockerfile:29
--------------------
27 | # Verification script to ensure Bio is importable
28 | RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"
29 | >>> import Bio
30 | print("Biopython version:", getattr(Bio, "__version__", "unknown"))
31 | PY' \
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 29: unknown instruction: importFROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Packaging tooling
ENV PYTHONUNBUFFERED=1
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Build context
WORKDIR /src
# Copy source
COPY . /src
# Build wheel from source and install it
RUN python -m build --wheel
RUN python -m pip install --no-cache-dir dist/*.whl
# Clean up build artifacts
RUN rm -f dist/*.whl dist/*.tar.gz || true
# Verification: ensure Bio is importable and version is shown
CMD ["python", "-c", "import Bio; print(Bio.__version__)" ]
Concerns: Potential mismatch between Python headers and the Python runtime in the base image: the image installs build-essential and python3-dev, but the Python runtime comes from the official Python image (3.12). If headers don't match, building C extensions could fail; consider ensuring the dev headers match Python 3.12 (e.g., python3.12-dev) if available in the base image., BUILD context dependency: The wheel build relies on a valid packaging configuration (pyproject.toml or setup.cfg). If the repository being copied into /src lacks a proper build configuration, 'python -m build --wheel' will fail during docker build., Post-build verification depends on Biopython exposing Bio.__version__: while Biopython typically exposes __version__, if the source changes this may break the smoke test. The CMD relies on this attribute existing.
Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'import Bio.Seq; print("Bio.Seq loaded:", Bio.Seq.__name__)
Output: sh: 1: Syntax error: Unterminated quoted stringActionable summary of the tool output (pyproject.toml for Biopython):
- Build system
- requires = ["setuptools>=74.1", "wheel"]
- build-backend = "setuptools.build_meta"
- Project metadata
- name = "biopython"
- dynamic = ["version"]
- description, readme, license, license-files, license info
- requires-python = ">=3.10"
- authors: The Biopython Contributors
- classifiers include Production/Stable, OS Independent, Python 3.10–3.14, Bio-Informatics, etc.
- dependencies = ["numpy"]
- URLs
- Homepage, Documentation, Source, Tracker
- Packaging
- include-package-data = true
- zip-safe = false
- packages: long list of Bio.* packages (e.g., Bio, Bio.Affy, Bio.Align, Bio.AlignIO, Bio.Entrez, Bio.PDB, Bio.SeqIO, Bio.SeqUtils, Bio.SwissProt, Bio.TogoWS, Bio.Phylo, Bio.PopGen, BioSQL, etc.)
- Versioning
- [tool.setuptools.dynamic] version = {attr = "Bio.__version__"}
- C extensions (native modules)
- Bio.Align._aligncore → Bio/Align/_aligncore.c
- Bio.Align._alignmentcounts → Bio/Align/_alignmentcounts.c
- Bio.Align._codonaligner → Bio/Align/_codonaligner.c
- Bio.Align._pairwisealigner → Bio/Align/_pairwisealigner.c
- Bio.Align.substitution_matrices._arraycore → Bio/Align/substitution_matrices/_arraycore.c
- Bio.cpairwise2 → Bio/cpairwise2module.c
- Bio.Nexus.cnexus → Bio/Nexus/cnexus.c
- Bio.motifs._pwm → Bio/motifs/_pwm.c
- Bio.Cluster._cluster → Bio/Cluster/cluster.c, Bio/Cluster/clustermodule.c (extra-compile-args = ["-DCLUSTER_USE_PYTHON_MEMORY"])
- Bio.PDB.ccealign → Bio/PDB/ccealignmodule.c
- Bio.PDB.kdtrees → Bio/PDB/kdtrees.c
- Bio.PDB._bcif_helper → Bio/PDB/bcifhelpermodule.c
- Bio.SeqIO._twoBitIO → Bio/SeqIO/_twoBitIO.c
- More ext-modules exist (under the header “C extension modules using setuptools 74.1+ native support”)
- Dependency groups
- dev = ["setuptools>=74.1.0"]
Notes:
- Version is dynamically read from Bio.__version__.
- This is a full packaging manifest listing many top-level Bio.* packages and a substantial set of C extensions.FROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set build context
WORKDIR /src
# Copy source code
COPY . /src
# Build a wheel from source and install it
RUN python -m build --wheel
RUN python -m pip install --no-cache-dir dist/*.whl
# Clean up build artifacts
RUN rm -f dist/*.whl dist/*.tar.gz || true
# Verification script to ensure Bio is importable and version is shown
RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"
import Bio
print("Bio version:", getattr(Bio, "__version__", "unknown"))
PY' \
&& chmod +x /usr/local/bin/verify_bio.py
# Default command: run the verification script
CMD ["/usr/local/bin/verify_bio.py"]
#0 building with "default" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 DONE 0.0s
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile:
#1 transferring dockerfile: 1.03kB 0.0s done
#1 DONE 0.4s
Dockerfile:27
--------------------
25 | # Verification script to ensure Bio is importable and version is shown
26 | RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"
27 | >>> import Bio
28 | print("Bio version:", getattr(Bio, "__version__", "unknown"))
29 | PY' \
--------------------
ERROR: failed to build: failed to solve: dockerfile parse error on line 27: unknown instruction: importFROM python:3.12.13-bookworm
# System dependencies for building Biopython (C extensions, etc.)
RUN apt-get update \
&& apt-get install -y --no-install-recommends build-essential python3-dev \
&& rm -rf /var/lib/apt/lists/*
# Improve reliability: ensure build tooling is available via pip
RUN python -m pip install --upgrade pip setuptools wheel
RUN python -m pip install --upgrade build
# Set build context
WORKDIR /src
# Copy source code
COPY . /src
# Build a wheel from source and install it
RUN python -m build --wheel
RUN python -m pip install --no-cache-dir dist/*.whl
# Clean up build artifacts
RUN rm -f dist/*.whl dist/*.tar.gz || true
# Verification script to ensure Bio is importable and version is shown
RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"\
import Bio\nprint("Bio version:", getattr(Bio, "__version__", "unknown"))\nPY' \
&& chmod +x /usr/local/bin/verify_bio.py
# Default command: run the verification script
CMD ["/usr/local/bin/verify_bio.py"]
Summary (under 1500 chars)
- VerifyBuild status: build_failed
- Key contextual concerns
- Biopython build may require runtime/build dependencies (e.g., libbz2, zlib, NumPy headers). Ensure base image includes prerequisites or validate in CI.
- Tests rely on Bio.__version__; packaging changes or missing __version__ could mislead results. Consider corroborating with a submodule test (e.g., Bio.Seq).
- COPY . /src copies the entire repo; without a .dockerignore, build context can be large. Add .dockerignore to speed up builds and reduce image size.
- Build error (Docker)
- Exact error: process "/bin/sh -c bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY" ...' did not complete successfully: exit code: 2
- Real-time error lines:
- "bash: line 1: warning: here-document at line 1 delimited by end-of-file (wanted `PYimport')"
- "bash: -c: line 1: `cat > /usr/local/bin/verify_bio.py << "PY"import Bio\nprint("Bio version:", getattr(Bio, "__version__", "unknown"))\nPY'"
- Summary: the RUN failed due to a malformed here-document
- Failing command/step:
- Step: [10/10] RUN bash -lc 'cat > /usr/local/bin/verify_bio.py << "PY"\
import Bio\nprint("Bio version:", getattr(Bio, "__version__", "unknown"))\nPY' && chmod +x /usr/local/bin/verify_bio.py
- Issue: here-document was malformed, causing shell syntax error and exit code 2
- Missing packages/files: None reported; failure is caused by the malformed here-document, not a missing package/file
- Version mismatch info
- Base-image tag discrepancy observed early:
- #3 uses FROM docker.io/library/python:3.12-bookworm@sha256:...
- #4 uses FROM docker.io/library/python:3.12.13-bookworm@sha256:...
- Both resolve to the same digest: sha256:b06e8541b66390dbe26e635448bfa51b6dd15cdc4d79c5dfd9cacdac8ec5ab91
- This tag-digest mismatch could cause confusion about which Python minor version is in use.FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /src
# Install essential build tools and headers for compiling C extensions
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libbz2-dev \
zlib1g-dev \
liblzma-dev \
libssl-dev \
libffi-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Python packaging/build tools
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel build
# Copy source code and build from source
COPY . .
# Build sdist and wheel from source
RUN python -m build --sdist && python -m build --wheel
# Runtime stage
FROM python:3.12.13-bookworm
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /src/dist /dist
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install NumPy for runtime compatibility with Biopython
RUN python -m pip install --no-cache-dir numpy
# Install the built distribution wheels
RUN python -m pip install --no-cache-dir /dist/*.whl
# Smoke test to verify installation during image build
RUN python -c "import Bio, sys; print('Biopython installed, version:', Bio.__version__)"
# Default command: verify import at container start
CMD ["python", "-c", "import Bio, sys; print('Biopython version:', Bio.__version__)" ]
# Local development artifacts .git .github/ __pycache__/ *.pyc *.pyo *.pyd *.swp .DS_Store # Virtual environments and caches .venv/ venv/ ENV/ env/ .python-version # Build artifacts build/ dist/ *.egg-info/ # Tests and docs (excluded from build context to minimize context size) Tests/ Tests/* 测试/ doc/ docs/ Doc/ Doc/ # Node modules and other common noise node_modules/ .cache/ .pytest_cache/ .mypy_cache/ # Biopython docs build outputs (if any) _docs/
Concerns: Build context may be large since COPY . . copies the entire repository; consider using a .dockerignore to keep only necessary files., The runtime installation explicitly installs numpy before the Biopython wheel; ensure numpy version compatibility with Python 3.12 and Biopython; consider letting pip resolve dependencies automatically., The smoke test assumes Bio.__version__ is defined; if packaging changes, this could fail; a more robust test could verify import and existence of a known symbol. Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__) Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: python -c 'import Bio; print(Bio.__file__) Output: sh: 1: Syntax error: Unterminated quoted string
FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /src
# Install essential build tools and headers for compiling C extensions
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libbz2-dev \
zlib1g-dev \
liblzma-dev \
libssl-dev \
libffi-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Python packaging/build tools
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel build
# Copy source code and build from source
COPY . .
# Build sdist and wheel from source
RUN python -m build --sdist && python -m build --wheel
# Runtime stage
FROM python:3.12.13-bookworm
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /src/dist /dist
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install NumPy for runtime compatibility with Biopython
RUN python -m pip install --no-cache-dir numpy
# Install the built distribution wheels
RUN python -m pip install --no-cache-dir /dist/*.whl
# Smoke test to verify installation during image build
# The smoke test is performed by the CI VerifyBuild step; keep it lightweight
# and avoid complex shell quoting here.
RUN python -c "import Bio, sys; print('Biopython installed')"
# Default command: verify import at container start
CMD ["python", "-c", "import Bio, sys; print('Biopython version:', Bio.__version__)" ]
Concerns: No obvious syntax errors; build uses a dedicated builder stage and copies dist wheels to runtime stage., The runtime installs numpy unconditionally; if Biopython wheel already bundles dependencies, this could be redundant, but it's harmless., Optional: pin numpy version to ensure reproducible builds.
Smoke [FAIL]: python -c 'import Bio; print("Biopython version:", Bio.__version__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'import Bio; print("Biopython path:", Bio.__file__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'import sys; print("Python:", sys.version.split()[0])
Output: sh: 1: Syntax error: Unterminated quoted stringFROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /src
# Install essential build tools and headers for compiling C extensions
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libbz2-dev \
zlib1g-dev \
liblzma-dev \
libssl-dev \
libffi-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Python packaging/build tools
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel build
# Copy source code and build from source
COPY . .
# Build sdist and wheel from source
RUN python -m build --sdist && python -m build --wheel
# Runtime stage
FROM python:3.12.13-bookworm
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /src/dist /dist
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install NumPy for runtime compatibility with Biopython
RUN python -m pip install --no-cache-dir numpy
# Install the built distribution wheels
RUN python -m pip install --no-cache-dir /dist/*.whl
# Smoke test to verify installation without quoting issues
RUN python - <<'PY'
import Bio
print('Biopython installed, version:', Bio.__version__)
PY
# Default command: verify import at container start
CMD ["bash", "-lc", "python - <<'PY'\nimport Bio\nprint('Biopython version:', Bio.__version__)\nPY"]
Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__) Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: python -c 'from Bio import Entrez; print(Entrez.__name__) Output: sh: 1: Syntax error: Unterminated quoted string Smoke [FAIL]: python -c 'import Bio; print(Bio.__file__) Output: sh: 1: Syntax error: Unterminated quoted string
FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /src
# Install essential build tools and headers for compiling C extensions
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libbz2-dev \
zlib1g-dev \
liblzma-dev \
libssl-dev \
libffi-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Python packaging/build tools
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel build
# Copy source code and build from source
COPY . .
# Build sdist and wheel from source
RUN python -m build --sdist && python -m build --wheel
# Runtime stage
FROM python:3.12.13-bookworm
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /src/dist /dist
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install NumPy for runtime compatibility with Biopython
RUN python -m pip install --no-cache-dir numpy
# Install the built distribution wheels
RUN python -m pip install --no-cache-dir /dist/*.whl
# Lightweight smoke test to verify installation
RUN python -c "import Bio; print('Biopython installed, version:', Bio.__version__)"
# Default command: simple version print when container runs
CMD ["python", "-c", "import Bio; print('Biopython version:', Bio.__version__)" ]
Smoke [FAIL]: python -c \"import Bio; print('Biopython version:', Bio.__version__)\
Output: sh: 1: Syntax error: word unexpected (expecting ")")
Smoke [FAIL]: python -c \"import Bio.SeqIO; print('Bio.SeqIO loaded:', Bio.SeqIO.__name__)\
Output: sh: 1: Syntax error: word unexpected (expecting ")")
Smoke [FAIL]: python -c \"import Bio; import Bio.Seq; print('Bio.Seq loaded:', Bio.Seq.__name__)\
Output: sh: 1: Syntax error: word unexpected (expecting ")")FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /src
# Install essential build tools and headers for compiling C extensions
RUN apt-get update && \
apt-get install -y --no-install-recommends \
build-essential \
libbz2-dev \
zlib1g-dev \
liblzma-dev \
libssl-dev \
libffi-dev \
ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# Install Python packaging/build tools
RUN python -m pip install --no-cache-dir --upgrade pip setuptools wheel build
# Copy source code and build from source
COPY . .
# Build sdist and wheel from source
RUN python -m build --sdist && python -m build --wheel
# Runtime stage
FROM python:3.12.13-bookworm
ENV PYTHONUNBUFFERED=1
WORKDIR /app
# Copy built artifacts from builder
COPY --from=builder /src/dist /dist
# Install runtime dependencies
RUN apt-get update && \
apt-get install -y --no-install-recommends ca-certificates \
&& rm -rf /var/lib/apt/lists/*
# The wheel's dependencies (like numpy) will be installed automatically
RUN python -m pip install --no-cache-dir /dist/*.whl
# Lightweight verify script to confirm Biopython is importable
RUN printf "import Bio\nprint('Biopython version', Bio.__version__)\n" > /verify_bio.py
CMD ["python", "/verify_bio.py"]
Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__) Output: sh: 1: Syntax error: Unterminated quoted string
# syntax=docker/dockerfile:1
FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install build tools required for compiling C extensions (e.g., Biopython)
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends build-essential python3-dev; \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy the repository source
COPY . .
# Ensure build tooling is available
RUN python -m pip install --upgrade pip setuptools wheel build
# Build both source tarball and wheel from the repository
RUN python -m build --sdist
RUN python -m build --wheel
# Runtime stage
FROM python:3.12-slim-bookworm AS runtime
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Lightweight runtime: include only necessary system deps
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Bring in the built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built distribution(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Verification: a quick import to ensure the package is importable
RUN python -c "import Bio; print('Bio version:', Bio.__version__)"
# Default command: demonstrate a simple import of the library
CMD ["python", "-c", "import Bio; print(Bio.__version__)" ]
# Ignore Version Control .git .gitignore # Python artifacts __pycache__/ **/*.pyc **/*.pyo **/*.pyd *.egg-info/ dist/ build/ *.whl *.tar.gz # Tests and docs Tests/ Bio/tests/ Doc/ Docs/ docs/_build/ Doc/_build/ # Virtual environments venv/ env/ ENV/ # IDEs and editors .kakoune-setup .vscode/ *.swp *.swo # OS files .DS_Store Thumbs.db
Smoke [FAIL]: python -c 'import Bio; print("Bio version:", Bio.__version__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'from Bio.Seq import Seq; s = Seq("ACG"); print(s)
Output: sh: 1: Syntax error: Unterminated quoted string# syntax=docker/dockerfile:1
FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install build tools required for compiling C extensions (e.g., Biopython)
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends build-essential python3-dev; \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy the repository source
COPY . .
# Ensure build tooling is available
RUN python -m pip install --upgrade pip setuptools wheel build
# Build both source tarball and wheel from the repository
RUN python -m build --sdist
RUN python -m build --wheel
# Runtime stage
FROM python:3.12-slim-bookworm AS runtime
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Lightweight runtime: include only necessary system deps
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Bring in the built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built distribution(s)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Verification: a quick import to ensure the package is importable
RUN python -c "import Bio; print('Bio version:', Bio.__version__)"
# Default command: demonstrate a simple import of the library
CMD ["python", "-c", "import Bio; print(Bio.__version__)"]
Smoke [FAIL]: python -c 'import Bio; print("Bio version:", Bio.__version__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'from Bio import Seq; print("Seq module loaded:", Seq.__name__)
Output: sh: 1: Syntax error: Unterminated quoted string# syntax=docker/dockerfile:1
FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install build tools required for compiling C extensions (e.g., Biopython)
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends build-essential python3-dev; \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy the repository source
COPY . .
# Ensure build tooling is available
RUN python -m pip install --upgrade pip setuptools wheel build
# Build both source tarball and wheel from the repository
RUN python -m build --sdist
RUN python -m build --wheel
# Runtime stage
FROM python:3.12-slim-bookworm AS runtime
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Lightweight runtime: include only necessary system deps
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy the repository into the runtime and install in editable mode
COPY --from=builder /src /app
# Install the repository in editable mode so imports resolve cleanly in this environment
RUN python -m pip install --no-cache-dir -e /app
# Verification: a quick import to ensure the package is importable
RUN python -c "import Bio; print('Bio version:', Bio.__version__)"
# Default command: demonstrate a simple import of the library
CMD ["python", "-c", "import Bio; print(Bio.__version__)"]
Actionable summary
- Status: build_failed
- Concerns
- Potential reliance on Bio.__version__ being defined; may break if packaging changes.
- Editable install (-e /app) may fail if package metadata changes.
- Build error
- Exit code: 1
- Error: command 'gcc' failed: No such file or directory
- Context: Building editable for biopython (pyproject.toml) did not run successfully
- Failing command/step
- Failing step: [runtime 5/6] RUN python -m pip install --no-cache-dir -e /app
- Core: editable install of the app (Biopython) triggers building from source and compiling C extensions; gcc missing in runtime
- Missing packages/files
- GCC/build tools missing in the runtime image (No such file or directory: gcc)
- Biopython native extensions could not be compiled
- Builder stage had build tools, but final runtime image does not
- Version mismatch information
- Runtime base: python:3.12-slim-bookworm
- Build artifact: Biopython 1.87.dev0 (editable install from /app)
- Python ABI: cp312 (Python 3.12)
- NumPy wheel: numpy-2.4.3-cp312-cp312-manylinux_2_27_x86_64.whl
- Multi-stage: builder vs runtime environments; builder tools not present in runtime
- What happened, succinctly
- Editable install attempts to build Biopython from source; runtime image lacks gcc, so the pip install fails with exit code 1
- Quick fixes you can apply
- Install build tools in the runtime image:
- apt-get update && apt-get install -y --no-install-recommends build-essential gcc
- Also install common dev packages if needed:
- apt-get install -y --no-install-recommends python3-dev libffi-dev zlib1g-dev libxml2-dev
- Alternatively avoid editable install:
- Use a prebuilt Biopython wheel from PyPI or perform a non-editable install
- Ensure consistency between builder and runtime (or consolidate to a single stage that includes build tools)# syntax=docker/dockerfile:1
FROM python:3.12.13-bookworm AS builder
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Install build tools required for compiling C extensions (e.g., Biopython)
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends build-essential python3-dev; \
rm -rf /var/lib/apt/lists/*
WORKDIR /src
# Copy the repository source
COPY . .
# Ensure build tooling is available
RUN python -m pip install --upgrade pip setuptools wheel build
# Build both source tarball and wheel from the repository
RUN python -m build --sdist
RUN python -m build --wheel
# Runtime stage
FROM python:3.12-slim-bookworm AS runtime
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
# Lightweight runtime: include only necessary system deps
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends ca-certificates; \
rm -rf /var/lib/apt/lists/*
WORKDIR /app
# Copy built artifacts from the builder
COPY --from=builder /src/dist /dist
# Install the built distribution(s) (no editable install)
RUN python -m pip install --no-cache-dir /dist/*.whl
# Verification: a quick import to ensure the package is importable
RUN python -c "import Bio; print('Bio version:', Bio.__version__)"
# Default command: demonstration of importing Bio
CMD ["python", "-c", "import Bio; print(Bio.__version__)"]
Smoke [FAIL]: python -c 'import Bio; print(Bio.__version__)
Output: sh: 1: Syntax error: Unterminated quoted string
Smoke [FAIL]: python -c 'import Bio; from Bio.Seq import Seq; s = Seq("ACGT"); print(len(s))
Output: sh: 1: Syntax error: Unterminated quoted string