-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
skip conda in Makefile #91
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,139 +1,155 @@ | ||
# Application | ||
APP_ROOT := $(CURDIR) | ||
# Configuration | ||
APP_ROOT := $(abspath $(lastword $(MAKEFILE_LIST))/..) | ||
APP_NAME := emu | ||
|
||
# Anaconda | ||
CONDA := $(shell command -v conda 2> /dev/null) | ||
ANACONDA_HOME := $(shell conda info --base 2> /dev/null) | ||
CONDA_ENV := $(APP_NAME) | ||
|
||
TEMP_FILES := *.egg-info *.log *.sqlite | ||
# Bumpversion 'dry' config | ||
# if 'dry' is specified as target, any bumpversion call using 'BUMP_XARGS' will not apply changes | ||
BUMP_XARGS ?= --verbose --allow-dirty | ||
ifeq ($(filter dry, $(MAKECMDGOALS)), dry) | ||
BUMP_XARGS := $(BUMP_XARGS) --dry-run | ||
endif | ||
.PHONY: dry | ||
dry: setup.cfg | ||
@-echo > /dev/null | ||
|
||
# end of configuration | ||
|
||
.DEFAULT_GOAL := all | ||
.DEFAULT_GOAL := help | ||
|
||
.PHONY: all | ||
all: help | ||
|
||
.PHONY: help | ||
help: | ||
@echo "Please use \`make <target>' where <target> is one of" | ||
@echo " help to print this help message. (Default)" | ||
@echo " install to install $(APP_NAME) by running 'python setup.py develop'." | ||
@echo " start to start $(APP_NAME) service as daemon (background process)." | ||
@echo " stop to stop $(APP_NAME) service." | ||
@echo " restart to restart $(APP_NAME) service." | ||
@echo " status to show status of $(APP_NAME) service." | ||
@echo " clean to remove *all* files that are not controlled by 'git'. WARNING: use it *only* if you know what you do!" | ||
@echo "Please use 'make <target>' where <target> is one of:" | ||
@echo " help to print this help message. (Default)" | ||
@echo " install to install app by running 'pip install -e .'" | ||
@echo " develop to install with additional development requirements." | ||
@echo " start to start $(APP_NAME) service as daemon (background process)." | ||
@echo " stop to stop $(APP_NAME) service." | ||
@echo " restart to restart $(APP_NAME) service." | ||
@echo " status to show status of $(APP_NAME) service." | ||
@echo " clean to remove all files generated by build and tests." | ||
@echo "\nTesting targets:" | ||
@echo " test to run tests (but skip long running tests)." | ||
@echo " testall to run all tests (including long running tests)." | ||
@echo " pep8 to run pep8 code style checks." | ||
@echo " test to run tests (but skip long running tests)." | ||
@echo " test-all to run all tests (including long running tests)." | ||
@echo " lint to run code style checks with flake8." | ||
@echo "\nSphinx targets:" | ||
@echo " docs to generate HTML documentation with Sphinx." | ||
@echo " docs to generate HTML documentation with Sphinx." | ||
@echo "\nDeployment targets:" | ||
@echo " spec to generate Conda spec file." | ||
|
||
## Conda targets | ||
|
||
.PHONY: check_conda | ||
check_conda: | ||
ifndef CONDA | ||
$(error "Conda is not available. Please install miniconda: https://conda.io/miniconda.html") | ||
endif | ||
|
||
.PHONY: conda_env | ||
conda_env: check_conda | ||
@echo "Updating conda environment $(CONDA_ENV) ..." | ||
"$(CONDA)" env update -n $(CONDA_ENV) -f environment.yml | ||
|
||
.PHONY: envclean | ||
envclean: check_conda | ||
@echo "Removing conda env $(CONDA_ENV)" | ||
@-"$(CONDA)" remove -n $(CONDA_ENV) --yes --all | ||
|
||
.PHONY: spec | ||
spec: check_conda | ||
@echo "Updating conda environment specification file ..." | ||
@-"$(CONDA)" list -n $(CONDA_ENV) --explicit > spec-file.txt | ||
@echo " debug to print variable values employed by this Makefile." | ||
@echo " bump to update the package version." | ||
@echo " dry to only display results (not applied) when combined with 'bump'." | ||
@echo " dist to build source and wheel package." | ||
|
||
.PHONY: debug | ||
debug: | ||
@-echo "Following variables are used:" | ||
@-echo " SHELL: $(SHELL)" | ||
@-echo " APP_ROOT: $(APP_ROOT)" | ||
@-echo " BUMP_XARGS: $(BUMP_XARGS)" | ||
|
||
## Build targets | ||
|
||
.PHONY: bootstrap | ||
bootstrap: check_conda conda_env bootstrap_dev | ||
@echo "Bootstrap ..." | ||
|
||
.PHONY: bootstrap_dev | ||
bootstrap_dev: | ||
@echo "Installing development requirements for tests and docs ..." | ||
@-bash -c "$(CONDA) install -y -n $(CONDA_ENV) pytest flake8 sphinx gunicorn psycopg2" | ||
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && pip install -r requirements_dev.txt" | ||
|
||
.PHONY: install | ||
install: bootstrap | ||
install: | ||
@echo "Installing application ..." | ||
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && python setup.py develop" | ||
@-bash -c 'pip install -e .' | ||
@echo "\nStart service with \`make start'" | ||
|
||
.PHONY: develop | ||
develop: | ||
@echo "Installing development requirements for tests and docs ..." | ||
@-bash -c 'pip install -e ".[dev]"' | ||
|
||
.PHONY: start | ||
start: check_conda | ||
start: | ||
@echo "Starting application ..." | ||
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && $(APP_NAME) start -d" | ||
@-bash -c "$(APP_NAME) start -d" | ||
|
||
.PHONY: stop | ||
stop: check_conda | ||
stop: | ||
@echo "Stopping application ..." | ||
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && $(APP_NAME) stop" | ||
@-bash -c "$(APP_NAME) stop" | ||
|
||
.PHONY: restart | ||
restart: stop start | ||
@echo "Restarting application ..." | ||
|
||
.PHONY: status | ||
status: check_conda | ||
status: | ||
@echo "Show status ..." | ||
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && $(APP_NAME) status" | ||
@-bash -c "$(APP_NAME) status" | ||
|
||
.PHONY: clean | ||
clean: srcclean envclean | ||
@echo "Cleaning generated files ..." | ||
@-for i in $(TEMP_FILES); do \ | ||
test -e $$i && rm -v -rf $$i; \ | ||
done | ||
|
||
.PHONY: srcclean | ||
srcclean: | ||
@echo "Removing *.pyc files ..." | ||
@-find $(APP_ROOT) -type f -name "*.pyc" -print | xargs rm | ||
|
||
.PHONY: distclean | ||
distclean: clean | ||
@echo "Cleaning ..." | ||
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts | ||
|
||
.PHONY: clean-build | ||
clean-build: | ||
@echo "Remove build artifacts ..." | ||
@-rm -fr build/ | ||
@-rm -fr dist/ | ||
@-rm -fr .eggs/ | ||
@-find . -name '*.egg-info' -exec rm -fr {} + | ||
@-find . -name '*.egg' -exec rm -f {} + | ||
@-find . -name '*.log' -exec rm -fr {} + | ||
@-find . -name '*.sqlite' -exec rm -fr {} + | ||
|
||
.PHONY: clean-pyc | ||
clean-pyc: | ||
@echo "Remove Python file artifacts ..." | ||
@-find . -name '*.pyc' -exec rm -f {} + | ||
@-find . -name '*.pyo' -exec rm -f {} + | ||
@-find . -name '*~' -exec rm -f {} + | ||
@-find . -name '__pycache__' -exec rm -fr {} + | ||
|
||
.PHONY: clean-test | ||
clean-test: | ||
@echo "Remove test artifacts ..." | ||
@-rm -fr .pytest_cache | ||
|
||
.PHONY: clean-dist | ||
clean-dist: clean | ||
@echo "Run 'git clean' ..." | ||
@git diff --quiet HEAD || echo "There are uncommited changes! Not doing 'git clean' ..." | ||
@-git clean -dfx -e *.bak -e custom.cfg | ||
@-git clean -dfx | ||
|
||
## Test targets | ||
|
||
.PHONY: test | ||
test: check_conda | ||
test: | ||
@echo "Running tests (skip slow and online tests) ..." | ||
@bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV);pytest -v -m 'not slow and not online' tests/" | ||
@bash -c 'pytest -v -m "not slow and not online" tests/' | ||
|
||
.PHONY: testall | ||
testall: check_conda | ||
.PHONY: test-all | ||
test-all: | ||
@echo "Running all tests (including slow and online tests) ..." | ||
@bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && pytest -v tests/" | ||
@bash -c 'pytest -v tests/' | ||
|
||
.PHONY: pep8 | ||
pep8: check_conda | ||
@echo "Running pep8 code style checks ..." | ||
@bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV) && flake8" | ||
.PHONY: lint | ||
lint: | ||
@echo "Running flake8 code style checks ..." | ||
@bash -c 'flake8' | ||
|
||
## Sphinx targets | ||
## Sphinx targets | ||
|
||
.PHONY: docs | ||
docs: check_conda | ||
docs: | ||
@echo "Generating docs with Sphinx ..." | ||
@-bash -c "source $(ANACONDA_HOME)/bin/activate $(CONDA_ENV);$(MAKE) -C $@ clean html" | ||
@echo "open your browser: firefox docs/build/html/index.html" | ||
@-bash -c '$(MAKE) -C $@ clean html' | ||
@echo "open your browser: open file://$(APP_ROOT)/docs/build/html/index.html" | ||
|
||
## Deployment targets | ||
|
||
.PHONY: bump | ||
bump: | ||
@-echo "Updating package version ..." | ||
@[ "${VERSION}" ] || ( echo ">> 'VERSION' is not set"; exit 1 ) | ||
@-bash -c 'bump2version $(BUMP_XARGS) --new-version "${VERSION}" patch;' | ||
|
||
.PHONY: dist | ||
dist: clean | ||
@echo "Builds source and wheel package ..." | ||
@-python setup.py sdist | ||
@-python setup.py bdist_wheel | ||
ls -l dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a welcome change. Some other projects include Black formatting. This leaves an opening for the discussion.