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/
lib/
lib64/
vendor/
parts/
sdist/
var/
public/
.mypy_cache/
*.egg-info/
.installed.cfg
@ -28,6 +30,7 @@ var/
.eggs/
.pytest_cache/
.ipynb_checkpoints/
package-lock.json
# PyInstaller
# Usually these files are written by a python script from a template
@ -46,7 +49,7 @@ htmlcov/
.cache
nosetests.xml
coverage.xml
.coverage_percent.txt
.coverage*
# Translations
*.mo
@ -65,3 +68,4 @@ target/
README.html
envs.txt
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:
- Talks:
- [Stop Writing Classes by Jack Diederich](https://www.youtube.com/watch?v=o9pEzgHorH0)
- [The Naming of Ducks: Where Dynamic Types Meet Smart Conventions by Brandon Rhodes](https://www.youtube.com/watch?v=YklKUuDpX5c)
- [Transforming Code into Beautiful, Idiomatic Python by Raymond Hettinger](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)
- 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
- https://www.youtube.com/watch?v=o9pEzgHorH0
- https://www.youtube.com/watch?v=OSGv2VnC0go
- https://www.youtube.com/watch?v=wf-BqAjZb8M
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

View file

@ -29,7 +29,7 @@ ENV MINICONDA_VER latest
ENV MINICONDA Miniconda3-$MINICONDA_VER-Linux-x86_64.sh
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 && \
rm miniconda3.sh && \
/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}
# 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 ${ENV_SSH_PRIVATE_RSA_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_PY := $(DEV_ENV)/bin/python
RSA_KEY_PATH := ${HOME}/.ssh/${PKG_NAME}_gitlab_runner_id_rsa
build/envs.txt: requirements/conda.txt
@mkdir -p build/;
@ -129,10 +131,6 @@ build/deps.txt: build/envs.txt requirements/*.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
.PHONY: help
help:
@ -204,8 +202,12 @@ clean:
@printf "\n setup/update completed ✨ 🍰 ✨ \n\n"
## Force update of dependencies
## (this removes makefile markers)
## Force update of dependencies by removing marker files
## 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
force:
rm -f build/envs.txt
@ -293,12 +295,12 @@ test:
@rm -rf "src/__pycache__";
@rm -rf "test/__pycache__";
ENV=dev PYTHONPATH=src/:vendor/:$$PYTHONPATH \
ENV=${ENV-dev} PYTHONPATH=src/:vendor/:$$PYTHONPATH \
$(DEV_ENV_PY) -m pytest -v \
--doctest-modules \
--cov-report html \
--cov-report term \
--cov=$(PKG_NAME) \
$(shell ls -1 src/ | awk '{ print "--cov "$$1 }') \
test/ src/;
@rm -rf ".pytest_cache";
@ -319,7 +321,7 @@ check: fmt lint mypy test
env:
@bash --init-file <(echo '\
source $$HOME/.bashrc; \
export ENV=dev; \
export ENV=${ENV-dev}; \
export PYTHONPATH="src/:vendor/:$$PYTHONPATH"; \
conda activate $(DEV_ENV_NAME) \
')
@ -341,7 +343,7 @@ devtest:
ifndef FILTER
ENV=dev PYTHONPATH=src/:vendor/:$$PYTHONPATH \
ENV=${ENV-dev} PYTHONPATH=src/:vendor/:$$PYTHONPATH \
$(DEV_ENV_PY) -m pytest -v \
--doctest-modules \
--no-cov \
@ -350,7 +352,7 @@ ifndef FILTER
--exitfirst \
test/ src/;
else
ENV=dev PYTHONPATH=src/:vendor/:$$PYTHONPATH \
ENV=${ENV-dev} PYTHONPATH=src/:vendor/:$$PYTHONPATH \
$(DEV_ENV_PY) -m pytest -v \
--doctest-modules \
--no-cov \
@ -370,22 +372,25 @@ endif
## Generate Documentation
.PHONY: doc
doc:
echo "Not Implemented"
# .PHONY: doc
# doc:
# echo "Not Implemented"
## Bump Version number in all files
.PHONY: bump_version
bump_version:
echo "Not Implemented"
# .PHONY: bump_version
# bump_version:
# echo "Not Implemented"
## Freeze dependencies of the current development env
## These dependencies are used for the docker image
.PHONY: freeze
freeze:
echo "Not Implemented"
## Freeze dependencies of the current development env.
## The requirements files this produces should be used
## in order to have reproducable builds, otherwise you
## should minimize the number of pinned versions in
## your requirements.
# .PHONY: freeze
# freeze:
# echo "Not Implemented"
## 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
## (which is needed to install packages from private repos
## and is copied into a temp container during the build).
## 2. Your docker daemon is not running or configured to
## expose on tcp://localhost:2375
## 3. Your shell is not configured to connect to your docker
## daemon via "export DOCKER_HOST=localhost:2375"
## 2. Your docker daemon is not running
## 3. You're using WSL and docker is not exposed on tcp://localhost:2375
## 4. You're using WSL but didn't do export DOCKER_HOST="tcp://localhost:2375"
.PHONY: build_docker
build_docker:
@if [[ -f $$HOME/.ssh/${PKG_NAME}_gitlab_runner_id_rsa ]]; then \
@if [[ -f "${RSA_KEY_PATH}" ]]; then \
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 \
--tag $(DOCKER_REGISTRY_URL)/base:latest \
.; \

View file

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