Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker build with workspace package #7936

Closed
idinsmore1 opened this issue Oct 4, 2024 · 2 comments
Closed

Docker build with workspace package #7936

idinsmore1 opened this issue Oct 4, 2024 · 2 comments
Labels
question Asking for clarification or support

Comments

@idinsmore1
Copy link

Thanks for such an amazing tool in uv, it has been an awesome addition in my work as an analyst in academic research. I'm trying to build out a docker image of the workspace using the docker guide in the docs, but I'm running into the following error while trying to build the image.

docker build . 
 > [stage-0 5/7] RUN --mount=type=cache,target=/root/.cache/uv     --mount=type=bind,source=uv.lock,target=uv.lock     --mount=type=bind,source=pyproject.toml,target=pyproject.toml     uv sync --frozen --no-install-project --no-install-workspace --compile-bytecode:
#10 5.139 Using CPython 3.11.10
#10 5.139 Creating virtual environment at: .venv
#10 8.494 error: Failed to prepare distributions
#10 8.494   Caused by: Failed to fetch wheel: dracopy==1.4.0
#10 8.494   Caused by: Build backend failed to determine requirements with `build_wheel()` (exit status: 1)
#10 8.494 --- stdout:
#10 8.494
#10 8.494 --- stderr:
#10 8.494 Traceback (most recent call last):
#10 8.494   File "<string>", line 14, in <module>
#10 8.494   File "/root/.cache/uv/builds-v0/.tmpVvUWy6/lib/python3.11/site-packages/setuptools/build_meta.py", line 332, in get_requires_for_build_wheel
#10 8.494     return self._get_build_requires(config_settings, requirements=[])
#10 8.494            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#10 8.494   File "/root/.cache/uv/builds-v0/.tmpVvUWy6/lib/python3.11/site-packages/setuptools/build_meta.py", line 302, in _get_build_requires
#10 8.494     self.run_setup()
#10 8.494   File "/root/.cache/uv/builds-v0/.tmpVvUWy6/lib/python3.11/site-packages/setuptools/build_meta.py", line 503, in run_setup
#10 8.494     super().run_setup(setup_script=setup_script)
#10 8.494   File "/root/.cache/uv/builds-v0/.tmpVvUWy6/lib/python3.11/site-packages/setuptools/build_meta.py", line 318, in run_setup
#10 8.494     exec(code, locals())
#10 8.494   File "<string>", line 6, in <module>
#10 8.494 ModuleNotFoundError: No module named 'skbuild'
#10 8.494 ---
------
executor failed running [/bin/sh -c uv sync --frozen --no-install-project --no-install-workspace --compile-bytecode]: exit code: 2

My workspace looks like this:

├── Dockerfile
├── LICENSE
├── README.md
├── packages
│   ├── mircat-seg
│   │   ├── README.md
│   │   ├── pyproject.toml
│   │   └── src
│   │       └── mircat_seg
│   │           ├── __init__.py
│   │           ├── core.py
│   │           └── models
│   │               └── __init__.py
│   └── mircat-stats
│       ├── Dockerfile
│       ├── README.md
│       ├── pyproject.toml
│       └── src
│           └── mircat_stats
│               ├── __init__.py
│               ├── configs
│               │   ├── __init__.py
│               │   ├── logging.py
│               │   ├── models.py
│               │   └── statistics.py
│               ├── dicom
│               │   ├── __init__.py
│               │   └── dicom_folder.py
│               ├── models
│               │   ├── __init__.py
│               │   └── xgboost.json
│               └── statistics
│                   ├── __init__.py
│                   ├── aorta.py
│                   ├── body_and_tissues.py
│                   ├── centerline.py
│                   ├── contrast_detection.py
│                   ├── cpr.py
│                   ├── nifti.py
│                   ├── total.py
│                   └── utils.py
├── pyproject.toml
├── src
│   └── mircat
│       └── __init__.py
└── uv.lock

My root pyproject.toml:

[project]
name = "mircat"
version = "0.1.1"
description = "write description here"
readme = "README.md"
requires-python = ">=3.10,<3.12"
dependencies = [
    "loguru>=0.7.2",
    "nibabel>=5.2.1",
    "numpy==1.26",
    "scipy==1.13.1",
    "threadpoolctl>=3.5.0",
    "mircat-seg",
    "mircat-stats",
    "scikit-build>=0.18.1",
]

[project.scripts]
mircat = "mircat:mircat"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.uv.sources]
mircat-seg = { workspace = true }
mircat-stats = { workspace = true }

[tool.uv.workspace]
members = ["packages/mircat-seg", "packages/mircat-stats"]

and finally my Dockerfile

FROM ubuntu:oracular

COPY --from=ghcr.io/astral-sh/uv:0.4.18 /uv /bin/uv

# Change the working directory to the `app` directory
RUN apt-get update && \
    apt-get install -y clang gcc g++ python3-dev && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

WORKDIR /app

# Install dependencies
RUN --mount=type=cache,target=/root/.cache/uv \
    --mount=type=bind,source=uv.lock,target=uv.lock \
    --mount=type=bind,source=pyproject.toml,target=pyproject.toml \
    uv sync --frozen --no-install-project --no-install-workspace --compile-bytecode

# Copy the project into the image
ADD . /app

# Sync the project
RUN --mount=type=cache,target=/root/.cache/uv \
    && uv sync --frozen

ENTRYPOINT ["uv", "run", "mircat"]

Any ideas on a solution would be great. Thanks!

@zanieb
Copy link
Member

zanieb commented Oct 4, 2024

It looks like that version of Dracopy does not define skbuild as a build requirement but imports it: https://inspector.pypi.io/project/dracopy/1.4.0/packages/40/dc/fc22bdbe29fc9ecc7232f55253e7d6419be5b28ca77eb2e9f9cd9fac321c/DracoPy-1.4.0.tar.gz/DracoPy-1.4.0/setup.py#line.6

Hence, when we attempt to build that project in an isolated environment we see the error:

ModuleNotFoundError: No module named 'skbuild'

Is there a newer version of that package that properly declares its dependencies? If not you'll need to disable build isolation and manually install its build dependencies beforehand (i.e. uv pip install skbuild && uv sync --no-build-isolation-package dracopy).

See more details about build isolation https://docs.astral.sh/uv/pip/compatibility/#pep-517-build-isolation (and #2252)

@zanieb zanieb added the question Asking for clarification or support label Oct 4, 2024
@idinsmore1
Copy link
Author

Weirdly enough, this seems to be an issue of trying to build the image on an M1 Mac vs. on a Linux machine. DracoPy doesn't properly pull it's pre-built wheel when I attempt to build the image on Mac and tries to build from source (where the error is happening), but it works just fine when I build the image on my Ubuntu machine, with the same base image used on both. Thanks so much for your help and quick response, this is good to know for the future!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Asking for clarification or support
Projects
None yet
Development

No branches or pull requests

2 participants