Skip to content

Commit

Permalink
Add virtualenv build script for local development.
Browse files Browse the repository at this point in the history
Add a configure script and Makefile that build out an isolated virtualenv environment with the packages needed for running p2pool. Useful for local development or automated deployment.
  • Loading branch information
Mark Friedenbach committed Oct 24, 2012
1 parent c78dab1 commit 0c2aa38
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@
/litecoin_scrypt/build/
/_trial_temp/
/_trial_temp.lock
Makefile.local
.cache/
.pkg/
.coverage
build/
99 changes: 99 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# === makefile ------------------------------------------------------------===

ROOT=$(shell pwd)
CACHE_ROOT=${ROOT}/.cache
PKG_ROOT=${ROOT}/.pkg

-include Makefile.local

.PHONY: all
all: ${PKG_ROOT}/.stamp-h

.PHONY: check
check: all
"${PKG_ROOT}"/bin/coverage run "${PKG_ROOT}"/bin/trial p2pool
"${PKG_ROOT}"/bin/coverage xml -o build/report/coverage.xml

.PHONY: run
run: all
"${PKG_ROOT}"/bin/python run_p2pool.py

.PHONY: shell
shell: all
"${PKG_ROOT}"/bin/ipython

.PHONY: mostlyclean
mostlyclean:
-rm -rf build
-rm -rf .coverage

.PHONY: clean
clean: mostlyclean
-rm -rf "${PKG_ROOT}"

.PHONY: distclean
distclean: clean
-rm -rf "${CACHE_ROOT}"

.PHONY: maintainer-clean
maintainer-clean: distclean
@echo 'This command is intended for maintainers to use; it'
@echo 'deletes files that may need special tools to rebuild.'

.PHONY: dist
dist:

# ===--------------------------------------------------------------------===

${CACHE_ROOT}/virtualenv/virtualenv-1.8.2.tar.gz:
mkdir -p ${CACHE_ROOT}/virtualenv
sh -c "cd ${CACHE_ROOT}/virtualenv && curl -O http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.8.2.tar.gz"

${PKG_ROOT}/.stamp-h: conf/requirements*.pip ${CACHE_ROOT}/virtualenv/virtualenv-1.8.2.tar.gz
# Because build and run-time dependencies are not thoroughly tracked,
# it is entirely possible that rebuilding the development environment
# on top of an existing one could result in a broken build. For the
# sake of consistency and preventing unnecessary, difficult-to-debug
# problems, the entire development environment is rebuilt from scratch
# everytime this make target is selected.
${MAKE} clean

# The ``${PKG_ROOT}`` directory, if it exists, is removed by the
# ``clean`` target. The PyPI cache is nonexistant if this is a freshly
# checked-out repository, or if the ``distclean`` target has been run.
# This might cause problems with build scripts executed later which
# assume their existence, so they are created now if they don't
# already exist.
mkdir -p "${PKG_ROOT}"
mkdir -p "${CACHE_ROOT}"/pypi

# ``virtualenv`` is used to create a separate Python installation for
# this project in ``${PKG_ROOT}``.
tar \
-C "${CACHE_ROOT}"/virtualenv --gzip \
-xf "${CACHE_ROOT}"/virtualenv/virtualenv-1.8.2.tar.gz
python "${CACHE_ROOT}"/virtualenv/virtualenv-1.8.2/virtualenv.py \
--clear \
--distribute \
--never-download \
--prompt="(p2pool) " \
"${PKG_ROOT}"
-rm -rf "${CACHE_ROOT}"/virtualenv/virtualenv-1.8.2

# readline is installed here to get around a bug on Mac OS X which is
# causing readline to not build properly if installed from pip.
"${PKG_ROOT}"/bin/easy_install readline

# pip is used to install Python dependencies for this project.
for reqfile in conf/requirements*.pip; do \
"${PKG_ROOT}"/bin/python "${PKG_ROOT}"/bin/pip install \
--download-cache="${CACHE_ROOT}"/pypi \
-r $$reqfile; \
done

# All done!
touch "${PKG_ROOT}"/.stamp-h

# ===--------------------------------------------------------------------===
# End of File
# ===--------------------------------------------------------------------===
3 changes: 3 additions & 0 deletions conf/requirements.development.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ipdb==0.7
ipython==0.13.1
readline>=6.2.4.1
2 changes: 2 additions & 0 deletions conf/requirements.production.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Twisted>=12.2.0
argparse>=1.2.1
3 changes: 3 additions & 0 deletions conf/requirements.testing.pip
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
coverage==3.5.3
unittest-xml-reporting==1.4.1
unittest2==0.5.1
9 changes: 9 additions & 0 deletions configure
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# === configure -----------------------------------------------------------===

touch Makefile.local

# ===--------------------------------------------------------------------===
# End of File
# ===--------------------------------------------------------------------===

0 comments on commit 0c2aa38

Please sign in to comment.