Skip to content

Commit 045e9e4

Browse files
authored
Manual Backport PR pandas-dev#48427 on branch 1.5.x (BLD: Refactor Dockerfile to not install dev enviornment on base) (pandas-dev#48450)
Backport PR pandas-dev#48427: BLD: Refactor Dockerfile to not install dev enviornment on base
1 parent 4226f42 commit 045e9e4

File tree

4 files changed

+20
-16
lines changed

4 files changed

+20
-16
lines changed

.github/workflows/code-checks.yml

+3
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,9 @@ jobs:
153153
- name: Build image
154154
run: docker build --pull --no-cache --tag pandas-dev-env .
155155

156+
- name: Show environment
157+
run: docker run -w /home/pandas pandas-dev-env mamba run -n pandas-dev python -c "import pandas as pd; print(pd.show_versions())"
158+
156159
requirements-dev-text-installable:
157160
name: Test install requirements-dev.txt
158161
runs-on: ubuntu-latest

Dockerfile

+6-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM quay.io/condaforge/mambaforge:4.13.0-1
1+
FROM quay.io/condaforge/mambaforge
22

33
# if you forked pandas, you can pass in your own GitHub username to use your fork
44
# i.e. gh_username=myname
@@ -10,16 +10,12 @@ ENV DEBIAN_FRONTEND=noninteractive
1010

1111
# Configure apt and install packages
1212
RUN apt-get update \
13-
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
13+
&& apt-get -y install --no-install-recommends apt-utils git tzdata dialog 2>&1 \
1414
#
15-
# Install tzdata and configure timezone (fix for tests which try to read from "/etc/localtime")
16-
&& apt-get -y install tzdata \
15+
# Configure timezone (fix for tests which try to read from "/etc/localtime")
1716
&& ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \
1817
&& dpkg-reconfigure -f noninteractive tzdata \
1918
#
20-
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
21-
&& apt-get -y install git iproute2 procps iproute2 lsb-release \
22-
#
2319
# cleanup
2420
&& apt-get autoremove -y \
2521
&& apt-get clean -y \
@@ -35,18 +31,12 @@ RUN mkdir "$pandas_home" \
3531
&& git remote add upstream "https://github.com/pandas-dev/pandas.git" \
3632
&& git pull upstream main
3733

38-
# Because it is surprisingly difficult to activate a conda environment inside a DockerFile
39-
# (from personal experience and per https://github.com/ContinuumIO/docker-images/issues/89),
40-
# we just update the base/root one from the 'environment.yml' file instead of creating a new one.
41-
#
4234
# Set up environment
43-
RUN mamba env update -n base -f "$pandas_home/environment.yml"
35+
RUN mamba env create -f "$pandas_home/environment.yml"
4436

4537
# Build C extensions and pandas
46-
SHELL ["/bin/bash", "-c"]
47-
RUN . /opt/conda/etc/profile.d/conda.sh \
48-
&& conda activate base \
49-
&& cd "$pandas_home" \
38+
SHELL ["mamba", "run", "--no-capture-output", "-n", "pandas-dev", "/bin/bash", "-c"]
39+
RUN cd "$pandas_home" \
5040
&& export \
5141
&& python setup.py build_ext -j 4 \
5242
&& python -m pip install --no-build-isolation -e .

doc/source/development/contributing_environment.rst

+10
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ Run Container::
3838
# Run a container and bind your local repo to the container
3939
docker run -it -w /home/pandas --rm -v path-to-local-pandas-repo:/home/pandas pandas-yourname-env
4040

41+
Then a ``pandas-dev`` virtual environment will be available with all the development dependencies.
42+
43+
.. code-block:: shell
44+
45+
root@... :/home/pandas# conda env list
46+
# conda environments:
47+
#
48+
base * /opt/conda
49+
pandas-dev /opt/conda/envs/pandas-dev
50+
4151
.. note::
4252
If you bind your local repo for the first time, you have to build the C extensions afterwards.
4353
Run the following command inside the container::

doc/source/whatsnew/v1.5.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ Other enhancements
332332
- Added ``copy`` keyword to :meth:`Series.set_axis` and :meth:`DataFrame.set_axis` to allow user to set axis on a new object without necessarily copying the underlying data (:issue:`47932`)
333333
- :meth:`DataFrame.set_index` now supports a ``copy`` keyword. If ``False``, the underlying data is not copied when a new :class:`DataFrame` is returned (:issue:`48043`)
334334
- The method :meth:`.ExtensionArray.factorize` accepts ``use_na_sentinel=False`` for determining how null values are to be treated (:issue:`46601`)
335+
- The ``Dockerfile`` now installs a dedicated ``pandas-dev`` virtual environment for pandas development instead of using the ``base`` environment (:issue:`48427`)
335336

336337
.. ---------------------------------------------------------------------------
337338
.. _whatsnew_150.notable_bug_fixes:

0 commit comments

Comments
 (0)