A collection of classes and commands for automated command line scripting using Python.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
3.0 KiB

4 years ago
.PHONY: docs help tests
# The path to source code to be counted with cloc.
4 years ago
PACKAGE_NAME := scripttease
4 years ago
# The name of the project on disk.
PROJECT_NAME := python-scripttease
4 years ago
# The directory where test coverage is generated.
COVERAGE_PATH := docs/build/html/coverage
# $(file) may not work depending upon version of make.
#RELEASE := $(strip $(file < RELEASE.txt))
RELEASE := $(strip $(shell cat RELEASE.txt))
VERSION := $(strip $(shell cat VERSION.txt))
1 year ago
DOCS_PATH := $(PROJECT_HOME)/docs_diff6_com
DOCS_WWW := $(DOCS_PATH)/www
4 years ago
# Attempt to load a local makefile which may override any of the values above.
-include local.makefile
#> help - Show help.
help:
@echo ""
@echo "Management Commands"
@echo "------------------------------------------------------------------------------"
@cat Makefile | grep "^#>" | sed 's/\#\> //g';
@echo ""
#> backup - Create a backup of the project.
backup:
cd ~/Work && tar -czvf $(PROJECT_NAME).tgz $(PROJECT_NAME);
mv ~/Work/$(PROJECT_NAME).tgz ~/Dropbox/backups/;
4 years ago
#> dist - Create a distribution of the package.
dist:
cp DESCRIPTION.txt $(PACKAGE_NAME)/;
cp LICENSE.txt $(PACKAGE_NAME)/;
cp VERSION.txt $(PACKAGE_NAME)/;
@rm -Rf build/*;
@rm -Rf dist/*;
@rm -Rf *.egg-info;
python setup.py sdist bdist_wheel;
twine check dist/*;
rm $(PACKAGE_NAME)/*.txt;
4 years ago
#> docs - Generate documentation.
docs: lines
4 years ago
cd docs && make dirhtml;
4 years ago
cd docs && make html;
cd docs && make coverage;
open docs/build/coverage/python.txt;
firefox docs/build/html/index.html;
4 years ago
4 years ago
#> clean - Remove pyc files and documentation builds.
4 years ago
clean:
find . -name '*.pyc' -delete;
4 years ago
(cd docs && make clean);
4 years ago
# lines - Generate lines of code report.
lines:
rm -f docs/source/_data/cloc.csv;
echo "files,language,blank,comment,code" > docs/source/_data/cloc.csv;
4 years ago
cloc $(PACKAGE_NAME) --csv --quiet --unix --report-file=tmp.csv
4 years ago
tail -n +2 tmp.csv >> docs/source/_data/cloc.csv;
rm tmp.csv;
4 years ago
#> publish - Publish to PYPI.
publish:
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*;
4 years ago
#> secure - Run security checks on the code base.
secure:
bandit -r $(PACKAGE_NAME);
1 year ago
#> support - Build support (help) and reference documentation.
support:
cd docs && make dirhtml;
cd help/en/ && mkdocs build;
test -d $(DOCS_WWW)/en/$(PROJECT_NAME)/$(RELEASE) || mkdir -p $(DOCS_WWW)/en/$(PROJECT_NAME)/$(RELEASE);
test -d $(DOCS_WWW)/en/$(PROJECT_NAME)/$(RELEASE)/reference || mkdir -p $(DOCS_WWW)/en/$(PROJECT_NAME)/$(RELEASE)/reference;
cp -R docs/build/dirhtml/* $(DOCS_WWW)/en/$(PROJECT_NAME)/$(RELEASE)/reference/;
cp -R help/en/site/* $(DOCS_WWW)/en/$(PROJECT_NAME)/$(RELEASE)/;
cp meta.ini $(DOCS_PATH)/config/$(PROJECT_NAME).ini;
cd $(DOCS_WWW)/en/$(PROJECT_NAME) && ln -fs $(RELEASE) latest;
cd $(DOCS_WWW)/en/$(PROJECT_NAME) && ln -fs $(RELEASE) stable; # if product is stable
#cd $(DOCS_PATH) && make build;
1 year ago
4 years ago
#> tests - Run unit tests and generate coverage report.
tests:
coverage run --source=. -m pytest;
coverage html --directory=$(COVERAGE_PATH);
firefox $(COVERAGE_PATH)/index.html;
4 years ago