Skip to content

Instantly share code, notes, and snippets.

@turtlebender
Created August 22, 2012 20:33
Show Gist options
  • Save turtlebender/3429094 to your computer and use it in GitHub Desktop.
Save turtlebender/3429094 to your computer and use it in GitHub Desktop.
Current Makefile
VIRTUALENV_URL=https://raw.github.com/pypa/virtualenv/master/virtualenv.py
PROJECT_NAME:=$(shell python setup.py --name)
VIRTUALENV_DIR=vendor/$(PROJECT_NAME)
DOWNLOAD_CACHE=vendor/cache
PIP_CMD=PIP_DOWNLOAD_CACHE=$(DOWNLOAD_CACHE) $(VIRTUALENV_DIR)/bin/pip
SRC_DIR=src
COVER_PACKAGE=ns
TEST_OUTPUT_DIR=test_results
TEST_DIR=tests
.PHONY: usage
usage:
@echo "python: Execute a command in the venv (python CMD=<script and arguments>)"
@echo "run: Run the program for this project."
@echo "test: Run the tests and generate coverage."
@echo "clean: Remove the build artifacts"
@echo "clean_all: Remove the virtualenv and build artifact"
@echo "package: Package up a build in a relocatable virtualenv"
.PHONY: run
run: install_libs
if [ -f run-requirements.txt ] ; then $(PIP_CMD) install -r run-requirements.txt ; fi
$(VIRTUALENV_DIR)/bin/python setup.py develop
if [ -f runme ] ; then PATH=$(VIRTUALENV_DIR)/bin:$(PATH) bash runme ; fi
.PHONY: python
python:
$(VIRTUALENV_DIR)/bin/python $(CMD)
.PHONY: test
test: install_libs $(VIRTUALENV_DIR)/bin/nosetests
mkdir -p $(TEST_OUTPUT_DIR)
if [ -f test-requirements ] ; then PIP_DOWNLOAD_CACHE=vendor/cache $(VIRTUALENV_DIR)/bin/pip install -r test-requirements.txt ; fi
$(VIRTUALENV_DIR)/bin/nosetests --with-coverage --cover-xml --cover-xml-file=../$(TEST_OUTPUT_DIR)/coverage.xml --cover-package=$(COVER_PACKAGE) -w $(T
EST_DIR) --with-xunit --xunit-file=$(TEST_OUTPUT_DIR)/nosetests.xml
.PHONY: package
package: clean_all install_libs install
$(VIRTUALENV_DIR)/bin/python setup.py install
python vendor/virtualenv.py --relocatable $(VIRTUALENV_DIR)
.PHONY: clean
clean:
rm -rf build dist *egg-info $(TEST_OUTPUT_DIR)
.PHONY: clean_all
clean_all: clean
rm -rf $(VIRTUALENV_DIR)
.PHONY: install
install:
$(VIRTUALENV_DIR)/bin/python setup.py install
$(VIRTUALENV_DIR)/bin/nosetests: $(VIRTUALENV_DIR)/bin/python
curl -L -o vendor/nosetests-master.tar.gz https://github.com/nose-devs/nose/tarball/master
$(PIP_CMD) install ./vendor/nosetests-master.tar.gz
$(PIP_CMD) install coverage
.PHONY: build
build: install_libs
$(VIRTUALENV_DIR)/bin/python setup.py develop
.PHONY: install_libs
install_libs: $(VIRTUALENV_DIR)/bin/python
$(PIP_CMD) install -r requirements.txt
$(VIRTUALENV_DIR)/bin/python:
mkdir -p vendor
curl -o vendor/virtualenv.py $(VIRTUALENV_URL)
python vendor/virtualenv.py --distribute $(VIRTUALENV_DIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment