Skip to content

Commit d9bb114

Browse files
ENH: Create script to set up a development environment using docker
1 parent f904213 commit d9bb114

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

doc/source/development/contributing.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,15 @@ Instead of manually setting up a development environment, you can use `Docker
159159
commands. pandas provides a ``DockerFile`` in the root directory to build a Docker image
160160
with a full pandas development environment.
161161

162-
**Docker Commands**
162+
**Unix/macOS**
163+
164+
There is a script to help you with this::
165+
166+
./docker.sh
167+
168+
When prompted, enter your Github username.
169+
170+
**Windows**
163171

164172
Pass your GitHub username in the ``DockerFile`` to use your own fork::
165173

docker.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
#
3+
# Set up a development environment with Docker.
4+
5+
run_container () {
6+
# Run a container and bind the local forked repo to it
7+
docker run -it --rm -v "$(pwd)":/home/pandas-"$USER" pandas-"$USER"-env
8+
}
9+
10+
# Check if pandas image already exists
11+
docker image ls | grep "pandas-$USER-env" &> /dev/null
12+
13+
if [[ $? == 0 ]]; then
14+
15+
run_container
16+
17+
else
18+
19+
# Pass the Github username in the Dockerfile
20+
read -rp "Github username: " gh_username
21+
sed -i "s/gh_username=pandas-dev/gh_username=$gh_username/" Dockerfile
22+
23+
docker build --tag pandas-"$USER"-env .
24+
25+
# Revert change made to Dockerfile. This will prevent the Dockerfile
26+
# from being commited with the contributor's username in it if
27+
# the contributor eventually runs "git commit -am".
28+
sed -i "s/$gh_username/pandas-dev/" Dockerfile
29+
30+
run_container
31+
fi

0 commit comments

Comments
 (0)