Skip to content

Commit 9e6bbde

Browse files
authored
Streamline docker usage (#49981)
* Streamline docker usage * Updated CI * newline * update python.pythonpath in devcontainer.json Co-authored-by: MarcoGorelli <>
1 parent 39e0964 commit 9e6bbde

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
@@ -158,7 +158,7 @@ jobs:
158158
run: docker build --pull --no-cache --tag pandas-dev-env .
159159

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

163163
requirements-dev-text-installable:
164164
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
@@ -228,34 +228,22 @@ with a full pandas development environment.
228228

229229
Build the Docker image::
230230

231-
# Build the image pandas-yourname-env
232-
docker build --tag pandas-yourname-env .
233-
# Or build the image by passing your GitHub username to use your own fork
234-
docker build --build-arg gh_username=yourname --tag pandas-yourname-env .
231+
# Build the image
232+
docker build -t pandas-dev .
235233

236234
Run Container::
237235

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

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

243-
.. code-block:: shell
244-
245-
root@... :/home/pandas# conda env list
246-
# conda environments:
247-
#
248-
base * /opt/conda
249-
pandas-dev /opt/conda/envs/pandas-dev
250-
251-
.. note::
252-
If you bind your local repo for the first time, you have to build the C extensions afterwards.
253-
Run the following command inside the container::
254-
255-
python setup.py build_ext -j 4
243+
.. code-block:: bash
256244
257-
You need to rebuild the C extensions anytime the Cython code in ``pandas/_libs`` changes.
258-
This most frequently occurs when changing or merging branches.
245+
python setup.py build_ext -j 4
246+
python -m pip install -e . --no-build-isolation --no-use-pep517
259247
260248
*Even easier, you can integrate Docker with the following IDEs:*
261249

0 commit comments

Comments
 (0)