Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
grimen committed Nov 18, 2018
0 parents commit db7af62
Show file tree
Hide file tree
Showing 30 changed files with 1,708 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
indent_style = tab
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
23 changes: 23 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Basic .gitattributes for a python repo.

# Source files
# ============
*.pxd text
*.py text
*.py3 text
*.pyw text
*.pyx text

# Binary files
# ============
*.db binary
*.p binary
*.pkl binary
*.pyc binary
*.pyd binary
*.pyo binary

# Note: .db, .p, and .pkl files are associated
# with the python modules ``pickle``, ``dbm.*``,
# ``shelve``, ``marshal``, ``anydbm``, & ``bsddb``
# (among others).
117 changes: 117 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

# line_profiler
*.prof
*.lprof

# memory_profiler
mprofile*

# node deps
node_modules
npm*.log
yarn*.log

9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: python
python:
- "2.7"
- "3.6"
- "3.7"
install: make install-ci
script: make test-ci
notifications:
email: false
19 changes: 19 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2018 Jonas Grimfelt <grimen@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
180 changes: 180 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@

# =========================================
# meta
# --------------------------------------

NAME := "rootpath"
BRANCH := $(shell git for-each-ref --format='%(objectname) %(refname:short)' refs/heads | awk "/^$$(git rev-parse HEAD)/ {print \$$2}")
HASH := $(shell git rev-parse HEAD)
DATETIME := $(shell date | sed 's/ /./g')


# =========================================
# default
# --------------------------------------

all: test


# =========================================
# clean
# --------------------------------------

.PHONY: clean
clean:
CLEAR_PATTERNS='*.pyc __pycache__ build dist *.egg-info .tox'; \
for PATTERN in $$CLEAR_PATTERNS; do \
echo "rm -rf \$$(find $$PWD -name $$PATTERN)"; \
rm -rf $$(find $$PWD -name $$PATTERN); \
done


# =========================================
# install (pip)
# --------------------------------------

.PHONY: install
install:
PYTHON_USER_FLAG=$(shell python -c "import sys; print('' if hasattr(sys, 'real_prefix') or hasattr(sys, 'base_prefix') else '--user')") && \
pip install $(PYTHON_USER_FLAG) -r requirements.txt

.PHONY: install-ci
install-ci:
PYTHON_USER_FLAG=$(shell python -c "import sys; print('' if hasattr(sys, 'real_prefix') or hasattr(sys, 'base_prefix') else '--user')") && \
pip install $(PYTHON_USER_FLAG) -U setuptools setuptools-git tox tox-travis && \
pip install $(PYTHON_USER_FLAG) -r requirements.txt


# =========================================
# build + release (pip)
# --------------------------------------

.PHONY: build
build:
rm -rf ./dist && \
PYTHON_USER_FLAG=$(shell python -c "import sys; print('' if hasattr(sys, 'real_prefix') or hasattr(sys, 'base_prefix') else '--user')") && \
python -m pip install $(PYTHON_USER_FLAG) --upgrade setuptools wheel && \
python setup.py sdist bdist_wheel

.PHONY: dist
dist: build
python -m pip install $(PYTHON_USER_FLAG) --upgrade twine && \
twine upload dist/*

.PHONY: dist-dev
dist-dev: build
python -m pip install $(PYTHON_USER_FLAG) --upgrade twine && \
twine upload --repository-url https://test.pypi.org/legacy/ dist/*


# =========================================
# test
# --------------------------------------

.PHONY: test
test: test-python2 test-python3

test-python2: clean env2
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
(pyenv activate $(NAME)-python3 || (echo "NOTE: Could not activate virtual Python environment `$NAME-python2` - creating..." && make env-create-python2 && pyenv activate $(NAME)-python2)) && \
python ./$(NAME)/tests

test-python3: clean env3
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
(pyenv activate $(NAME)-python3 || (echo "NOTE: Could not activate virtual Python environment `$NAME-python2` - creating..." && make env-create-python3 && pyenv activate $(NAME)-python3)) && \
python ./$(NAME)/tests

.PHONY: test-tox
test-tox:
tox

.PHONY: test-ci
test-ci: test-tox

.PHONY: testimport
testimport:
pip uninstall -y $(NAME) && \
pip install -U . && \
python -c "import $(NAME); print('$(NAME)', $(NAME))" && \
echo "OK"


# =========================================
# environment (pyenv)
# --------------------------------------

.PHONY: env-install
env-install:
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

.PHONY: env-install-osx
env-install-osx:
brew install pyenv pyenv-virtualenv

.PHONY: env-install-linux
env-install-linux:
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash

.PHONY: env-create
env-create: env-create-python2 env-create-python3

.PHONY: env-create-python2
env-create-python2:
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
pyenv virtualenv -f $(PYTHON_2_VERSION) $(NAME)-python2 && \
pyenv activate $(NAME)-python2 && \
pip install -U -r requirements.txt && \
pyenv versions | grep --color=always $(NAME)-python

.PHONY: env-create-python3
env-create-python3:
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
pyenv virtualenv -f $(PYTHON_3_VERSION) $(NAME)-python3 && \
pyenv activate $(NAME)-python3 && \
pip install -U -r requirements.txt && \
pyenv versions | grep --color=always $(NAME)-python

.PHONY: env-destroy
env-destroy: env-destroy-python2 env-destroy-python3

.PHONY: env-destroy-python2
env-destroy-python2:
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
pyenv shell system && \
pyenv uninstall -f $(NAME)-python2 && \
pyenv versions | grep --color=always $(NAME)-python

.PHONY: env-destroy-python3
env-destroy-python3:
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
pyenv shell system && \
pyenv uninstall -f $(NAME)-python3 && \
pyenv versions | grep --color=always $(NAME)-python

.PHONY: env-reset
env-reset:
pyenv shell system

.PHONY: env
env: env3

.PHONY: env2
env2:
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
pyenv activate $(NAME)-python2 && \
pyenv versions | grep --color=always $(NAME)-python

.PHONY: env3
env3:
eval "$$(pyenv init -)" && \
eval "$$(pyenv virtualenv-init -)" && \
pyenv activate $(NAME)-python3 && \
pyenv versions | grep --color=always $(NAME)-python

Loading

0 comments on commit db7af62

Please sign in to comment.