bootstrapit updates

This commit is contained in:
Manuel Barkhau 2018-11-09 19:22:17 +01:00
parent cbe62c371e
commit 501cde895a
5 changed files with 54 additions and 37 deletions

6
.gitignore vendored
View file

@ -18,9 +18,11 @@ downloads/
eggs/ eggs/
lib/ lib/
lib64/ lib64/
vendor/
parts/ parts/
sdist/ sdist/
var/ var/
public/
.mypy_cache/ .mypy_cache/
*.egg-info/ *.egg-info/
.installed.cfg .installed.cfg
@ -28,6 +30,7 @@ var/
.eggs/ .eggs/
.pytest_cache/ .pytest_cache/
.ipynb_checkpoints/ .ipynb_checkpoints/
package-lock.json
# PyInstaller # PyInstaller
# Usually these files are written by a python script from a template # Usually these files are written by a python script from a template
@ -46,7 +49,7 @@ htmlcov/
.cache .cache
nosetests.xml nosetests.xml
coverage.xml coverage.xml
.coverage_percent.txt .coverage*
# Translations # Translations
*.mo *.mo
@ -65,3 +68,4 @@ target/
README.html README.html
envs.txt envs.txt
test_build_logs/*.log test_build_logs/*.log
build/miniconda3.sh

View file

@ -392,12 +392,19 @@ code in order to minimize common pitfalls.
Please read, view at your leasure: Please read, view at your leasure:
- https://www.python.org/dev/peps/pep-0008/ - Talks:
- https://github.com/amontalenti/elements-of-python-style - [Stop Writing Classes by Jack Diederich](https://www.youtube.com/watch?v=o9pEzgHorH0)
- https://github.com/google/styleguide/blob/gh-pages/pyguide.md - [The Naming of Ducks: Where Dynamic Types Meet Smart Conventions by Brandon Rhodes](https://www.youtube.com/watch?v=YklKUuDpX5c)
- https://www.youtube.com/watch?v=o9pEzgHorH0 - [Transforming Code into Beautiful, Idiomatic Python by Raymond Hettinger](https://www.youtube.com/watch?v=OSGv2VnC0go)
- https://www.youtube.com/watch?v=OSGv2VnC0go - [Beyond PEP 8 -- Best practices for beautiful intelligible code by Raymond Hettinger](https://www.youtube.com/watch?v=wf-BqAjZb8M)
- https://www.youtube.com/watch?v=wf-BqAjZb8M - Articles, Essays, Books:
- Short ebook for Novice to Intermediate Pythonistas:
[How to Make Mistakes in Python](https://www.oreilly.com/programming/free/how-to-make-mistakes-in-python.csp)
- [The Little Book of Python Anti-Patterns](https://docs.quantifiedcode.com/python-anti-patterns/)
- Style Guides:
- https://www.python.org/dev/peps/pep-0008/
- https://github.com/amontalenti/elements-of-python-style
- https://github.com/google/styleguide/blob/gh-pages/pyguide.md
Keep in mind, that all of this is about the form of your code, and Keep in mind, that all of this is about the form of your code, and
catching common pitfalls or gotchas. None of this releives you of the catching common pitfalls or gotchas. None of this releives you of the

View file

@ -29,7 +29,7 @@ ENV MINICONDA_VER latest
ENV MINICONDA Miniconda3-$MINICONDA_VER-Linux-x86_64.sh ENV MINICONDA Miniconda3-$MINICONDA_VER-Linux-x86_64.sh
ENV MINICONDA_URL https://repo.continuum.io/miniconda/$MINICONDA ENV MINICONDA_URL https://repo.continuum.io/miniconda/$MINICONDA
RUN curl -L ${MINICONDA_URL} --silent -o miniconda3.sh && \ RUN curl -L "$MINICONDA_URL" --silent -o miniconda3.sh && \
/bin/bash miniconda3.sh -f -b -p $CONDA_DIR && \ /bin/bash miniconda3.sh -f -b -p $CONDA_DIR && \
rm miniconda3.sh && \ rm miniconda3.sh && \
/opt/conda/bin/conda clean -tipsy && \ /opt/conda/bin/conda clean -tipsy && \
@ -49,7 +49,7 @@ ARG SSH_PRIVATE_RSA_KEY
ENV ENV_SSH_PRIVATE_RSA_KEY=${SSH_PRIVATE_RSA_KEY} ENV ENV_SSH_PRIVATE_RSA_KEY=${SSH_PRIVATE_RSA_KEY}
# Write private key and generate public key # Write private key and generate public key
RUN if [[ $ENV_SSH_PRIVATE_RSA_KEY ]]; then \ RUN if [[ "$ENV_SSH_PRIVATE_RSA_KEY" ]]; then \
echo -n "-----BEGIN RSA PRIVATE KEY-----" >> /root/.ssh/id_rsa && \ echo -n "-----BEGIN RSA PRIVATE KEY-----" >> /root/.ssh/id_rsa && \
echo -n ${ENV_SSH_PRIVATE_RSA_KEY} \ echo -n ${ENV_SSH_PRIVATE_RSA_KEY} \
| sed 's/-----BEGIN RSA PRIVATE KEY-----//' \ | sed 's/-----BEGIN RSA PRIVATE KEY-----//' \

View file

@ -55,6 +55,8 @@ CONDA_ENV_PATHS := \
DEV_ENV := $(ENV_PREFIX)/$(DEV_ENV_NAME) DEV_ENV := $(ENV_PREFIX)/$(DEV_ENV_NAME)
DEV_ENV_PY := $(DEV_ENV)/bin/python DEV_ENV_PY := $(DEV_ENV)/bin/python
RSA_KEY_PATH := ${HOME}/.ssh/${PKG_NAME}_gitlab_runner_id_rsa
build/envs.txt: requirements/conda.txt build/envs.txt: requirements/conda.txt
@mkdir -p build/; @mkdir -p build/;
@ -129,10 +131,6 @@ build/deps.txt: build/envs.txt requirements/*.txt
@mv build/deps.txt.tmp build/deps.txt @mv build/deps.txt.tmp build/deps.txt
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
## This help message ## This help message
.PHONY: help .PHONY: help
help: help:
@ -204,8 +202,12 @@ clean:
@printf "\n setup/update completed ✨ 🍰 ✨ \n\n" @printf "\n setup/update completed ✨ 🍰 ✨ \n\n"
## Force update of dependencies ## Force update of dependencies by removing marker files
## (this removes makefile markers) ## Use this when you know an external dependency was
## updated, but that is not reflected in your
## requirements files.
##
## Usage: make force update
.PHONY: force .PHONY: force
force: force:
rm -f build/envs.txt rm -f build/envs.txt
@ -293,12 +295,12 @@ test:
@rm -rf "src/__pycache__"; @rm -rf "src/__pycache__";
@rm -rf "test/__pycache__"; @rm -rf "test/__pycache__";
ENV=dev PYTHONPATH=src/:vendor/:$$PYTHONPATH \ ENV=${ENV-dev} PYTHONPATH=src/:vendor/:$$PYTHONPATH \
$(DEV_ENV_PY) -m pytest -v \ $(DEV_ENV_PY) -m pytest -v \
--doctest-modules \ --doctest-modules \
--cov-report html \ --cov-report html \
--cov-report term \ --cov-report term \
--cov=$(PKG_NAME) \ $(shell ls -1 src/ | awk '{ print "--cov "$$1 }') \
test/ src/; test/ src/;
@rm -rf ".pytest_cache"; @rm -rf ".pytest_cache";
@ -319,7 +321,7 @@ check: fmt lint mypy test
env: env:
@bash --init-file <(echo '\ @bash --init-file <(echo '\
source $$HOME/.bashrc; \ source $$HOME/.bashrc; \
export ENV=dev; \ export ENV=${ENV-dev}; \
export PYTHONPATH="src/:vendor/:$$PYTHONPATH"; \ export PYTHONPATH="src/:vendor/:$$PYTHONPATH"; \
conda activate $(DEV_ENV_NAME) \ conda activate $(DEV_ENV_NAME) \
') ')
@ -341,7 +343,7 @@ devtest:
ifndef FILTER ifndef FILTER
ENV=dev PYTHONPATH=src/:vendor/:$$PYTHONPATH \ ENV=${ENV-dev} PYTHONPATH=src/:vendor/:$$PYTHONPATH \
$(DEV_ENV_PY) -m pytest -v \ $(DEV_ENV_PY) -m pytest -v \
--doctest-modules \ --doctest-modules \
--no-cov \ --no-cov \
@ -350,7 +352,7 @@ ifndef FILTER
--exitfirst \ --exitfirst \
test/ src/; test/ src/;
else else
ENV=dev PYTHONPATH=src/:vendor/:$$PYTHONPATH \ ENV=${ENV-dev} PYTHONPATH=src/:vendor/:$$PYTHONPATH \
$(DEV_ENV_PY) -m pytest -v \ $(DEV_ENV_PY) -m pytest -v \
--doctest-modules \ --doctest-modules \
--no-cov \ --no-cov \
@ -370,22 +372,25 @@ endif
## Generate Documentation ## Generate Documentation
.PHONY: doc # .PHONY: doc
doc: # doc:
echo "Not Implemented" # echo "Not Implemented"
## Bump Version number in all files ## Bump Version number in all files
.PHONY: bump_version # .PHONY: bump_version
bump_version: # bump_version:
echo "Not Implemented" # echo "Not Implemented"
## Freeze dependencies of the current development env ## Freeze dependencies of the current development env.
## These dependencies are used for the docker image ## The requirements files this produces should be used
.PHONY: freeze ## in order to have reproducable builds, otherwise you
freeze: ## should minimize the number of pinned versions in
echo "Not Implemented" ## your requirements.
# .PHONY: freeze
# freeze:
# echo "Not Implemented"
## Create python sdist and bdist_wheel distributions ## Create python sdist and bdist_wheel distributions
@ -401,15 +406,14 @@ build_dist:
## 1. No ssh key at $(HOME)/.ssh/${PKG_NAME}_gitlab_runner_id_rsa ## 1. No ssh key at $(HOME)/.ssh/${PKG_NAME}_gitlab_runner_id_rsa
## (which is needed to install packages from private repos ## (which is needed to install packages from private repos
## and is copied into a temp container during the build). ## and is copied into a temp container during the build).
## 2. Your docker daemon is not running or configured to ## 2. Your docker daemon is not running
## expose on tcp://localhost:2375 ## 3. You're using WSL and docker is not exposed on tcp://localhost:2375
## 3. Your shell is not configured to connect to your docker ## 4. You're using WSL but didn't do export DOCKER_HOST="tcp://localhost:2375"
## daemon via "export DOCKER_HOST=localhost:2375"
.PHONY: build_docker .PHONY: build_docker
build_docker: build_docker:
@if [[ -f $$HOME/.ssh/${PKG_NAME}_gitlab_runner_id_rsa ]]; then \ @if [[ -f "${RSA_KEY_PATH}" ]]; then \
docker build \ docker build \
--build-arg SSH_PRIVATE_RSA_KEY="$$(cat ${HOME}/.ssh/${PKG_NAME}_gitlab_runner_id_rsa)" \ --build-arg SSH_PRIVATE_RSA_KEY="$$(cat '${RSA_KEY_PATH}')" \
--file docker_base.Dockerfile \ --file docker_base.Dockerfile \
--tag $(DOCKER_REGISTRY_URL)/base:latest \ --tag $(DOCKER_REGISTRY_URL)/base:latest \
.; \ .; \

View file

@ -15,6 +15,8 @@ ignore_missing_imports = True
max-line-length = 100 max-line-length = 100
max-complexity = 10 max-complexity = 10
ignore = ignore =
# Missing trailing comma (handled by sjfmt)
C812
# No whitespace after paren open "(" # No whitespace after paren open "("
E201 E201
# No whitespace before paren ")" # No whitespace before paren ")"