From 0a5338f506f39c07a40ca1a24ee138c156be28b6 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 6 Sep 2022 10:38:54 -0700 Subject: [PATCH 1/4] Use mamba run to activate environment --- Dockerfile | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/Dockerfile b/Dockerfile index 02c360d2f3d49..bd23855a50795 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN apt-get update \ && 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 \ + && apt-get -y install git iproute2 procps lsb-release \ # # cleanup && apt-get autoremove -y \ @@ -35,18 +35,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", "-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 . From 2d5468675ed668a68102406fb1a5127e44fa79d6 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Tue, 6 Sep 2022 19:12:51 -0700 Subject: [PATCH 2/4] Documented changes; test pd.show_verions() in env --- .github/workflows/code-checks.yml | 3 +++ Dockerfile | 12 ++++-------- doc/source/development/contributing_environment.rst | 10 ++++++++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index c9c5058fb365c..5857b38324951 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 -it -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 bd23855a50795..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 lsb-release \ - # # cleanup && apt-get autoremove -y \ && apt-get clean -y \ @@ -39,7 +35,7 @@ RUN mkdir "$pandas_home" \ RUN mamba env create -f "$pandas_home/environment.yml" # Build C extensions and pandas -SHELL ["mamba", "run", "-n", "pandas-dev", "/bin/bash", "-c"] +SHELL ["mamba", "run", "--no-capture-output", "-n", "pandas-dev", "/bin/bash", "-c"] RUN cd "$pandas_home" \ && export \ && python setup.py build_ext -j 4 \ diff --git a/doc/source/development/contributing_environment.rst b/doc/source/development/contributing_environment.rst index 070e6d2892bc8..c7613b4744719 100644 --- a/doc/source/development/contributing_environment.rst +++ b/doc/source/development/contributing_environment.rst @@ -237,6 +237,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:: From 8796c9d4b5ec4494641357c5415f75f9fff2134b Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 7 Sep 2022 09:09:48 -0700 Subject: [PATCH 3/4] Don't need interactive --- .github/workflows/code-checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 5857b38324951..6aff77c708378 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -154,7 +154,7 @@ jobs: run: docker build --pull --no-cache --tag pandas-dev-env . - name: Show environment - run: docker run -it -w /home/pandas pandas-dev-env mamba run -n pandas-dev python -c "import pandas as pd; print(pd.show_versions())" + 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 From fc33b853536dd72c7b8461f033b2eed9cb51fae2 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Wed, 7 Sep 2022 11:47:55 -0700 Subject: [PATCH 4/4] Add small whatsnew note --- doc/source/whatsnew/v1.5.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.5.0.rst b/doc/source/whatsnew/v1.5.0.rst index c479c59082464..30cee571c314f 100644 --- a/doc/source/whatsnew/v1.5.0.rst +++ b/doc/source/whatsnew/v1.5.0.rst @@ -331,6 +331,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: