From 045e9e4d938c22e869f357dd34ccee93ef6c1784 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Thu, 8 Sep 2022 04:25:35 -0700 Subject: [PATCH] Manual Backport PR #48427 on branch 1.5.x (BLD: Refactor Dockerfile to not install dev enviornment on base) (#48450) Backport PR #48427: BLD: Refactor Dockerfile to not install dev enviornment on base --- .github/workflows/code-checks.yml | 3 +++ Dockerfile | 22 +++++-------------- .../development/contributing_environment.rst | 10 +++++++++ doc/source/whatsnew/v1.5.0.rst | 1 + 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index c9c5058fb365c..6aff77c708378 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -153,6 +153,9 @@ jobs: - name: Build image run: docker build --pull --no-cache --tag pandas-dev-env . + - name: Show environment + run: docker run -w /home/pandas pandas-dev-env mamba run -n pandas-dev python -c "import pandas as pd; print(pd.show_versions())" + requirements-dev-text-installable: name: Test install requirements-dev.txt runs-on: ubuntu-latest diff --git a/Dockerfile b/Dockerfile index 02c360d2f3d49..9de8695b24274 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM quay.io/condaforge/mambaforge:4.13.0-1 +FROM quay.io/condaforge/mambaforge # if you forked pandas, you can pass in your own GitHub username to use your fork # i.e. gh_username=myname @@ -10,16 +10,12 @@ ENV DEBIAN_FRONTEND=noninteractive # Configure apt and install packages RUN apt-get update \ - && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ + && apt-get -y install --no-install-recommends apt-utils git tzdata dialog 2>&1 \ # - # Install tzdata and configure timezone (fix for tests which try to read from "/etc/localtime") - && apt-get -y install tzdata \ + # Configure timezone (fix for tests which try to read from "/etc/localtime") && ln -fs /usr/share/zoneinfo/Etc/UTC /etc/localtime \ && dpkg-reconfigure -f noninteractive tzdata \ # - # Verify git, process tools, lsb-release (common in install instructions for CLIs) installed - && apt-get -y install git iproute2 procps iproute2 lsb-release \ - # # cleanup && apt-get autoremove -y \ && apt-get clean -y \ @@ -35,18 +31,12 @@ RUN mkdir "$pandas_home" \ && git remote add upstream "https://github.com/pandas-dev/pandas.git" \ && git pull upstream main -# Because it is surprisingly difficult to activate a conda environment inside a DockerFile -# (from personal experience and per https://github.com/ContinuumIO/docker-images/issues/89), -# we just update the base/root one from the 'environment.yml' file instead of creating a new one. -# # Set up environment -RUN mamba env update -n base -f "$pandas_home/environment.yml" +RUN mamba env create -f "$pandas_home/environment.yml" # Build C extensions and pandas -SHELL ["/bin/bash", "-c"] -RUN . /opt/conda/etc/profile.d/conda.sh \ - && conda activate base \ - && cd "$pandas_home" \ +SHELL ["mamba", "run", "--no-capture-output", "-n", "pandas-dev", "/bin/bash", "-c"] +RUN cd "$pandas_home" \ && export \ && python setup.py build_ext -j 4 \ && python -m pip install --no-build-isolation -e . diff --git a/doc/source/development/contributing_environment.rst b/doc/source/development/contributing_environment.rst index c881770aa7584..9e6da887671bd 100644 --- a/doc/source/development/contributing_environment.rst +++ b/doc/source/development/contributing_environment.rst @@ -38,6 +38,16 @@ Run Container:: # Run a container and bind your local repo to the container docker run -it -w /home/pandas --rm -v path-to-local-pandas-repo:/home/pandas pandas-yourname-env +Then a ``pandas-dev`` virtual environment will be available with all the development dependencies. + +.. code-block:: shell + + root@... :/home/pandas# conda env list + # conda environments: + # + base * /opt/conda + pandas-dev /opt/conda/envs/pandas-dev + .. note:: If you bind your local repo for the first time, you have to build the C extensions afterwards. Run the following command inside the container:: diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index af0ba1bd75124..d8a319da2065e 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -332,6 +332,7 @@ Other enhancements - 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`) - :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`) - The method :meth:`.ExtensionArray.factorize` accepts ``use_na_sentinel=False`` for determining how null values are to be treated (:issue:`46601`) +- The ``Dockerfile`` now installs a dedicated ``pandas-dev`` virtual environment for pandas development instead of using the ``base`` environment (:issue:`48427`) .. --------------------------------------------------------------------------- .. _whatsnew_150.notable_bug_fixes: