Skip to content

Commit

Permalink
Adds version to setup requirements and generalizes make targets
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Matyasek committed May 12, 2019
1 parent 72382f3 commit 8d5ce80
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 31 deletions.
54 changes: 33 additions & 21 deletions Makefile
@@ -1,60 +1,72 @@
.PHONY: help build clean setup install release-check type-check flake8-check lint tests twine-release-test
.PHONY: help build clean setup setup-system install install-system release-check type-check flake8-check lint tests twine-release-test

.DEFAULT: help
help:
@echo "make build"
@echo "make [py=/path/to/python] build"
@echo " build distribution directories"
@echo "make clean"
@echo " clean distribution directories"
@echo "make setup"
@echo " setup development environment"
@echo "make install"
@echo " install dependencies"
@echo "make type-check"
@echo "make [py=/path/to/python] setup"
@echo " setup development environment, optionally using provided python"
@echo "make setup-system"
@echo " setup development environment using system python"
@echo "make [py=/path/to/python] install"
@echo " install dependencies, optionally using provided python"
@echo "make install-system"
@echo " install dependencies using system python"
@echo "make [py=/path/to/python] type-check"
@echo " run mypy type checking"
@echo "make flake8-check"
@echo "make [py=/path/to/python] flake8-check"
@echo " run flake8 code style check"
@echo "make lint"
@echo "make [py=/path/to/python] lint"
@echo " run pylint"
@echo "make tests"
@echo "make [py=/path/to/python] tests"
@echo " run unit and doc tests"
@echo "make release-check"
@echo " run type-check, flake8 check, linting and tests"
@echo "make twine-release-test"
@echo "make [py=/path/to/python] coverage-check"
@echo " run test coverage check"
@echo "make [py=/path/to/python] release-check"
@echo " run type-check, flake8 check, linting, tests and coverage check"
@echo "make [py=/path/to/python] twine-release-test"
@echo " release ftoolz to test pypi using twine"

build: clean
@echo ">>> building ftoolz distribution"
pipenv run build
pipenv $(if $(py),--python $(py) --site-packages ,)run build

clean:
rm -rf dist
rm -rf build
rm -rf *.egg-info

setup:
pipenv install --dev
pipenv install --dev $(if $(py),--python $(py),)

setup-system:
pipenv install --dev --system --deploy

install:
pipenv install
pipenv install $(if $(py),--python $(py),)

install-system:
pipenv install --system --deploy

type-check:
@echo ">>> checking types in ftoolz and tests"
pipenv run type-check || ( echo ">>> type check failed"; exit 1; )
pipenv $(if $(py),--python $(py) --site-packages ,)run type-check || ( echo ">>> type check failed"; exit 1; )

flake8-check:
@echo ">>> enforcing PEP 8 style with flake8 in ftoolz and tests"
pipenv run flake8-check || ( echo ">>> flake8 check failed"; exit 1; )
pipenv $(if $(py),--python $(py) --site-packages ,)run flake8-check || ( echo ">>> flake8 check failed"; exit 1; )

lint:
@echo ">>> linting code"
pipenv run lint || ( echo ">>> linting failed"; exit 1; )
pipenv $(if $(py),--python $(py) --site-packages ,)run lint || ( echo ">>> linting failed"; exit 1; )

tests:
@echo ">>> running tests"
pipenv run tests || ( echo ">>> tests failed"; exit 1; )
pipenv $(if $(py),--python $(py) --site-packages ,)run tests || ( echo ">>> tests failed"; exit 1; )

release-check: type-check flake8-check lint tests

twine-release-test: build
pipenv run release-test
pipenv $(if $(py),--python $(py) --site-packages ,)run release-test
21 changes: 11 additions & 10 deletions setup.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python

import json
from os.path import exists
from typing import Sequence

from setuptools import find_packages, setup
from setuptools.dist import Distribution
Expand All @@ -18,15 +20,14 @@ def has_ext_modules(self) -> bool:
with open('Pipfile.lock') as pipfile_lock:
lock_data = json.load(pipfile_lock)

requirements = [
package_name
for package_name in lock_data['default'].keys()
]

test_requirements = [
package_name
for package_name in lock_data['develop'].keys()
]
def requirements(section: str) -> Sequence[str]:
"""List versioned requirements from given section of Pipfile.lock"""
return [
f"{package_name}{package_data['version']}"
for package_name, package_data in lock_data[section].items()
]


setup(
name='ftoolz',
Expand Down Expand Up @@ -55,7 +56,7 @@ def has_ext_modules(self) -> bool:
distclass=BinaryDistribution,
zip_safe=False,
python_requires='>=3.6',
install_requires=requirements,
install_requires=requirements('default'),
test_suite='tests',
tests_require=test_requirements,
tests_require=requirements('develop'),
)

0 comments on commit 8d5ce80

Please sign in to comment.