Skip to content

Commit

Permalink
Move requirements to files
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Jul 24, 2016
1 parent 09b9cae commit 9af835f
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 123 deletions.
6 changes: 4 additions & 2 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ install:
- set PATH=%PATH%;C:\MinGW\bin
- make --version
# Install project dependencies
- make depends-ci
- make env
- make depends

build: off

test_script:
- make ci
- make check
- make test
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ install:

before_script:
- make env
- make depends-ci
- make depends

script:
- make ci
- make check
- make test

after_success:
- coveralls
Expand Down
211 changes: 92 additions & 119 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ PROJECT := sappy
PACKAGE := sappy
REPOSITORY := jacebrowning/sappy
DIRECTORIES := $(PACKAGE) tests
FILES := Makefile setup.py $(shell find $(DIRECTORIES) -name '*.py')
FILES := setup.py $(shell find $(DIRECTORIES) -name '*.py')

# Python settings
ifndef TRAVIS
Expand Down Expand Up @@ -69,125 +69,78 @@ COVERAGE_SPACE := $(BIN_)coverage.space
SNIFFER := $(BIN_)sniffer
HONCHO := PYTHONPATH=$(PWD) $(ACTIVATE) && $(BIN_)honcho

# Flags for PHONY targets
INSTALLED_FLAG := $(ENV)/.installed
DEPENDS_CI_FLAG := $(ENV)/.depends-ci
DEPENDS_DOC_FLAG := $(ENV)/.depends-doc
DEPENDS_DEV_FLAG := $(ENV)/.depends-dev
ALL_FLAG := $(ENV)/.all

# Main Targets #################################################################
# MAIN TASKS ###################################################################

.PHONY: all
all: depends doc $(ALL_FLAG)
$(ALL_FLAG): $(FILES)
make check
@ touch $@ # flag to indicate all setup steps were successful
all: doc

.PHONY: ci
ci: check test ## Run all targets that determine CI status

.PHONY: watch
watch: depends .clean-test ## Continuously run all CI targets when files chanage
@ rm -rf $(FAILED_FLAG)
$(SNIFFER)

# Development Installation #####################################################
# SYSTEM DEPENDENCIES ##########################################################

.PHONY: doctor
doctor: ## Confirm system dependencies are available
@ echo "Checking Python version:"
@ python --version | tee /dev/stderr | grep -q "3.5."

# PROJECT DEPENDENCIES #########################################################

DEPENDS_CI := $(ENV)/.depends-ci
DEPENDS_DEV := $(ENV)/.depends-dev

.PHONY: env
env: $(PIP) $(INSTALLED_FLAG)
$(INSTALLED_FLAG): Makefile setup.py requirements.txt
env: $(PYTHON) setup.py requirements.txt
$(PYTHON) setup.py develop
@ touch $@ # flag to indicate package is installed

$(PIP):
$(PYTHON):
$(SYS_PYTHON) -m venv --clear $(ENV)
$(PYTHON) -m pip install --upgrade pip setuptools


# Tools Installation ###########################################################

.PHONY: depends
depends: depends-ci depends-doc depends-dev ## Install all project dependnecies
depends: $(DEPENDS_CI) $(DEPENDS_DEV) ## Install all project dependnecies

.PHONY: depends-ci
depends-ci: env Makefile $(DEPENDS_CI_FLAG)
$(DEPENDS_CI_FLAG): Makefile
$(PIP) install --upgrade pep8 pep257 pylint coverage coverage.space pytest pytest-describe pytest-expecter pytest-cov pytest-random
$(DEPENDS_CI): env requirements/ci.txt
$(PIP) install -r requirements/ci.txt
@ touch $@ # flag to indicate dependencies are installed

.PHONY: depends-doc
depends-doc: env Makefile $(DEPENDS_DOC_FLAG)
$(DEPENDS_DOC_FLAG): Makefile
$(PIP) install --upgrade pylint docutils readme pdoc mkdocs pygments
@ touch $@ # flag to indicate dependencies are installed

.PHONY: depends-dev
depends-dev: env Makefile $(DEPENDS_DEV_FLAG)
$(DEPENDS_DEV_FLAG): Makefile
$(PIP) install --upgrade pip pep8radius wheel sniffer honcho
$(DEPENDS_DEV): env requirements/dev.txt
$(PIP) install pip -r requirements/dev.txt
ifdef WINDOWS
$(PIP) install --upgrade pywin32
@ echo "Manually install pywin32: https://sourceforge.net/projects/pywin32/files/pywin32"
else ifdef MAC
$(PIP) install --upgrade pync MacFSEvents==0.4
$(PIP) install --upgrade pync MacFSEvents
else ifdef LINUX
$(PIP) install --upgrade pyinotify
endif
@ touch $@ # flag to indicate dependencies are installed

# Documentation ################################################################

.PHONY: doc
doc: uml pdoc mkdocs ## Run all documentation targets

.PHONY: uml
uml: depends-doc docs/*.png ## Generate UML diagrams for classes and packages
docs/*.png: $(FILES)
$(PYREVERSE) $(PACKAGE) -p $(PACKAGE) -a 1 -f ALL -o png --ignore tests
- mv -f classes_$(PACKAGE).png docs/classes.png
- mv -f packages_$(PACKAGE).png docs/packages.png

.PHONY: pdoc
pdoc: depends-doc pdoc/$(PACKAGE)/index.html ## Generate API documentaiton from the code
pdoc/$(PACKAGE)/index.html: $(FILES)
$(PDOC) --html --overwrite $(PACKAGE) --html-dir docs/apidocs

.PHONY: mkdocs
mkdocs: depends-doc site/index.html ## Build the documentation with mkdocs
site/index.html: mkdocs.yml docs/*.md
ln -sf `realpath README.md --relative-to=docs` docs/index.md
ln -sf `realpath CHANGELOG.md --relative-to=docs/about` docs/about/changelog.md
ln -sf `realpath CONTRIBUTING.md --relative-to=docs/about` docs/about/contributing.md
ln -sf `realpath LICENSE.md --relative-to=docs/about` docs/about/licence.md
$(MKDOCS) build --clean --strict

.PHONY: mkdocs-live
mkdocs-live: depends-doc ## Launch and continuously rebuild the mkdocs site
eval "sleep 3; open http://127.0.0.1:8000" &
$(MKDOCS) serve

# Static Analysis ##############################################################
# CHECKS #######################################################################

.PHONY: check
check: pep8 pep257 pylint ## Run all static analysis targets

.PHONY: pep8
pep8: depends-ci ## Check for convention issues
pep8: depends ## Check for convention issues
$(PEP8) $(DIRECTORIES) --config=.pep8rc

.PHONY: pep257
pep257: depends-ci ## Check for docstring issues
pep257: depends ## Check for docstring issues
$(PEP257) $(DIRECTORIES)

.PHONY: pylint
pylint: depends-ci ## Check for code issues
pylint: depends ## Check for code issues
$(PYLINT) $(DIRECTORIES) --rcfile=.pylintrc

.PHONY: fix
fix: depends-dev
fix: depends
$(PEP8RADIUS) --docformatter --in-place

# Testing ######################################################################
# TESTS ########################################################################

RANDOM_SEED ?= $(shell date +%s)

Expand All @@ -204,7 +157,7 @@ FAILURES := .cache/v/cache/lastfailed
test: test-all

.PHONY: test-unit
test-unit: depends-ci ## Run the unit tests
test-unit: depends ## Run the unit tests
@- mv $(FAILURES) $(FAILURES).bak
$(PYTEST) $(PYTEST_OPTS) $(PACKAGE)
@- mv $(FAILURES).bak $(FAILURES)
Expand All @@ -215,7 +168,7 @@ endif
endif

.PHONY: test-int
test-int: depends-ci ## Run the integration tests
test-int: depends ## Run the integration tests
@ if test -e $(FAILURES); then $(PYTEST) $(PYTEST_OPTS_FAILFAST) tests; fi
$(PYTEST) $(PYTEST_OPTS) tests
ifndef TRAVIS
Expand All @@ -225,7 +178,7 @@ endif
endif

.PHONY: test-all
test-all: depends-ci ## Run all the tests
test-all: depends ## Run all the tests
@ if test -e $(FAILURES); then $(PYTEST) $(PYTEST_OPTS_FAILFAST) $(DIRECTORIES); fi
$(PYTEST) $(PYTEST_OPTS) $(DIRECTORIES)
ifndef TRAVIS
Expand All @@ -238,42 +191,42 @@ endif
read-coverage:
$(OPEN) htmlcov/index.html

# Cleanup ######################################################################
# DOCUMENTATION ################################################################

.PHONY: clean
clean: .clean-dist .clean-test .clean-doc .clean-build
rm -rf $(ALL_FLAG)

.PHONY: clean-all
clean-all: clean .clean-env .clean-workspace

.PHONY: .clean-build
.clean-build:
find $(DIRECTORIES) -name '*.pyc' -delete
find $(DIRECTORIES) -name '__pycache__' -delete
rm -rf $(INSTALLED_FLAG) *.egg-info
PDOC_INDEX := docs/apidocs/$(PACKAGE)/index.html
MKDOCS_INDEX := site/index.html

.PHONY: .clean-doc
.clean-doc:
rm -rf README.rst docs/apidocs *.html docs/*.png site
.PHONY: doc
doc: uml pdoc mkdocs ## Run all documentation targets

.PHONY: .clean-test
.clean-test:
rm -rf .cache .pytest .coverage htmlcov
.PHONY: uml
uml: depends docs/*.png ## Generate UML diagrams for classes and packages
docs/*.png: $(FILES)
$(PYREVERSE) $(PACKAGE) -p $(PACKAGE) -a 1 -f ALL -o png --ignore tests
- mv -f classes_$(PACKAGE).png docs/classes.png
- mv -f packages_$(PACKAGE).png docs/packages.png

.PHONY: .clean-dist
.clean-dist:
rm -rf dist build
.PHONY: pdoc
pdoc: depends $(PDOC_INDEX) ## Generate API documentaiton with pdoc
$(PDOC_INDEX): $(FILES)
$(PDOC) --html --overwrite $(PACKAGE) --html-dir docs/apidocs
@ touch $@

.PHONY: .clean-env
.clean-env: clean
rm -rf $(ENV)
.PHONY: mkdocs
mkdocs: depends $(MKDOCS_INDEX) ## Build the documentation site with mkdocs
$(MKDOCS_INDEX): mkdocs.yml docs/*.md
ln -sf `realpath README.md --relative-to=docs` docs/index.md
ln -sf `realpath CHANGELOG.md --relative-to=docs/about` docs/about/changelog.md
ln -sf `realpath CONTRIBUTING.md --relative-to=docs/about` docs/about/contributing.md
ln -sf `realpath LICENSE.md --relative-to=docs/about` docs/about/licence.md
$(MKDOCS) build --clean --strict

.PHONY: .clean-workspace
.clean-workspace:
rm -rf *.sublime-workspace
.PHONY: mkdocs-live
mkdocs-live: depends ## Launch and continuously rebuild the mkdocs site
eval "sleep 3; open http://127.0.0.1:8000" &
$(MKDOCS) serve

# Release ######################################################################
# RELEASE ######################################################################

.PHONY: register-test
register-test: README.rst CHANGELOG.rst ## Register the project on the test PyPI
Expand Down Expand Up @@ -310,21 +263,41 @@ upload: .git-no-changes register ## Upload the current version to PyPI
%.rst: %.md
pandoc -f markdown_github -t rst -o $@ $<

# System Installation ##########################################################
# CLEANUP ######################################################################

.PHONY: develop
develop:
$(SYS_PYTHON) setup.py develop
.PHONY: clean
clean: .clean-dist .clean-test .clean-doc .clean-build

.PHONY: install
install:
$(SYS_PYTHON) setup.py install
.PHONY: clean-all
clean-all: clean .clean-env .clean-workspace

.PHONY: download
download:
$(SYS_PYTHON) -m pip install $(PROJECT)
.PHONY: .clean-build
.clean-build:
find $(DIRECTORIES) -name '*.pyc' -delete
find $(DIRECTORIES) -name '__pycache__' -delete
rm -rf *.egg-info

.PHONY: .clean-doc
.clean-doc:
rm -rf README.rst docs/apidocs *.html docs/*.png site

.PHONY: .clean-test
.clean-test:
rm -rf .cache .pytest .coverage htmlcov

.PHONY: .clean-dist
.clean-dist:
rm -rf dist build

.PHONY: .clean-env
.clean-env: clean
rm -rf $(ENV)

.PHONY: .clean-workspace
.clean-workspace:
rm -rf *.sublime-workspace

# Help #########################################################################
# HELP #########################################################################

.PHONY: help
help: all
Expand Down
16 changes: 16 additions & 0 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Linters
pep8
pep257
pylint

# Testing
pytest
pytest-describe
pytest-expecter
pytest-cov
pytest-random
expecter

# Coverage
coverage
coverage.space
17 changes: 17 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Documentation
pylint
docutils
readme
pdoc
mkdocs
pygments

# Tooling
pep8radius
sniffer

# Runner
honcho

# Release
wheel

0 comments on commit 9af835f

Please sign in to comment.