diff --git a/.github/workflows/code-checks.yml b/.github/workflows/code-checks.yml index 280b6ed601f08..c4fc3575fdfa8 100644 --- a/.github/workflows/code-checks.yml +++ b/.github/workflows/code-checks.yml @@ -133,33 +133,6 @@ jobs: asv machine --yes asv run --quick --dry-run --strict --durations=30 --python=same - build_docker_dev_environment: - name: Build Docker Dev Environment - runs-on: ubuntu-22.04 - defaults: - run: - shell: bash -el {0} - - concurrency: - # https://github.community/t/concurrecy-not-work-for-push/183068/7 - group: ${{ github.event_name == 'push' && github.run_number || github.ref }}-build_docker_dev_environment - cancel-in-progress: true - - steps: - - name: Clean up dangling images - run: docker image prune -f - - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Build image - run: docker build --pull --no-cache --tag pandas-dev-env . - - - name: Show environment - run: docker run --rm pandas-dev-env python -c "import pandas as pd; print(pd.show_versions())" - requirements-dev-text-installable: name: Test install requirements-dev.txt runs-on: ubuntu-22.04 diff --git a/ci/dockerfiles/Dockerfile.alpine b/ci/dockerfiles/Dockerfile.alpine new file mode 100644 index 0000000000000..17c08a1589b20 --- /dev/null +++ b/ci/dockerfiles/Dockerfile.alpine @@ -0,0 +1,10 @@ +FROM python:3.10.8-alpine + +RUN apk update & apk upgrade +RUN apk add gcc g++ libc-dev + +COPY requirements-minimal.txt /tmp +RUN python -m pip install -r /tmp/requirements-minimal.txt + +WORKDIR /home/pandas +CMD ["/bin/sh"] diff --git a/ci/dockerfiles/Dockerfile.mamba-all b/ci/dockerfiles/Dockerfile.mamba-all new file mode 100644 index 0000000000000..dda31596d2a39 --- /dev/null +++ b/ci/dockerfiles/Dockerfile.mamba-all @@ -0,0 +1,13 @@ +FROM quay.io/condaforge/mambaforge + +RUN apt update && apt upgrade -y +RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata + +RUN mamba env create -f \ + https://raw.githubusercontent.com/pandas-dev/pandas/main/environment.yml + +RUN mamba init +RUN echo "\nmamba activate pandas-dev" >> ~/.bashrc +RUN mamba clean --all -qy + +WORKDIR /home/pandas diff --git a/ci/dockerfiles/Dockerfile.mamba-minimal b/ci/dockerfiles/Dockerfile.mamba-minimal new file mode 100644 index 0000000000000..0e49053f536b5 --- /dev/null +++ b/ci/dockerfiles/Dockerfile.mamba-minimal @@ -0,0 +1,21 @@ +FROM quay.io/condaforge/mambaforge + +RUN apt update && apt upgrade -y +RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata + +RUN mamba create -n pandas-dev \ + cython \ + hypothesis \ + numpy \ + pytest \ + pytest-asyncio \ + python=3.10.8 \ + pytz \ + python-dateutil \ + versioneer + +RUN mamba init +RUN echo "\nmamba activate pandas-dev" >> ~/.bashrc +RUN mamba clean --all -qy + +WORKDIR /home/pandas diff --git a/Dockerfile b/ci/dockerfiles/Dockerfile.pip-all similarity index 59% rename from Dockerfile rename to ci/dockerfiles/Dockerfile.pip-all index 7230dcab20f6e..d22a02593e4e0 100644 --- a/Dockerfile +++ b/ci/dockerfiles/Dockerfile.pip-all @@ -1,13 +1,12 @@ FROM python:3.10.8 -WORKDIR /home/pandas -RUN apt-get update && apt-get -y upgrade -RUN apt-get install -y build-essential +RUN apt update && apt -y upgrade # hdf5 needed for pytables installation RUN apt-get install -y libhdf5-dev -RUN python -m pip install --upgrade pip -RUN python -m pip install \ +RUN python -m pip install --use-deprecated=legacy-resolver \ -r https://raw.githubusercontent.com/pandas-dev/pandas/main/requirements-dev.txt + +WORKDIR /home/pandas CMD ["/bin/bash"] diff --git a/ci/dockerfiles/Dockerfile.pip-minimal b/ci/dockerfiles/Dockerfile.pip-minimal new file mode 100644 index 0000000000000..b88ab50b89136 --- /dev/null +++ b/ci/dockerfiles/Dockerfile.pip-minimal @@ -0,0 +1,10 @@ +FROM python:3.10.8-slim + +RUN apt update && apt upgrade -y +RUN apt install -y gcc g++ + +COPY requirements-minimal.txt /tmp +RUN python -m pip install -r /tmp/requirements-minimal.txt + +WORKDIR /home/pandas +CMD ["/bin/bash"] diff --git a/ci/dockerfiles/requirements-minimal.txt b/ci/dockerfiles/requirements-minimal.txt new file mode 100644 index 0000000000000..7de6f10d2824f --- /dev/null +++ b/ci/dockerfiles/requirements-minimal.txt @@ -0,0 +1,8 @@ +cython +hypothesis +numpy +pytest +pytest-asyncio +pytz +python-dateutil +versioneer diff --git a/doc/source/development/contributing_environment.rst b/doc/source/development/contributing_environment.rst index 942edd863a19a..815a161557f48 100644 --- a/doc/source/development/contributing_environment.rst +++ b/doc/source/development/contributing_environment.rst @@ -157,56 +157,42 @@ should already exist. Option 3: using Docker ~~~~~~~~~~~~~~~~~~~~~~ -pandas provides a ``DockerFile`` in the root directory to build a Docker image -with a full pandas development environment. +Instead of manually setting up a development environment, you can use `Docker +`_. pandas provides pre-built images that serve a +variety of users. These images include: -**Docker Commands** + * alpine - a lightweight image for the absolute minimalist (note: this is experimental) + * pip-minimal - a pip-based installation with the minimum set of packages for building / testing + * mamba-minimal - a mamba-based installation with the minimum set of packages for building / testing + * pip-all - a pip-based installation with all testing dependencies + * mamba-all - a mamba-based installation with all testing dependencies -Build the Docker image:: +If you are a new user and the image size is no concern to you, we suggest opting for either image +that includes all of the dependencies, as this will ensure you can run the test suite without any +caveats. - # Build the image - docker build -t pandas-dev . +To use any of the images, you should first start with ``docker pull pandas/pandas:``, +where tag is one of *alpine*, *pip-minimal*, *mamba-minimal*, *pip-all* or *mamba-all*. You can then run +the image without any extra configuration. -Run Container:: +To illustrate, if you wanted to use the *pip-all* image, from the root of your local pandas project +you would run: - # Run a container and bind your local repo to the container - # This command assumes you are running from your local repo - # but if not alter ${PWD} to match your local repo path - docker run -it --rm -v ${PWD}:/home/pandas pandas-dev - -*Even easier, you can integrate Docker with the following IDEs:* - -**Visual Studio Code** - -You can use the DockerFile to launch a remote session with Visual Studio Code, -a popular free IDE, using the ``.devcontainer.json`` file. -See https://code.visualstudio.com/docs/remote/containers for details. - -**PyCharm (Professional)** - -Enable Docker support and use the Services tool window to build and manage images as well as -run and interact with containers. -See https://www.jetbrains.com/help/pycharm/docker.html for details. - -Step 3: build and install pandas --------------------------------- +.. code-block:: bash -You can now run:: + docker pull pandas/pandas:pip-all + docker run --rm -it -v ${PWD}:/home/pandas pandas/pandas:pip-all - # Build and install pandas - python setup.py build_ext -j 4 - python -m pip install -e . --no-build-isolation --no-use-pep517 +Similarly for *mamba-all* -At this point you should be able to import pandas from your locally built version:: +.. code-block:: bash - $ python - >>> import pandas - >>> print(pandas.__version__) # note: the exact output may differ - 2.0.0.dev0+880.g2b9e661fbb.dirty + docker pull pandas/pandas:mamba-all + docker run --rm -it -v ${PWD}:/home/pandas pandas/pandas:mamba-all -This will create the new environment, and not touch any of your existing environments, -nor any existing Python installation. +The *mamba-* images will automatically activate the appropriate virtual environment for you on entry. .. note:: - You will need to repeat this step each time the C extensions change, for example - if you modified any file in ``pandas/_libs`` or if you did a fetch and merge from ``upstream/main``. + + You may run the images from a directory besides the root of the pandas project - just be + sure to substitute ${PWD} in the commands above to point to your local pandas repository