Skip to content
This repository was archived by the owner on Sep 29, 2025. It is now read-only.

Commit ba09852

Browse files
committed
fix(pems_streamlit): use package dependency on pems_data
using a file: dependency on pems_data doesn't work during Docker build time since we 1) don't copy the pems_data source for the install stage, and 2) we don't copy the .git directory either -- nor do we want to copy either of these instead, use a normal package dependency during Docker build and build and download both local packages and all dependencies into a 'wheelhouse' for install update CI to install all 3 packages for tests
1 parent 80f8422 commit ba09852

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

.devcontainer/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ RUN pip install .[dev,test]
5555
RUN pip install --no-cache-dir -r docs/requirements.txt
5656

5757
# install source packages as editable
58-
# install pems_data separately, and last, to ensure it installs in editable mode
59-
# and not as a normal package from the dependencies declared in the other packages
60-
RUN pip install -e ./pems_streamlit -e ./pems_web && pip install -e ./pems_data
58+
# install pems_data first, to ensure it installs as a
59+
# package from the dependencies declared in the other packages
60+
RUN pip install -e ./pems_data -e ./pems_streamlit -e ./pems_web

.github/workflows/tests-pytest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Install Python dependencies
2727
run: |
28-
pip install .[test] ./pems_streamlit ./pems_web
28+
pip install .[test] ./pems_data ./pems_streamlit ./pems_web
2929
3030
- name: Run tests
3131
run: ./tests/pytest/run.sh

pems_streamlit/container/Dockerfile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,17 @@ ARG PYTHON_VERSION=3.12
77
FROM python:${PYTHON_VERSION} AS build_wheel
88
WORKDIR /build
99

10-
# upgrade pip, install build dependencies
11-
RUN python -m pip install --upgrade pip build setuptools_scm
10+
# install build tools
11+
RUN python -m pip install --upgrade pip wheel setuptools_scm
1212

1313
# copy source files
1414
COPY . .
1515
RUN git config --global --add safe.directory /build
1616

17-
# Move into directory to run the build
18-
WORKDIR /build/pems_streamlit
19-
20-
# build package
21-
RUN python -m build
17+
# build wheels for local packages AND downloads
18+
# wheels for all their dependencies from PyPI
19+
# creating a "wheelhouse"
20+
RUN pip wheel --wheel-dir /wheels ./pems_data ./pems_streamlit
2221

2322
# multi-stage build
2423
#
@@ -54,8 +53,11 @@ WORKDIR /$USER/app
5453
COPY .streamlit .streamlit
5554
COPY pems_streamlit/container/entrypoint.sh entrypoint.sh
5655
COPY pems_streamlit/container/run.py run.py
57-
COPY --from=build_wheel /build/pems_streamlit/dist /wheels
5856

59-
RUN pip install $(find /wheels -name pems_streamlit*.whl)
57+
# copy the entire, now-complete wheelhouse from the build stage
58+
COPY --from=build_wheel /wheels /wheels
59+
60+
# install pems_streamlit using only the local wheels directory
61+
RUN pip install --no-index --find-links=/wheels pems_streamlit
6062

6163
ENTRYPOINT ["./entrypoint.sh"]

pems_streamlit/pyproject.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ dynamic = ["version"]
55
requires-python = ">=3.12"
66
dependencies = [
77
"django==5.2.3",
8-
"pems_data @ file:./pems_data",
8+
# local package reference
9+
# a wheel for this package is built during Docker build
10+
"pems_data",
911
"streamlit==1.45.1",
1012
]
1113

0 commit comments

Comments
 (0)