Skip to content

Commit 8b42d67

Browse files
Backport PR #49981 on branch 1.5.x (Streamline docker usage) (#50421)
Backport PR #49981: Streamline docker usage Co-authored-by: William Ayd <[email protected]>
1 parent 16bd414 commit 8b42d67

File tree

4 files changed

+21
-63
lines changed

4 files changed

+21
-63
lines changed

.devcontainer.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
// You can edit these settings after create using File > Preferences > Settings > Remote.
1010
"settings": {
1111
"terminal.integrated.shell.linux": "/bin/bash",
12-
"python.condaPath": "/opt/conda/bin/conda",
13-
"python.pythonPath": "/opt/conda/bin/python",
12+
"python.pythonPath": "/usr/local/bin/python",
1413
"python.formatting.provider": "black",
1514
"python.linting.enabled": true,
1615
"python.linting.flake8Enabled": true,

.github/workflows/code-checks.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152
run: docker build --pull --no-cache --tag pandas-dev-env .
153153

154154
- name: Show environment
155-
run: docker run -w /home/pandas pandas-dev-env mamba run -n pandas-dev python -c "import pandas as pd; print(pd.show_versions())"
155+
run: docker run --rm pandas-dev-env python -c "import pandas as pd; print(pd.show_versions())"
156156

157157
requirements-dev-text-installable:
158158
name: Test install requirements-dev.txt

Dockerfile

+10-39
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,13 @@
1-
FROM quay.io/condaforge/mambaforge
1+
FROM python:3.10.8
2+
WORKDIR /home/pandas
23

3-
# if you forked pandas, you can pass in your own GitHub username to use your fork
4-
# i.e. gh_username=myname
5-
ARG gh_username=pandas-dev
6-
ARG pandas_home="/home/pandas"
4+
RUN apt-get update && apt-get -y upgrade
5+
RUN apt-get install -y build-essential
76

8-
# Avoid warnings by switching to noninteractive
9-
ENV DEBIAN_FRONTEND=noninteractive
7+
# hdf5 needed for pytables installation
8+
RUN apt-get install -y libhdf5-dev
109

11-
# Configure apt and install packages
12-
RUN apt-get update \
13-
&& apt-get -y install --no-install-recommends apt-utils git tzdata dialog 2>&1 \
14-
#
15-
# Configure timezone (fix for tests which try to read from "/etc/localtime")
16-
&& ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \
17-
&& dpkg-reconfigure -f noninteractive tzdata \
18-
#
19-
# cleanup
20-
&& apt-get autoremove -y \
21-
&& apt-get clean -y \
22-
&& rm -rf /var/lib/apt/lists/*
23-
24-
# Switch back to dialog for any ad-hoc use of apt-get
25-
ENV DEBIAN_FRONTEND=dialog
26-
27-
# Clone pandas repo
28-
RUN mkdir "$pandas_home" \
29-
&& git clone "https://github.com/$gh_username/pandas.git" "$pandas_home" \
30-
&& cd "$pandas_home" \
31-
&& git remote add upstream "https://github.com/pandas-dev/pandas.git" \
32-
&& git pull upstream main
33-
34-
# Set up environment
35-
RUN mamba env create -f "$pandas_home/environment.yml"
36-
37-
# Build C extensions and pandas
38-
SHELL ["mamba", "run", "--no-capture-output", "-n", "pandas-dev", "/bin/bash", "-c"]
39-
RUN cd "$pandas_home" \
40-
&& export \
41-
&& python setup.py build_ext -j 4 \
42-
&& python -m pip install --no-build-isolation -e .
10+
RUN python -m pip install --upgrade pip
11+
RUN python -m pip install --use-deprecated=legacy-resolver \
12+
-r https://raw.githubusercontent.com/pandas-dev/pandas/main/requirements-dev.txt
13+
CMD ["/bin/bash"]

doc/source/development/contributing_environment.rst

+9-21
Original file line numberDiff line numberDiff line change
@@ -216,34 +216,22 @@ with a full pandas development environment.
216216

217217
Build the Docker image::
218218

219-
# Build the image pandas-yourname-env
220-
docker build --tag pandas-yourname-env .
221-
# Or build the image by passing your GitHub username to use your own fork
222-
docker build --build-arg gh_username=yourname --tag pandas-yourname-env .
219+
# Build the image
220+
docker build -t pandas-dev .
223221

224222
Run Container::
225223

226224
# Run a container and bind your local repo to the container
227-
docker run -it -w /home/pandas --rm -v path-to-local-pandas-repo:/home/pandas pandas-yourname-env
225+
# This command assumes you are running from your local repo
226+
# but if not alter ${PWD} to match your local repo path
227+
docker run -it --rm -v ${PWD}:/home/pandas pandas-dev
228228

229-
Then a ``pandas-dev`` virtual environment will be available with all the development dependencies.
229+
When inside the running container you can build and install pandas the same way as the other methods
230230

231-
.. code-block:: shell
232-
233-
root@... :/home/pandas# conda env list
234-
# conda environments:
235-
#
236-
base * /opt/conda
237-
pandas-dev /opt/conda/envs/pandas-dev
238-
239-
.. note::
240-
If you bind your local repo for the first time, you have to build the C extensions afterwards.
241-
Run the following command inside the container::
242-
243-
python setup.py build_ext -j 4
231+
.. code-block:: bash
244232
245-
You need to rebuild the C extensions anytime the Cython code in ``pandas/_libs`` changes.
246-
This most frequently occurs when changing or merging branches.
233+
python setup.py build_ext -j 4
234+
python -m pip install -e . --no-build-isolation --no-use-pep517
247235
248236
*Even easier, you can integrate Docker with the following IDEs:*
249237

0 commit comments

Comments
 (0)