From d9bb11416effbc09340f263ccef16f144d92058e Mon Sep 17 00:00:00 2001 From: "Gustavo C. Maciel" Date: Sat, 20 Feb 2021 11:01:15 -0300 Subject: [PATCH 1/3] ENH: Create script to set up a development environment using docker --- doc/source/development/contributing.rst | 10 +++++++- docker.sh | 31 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100755 docker.sh diff --git a/doc/source/development/contributing.rst b/doc/source/development/contributing.rst index f48c4ff5d97af..e4a59a25e0396 100644 --- a/doc/source/development/contributing.rst +++ b/doc/source/development/contributing.rst @@ -159,7 +159,15 @@ Instead of manually setting up a development environment, you can use `Docker commands. pandas provides a ``DockerFile`` in the root directory to build a Docker image with a full pandas development environment. -**Docker Commands** +**Unix/macOS** + +There is a script to help you with this:: + + ./docker.sh + +When prompted, enter your Github username. + +**Windows** Pass your GitHub username in the ``DockerFile`` to use your own fork:: diff --git a/docker.sh b/docker.sh new file mode 100755 index 0000000000000..d0da95c60f891 --- /dev/null +++ b/docker.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# +# Set up a development environment with Docker. + +run_container () { + # Run a container and bind the local forked repo to it + docker run -it --rm -v "$(pwd)":/home/pandas-"$USER" pandas-"$USER"-env +} + +# Check if pandas image already exists +docker image ls | grep "pandas-$USER-env" &> /dev/null + +if [[ $? == 0 ]]; then + + run_container + +else + + # Pass the Github username in the Dockerfile + read -rp "Github username: " gh_username + sed -i "s/gh_username=pandas-dev/gh_username=$gh_username/" Dockerfile + + docker build --tag pandas-"$USER"-env . + + # Revert change made to Dockerfile. This will prevent the Dockerfile + # from being commited with the contributor's username in it if + # the contributor eventually runs "git commit -am". + sed -i "s/$gh_username/pandas-dev/" Dockerfile + + run_container +fi From 419080645f706a4c12c8c9a60439eb4d3aec238b Mon Sep 17 00:00:00 2001 From: "Gustavo C. Maciel" Date: Tue, 23 Feb 2021 15:03:26 -0300 Subject: [PATCH 2/3] Update script --- doc/source/development/contributing.rst | 2 +- scripts/docker.sh | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 scripts/docker.sh diff --git a/doc/source/development/contributing.rst b/doc/source/development/contributing.rst index e4a59a25e0396..d246bd6b615a5 100644 --- a/doc/source/development/contributing.rst +++ b/doc/source/development/contributing.rst @@ -163,7 +163,7 @@ with a full pandas development environment. There is a script to help you with this:: - ./docker.sh + ./scripts/docker.sh When prompted, enter your Github username. diff --git a/scripts/docker.sh b/scripts/docker.sh new file mode 100755 index 0000000000000..ea572cc717efb --- /dev/null +++ b/scripts/docker.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Set up a development environment with Docker. + +run_container () { + # Run a container and bind the local forked repo to it + docker run -it --rm -v "$(pwd)":/home/pandas-"$USER" pandas-"$USER"-env +} + +# Check if pandas image already exists +docker image ls | grep "pandas-$USER-env" &> /dev/null + +if [[ $? == 0 ]]; then + + run_container + +else + + # Pass the Github username as the build variable + read -rp "Github username: " gh_username + docker build --tag pandas-"$USER"-env --build-arg gh_username=$gh_username . + + run_container + +fi From 4de234b3ae68535d94bf1f55b59dd7be10f91a90 Mon Sep 17 00:00:00 2001 From: "Gustavo C. Maciel" <66797203+gcmaciel@users.noreply.github.com> Date: Tue, 23 Feb 2021 15:05:34 -0300 Subject: [PATCH 3/3] Delete docker.sh --- docker.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100755 docker.sh diff --git a/docker.sh b/docker.sh deleted file mode 100755 index d0da95c60f891..0000000000000 --- a/docker.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# Set up a development environment with Docker. - -run_container () { - # Run a container and bind the local forked repo to it - docker run -it --rm -v "$(pwd)":/home/pandas-"$USER" pandas-"$USER"-env -} - -# Check if pandas image already exists -docker image ls | grep "pandas-$USER-env" &> /dev/null - -if [[ $? == 0 ]]; then - - run_container - -else - - # Pass the Github username in the Dockerfile - read -rp "Github username: " gh_username - sed -i "s/gh_username=pandas-dev/gh_username=$gh_username/" Dockerfile - - docker build --tag pandas-"$USER"-env . - - # Revert change made to Dockerfile. This will prevent the Dockerfile - # from being commited with the contributor's username in it if - # the contributor eventually runs "git commit -am". - sed -i "s/$gh_username/pandas-dev/" Dockerfile - - run_container -fi