Skip to content

Commit

Permalink
Merge pull request #10 from BastiTee/feature/dev-0.2.0
Browse files Browse the repository at this point in the history
0.2.0 Development
  • Loading branch information
set-leanix authored Jan 17, 2023
2 parents f59f338 + 89d9010 commit c056b53
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 19 deletions.
44 changes: 30 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export LANG = C.UTF-8
PY_FILES := my_module tests
VERSION := $(shell poetry version --short)

# Bundle tasks

all: clean venv build
@echo Executed default build pipeline

# Clean up and set up

clean:
@echo Clean project base
Expand All @@ -28,6 +33,10 @@ clean:
-name "dist" \
|xargs rm -rfv

clear-cache:
@echo Clear poetry cache
$(POETRY_CMD) cache clear pypi --all --no-interaction

venv: clean
@echo Initialize virtualenv, i.e., install required packages etc.
$(POETRY_CMD) config virtualenvs.in-project true --local
Expand All @@ -37,10 +46,20 @@ shell:
@echo Open a new shell using virtualenv
$(POETRY_CMD) shell

# Building software

build: test mypy isort black lint
@echo Run build process to package application
$(POETRY_CMD) build

test:
@echo Run all tests suites
$(POETRY_CMD) run py.test tests

mypy:
@echo Run static code checks against source code base
$(POETRY_CMD) run mypy $(PY_FILES)

isort:
@echo Check for incorrectly sorted imports
$(POETRY_CMD) run isort --check-only $(PY_FILES)
Expand All @@ -49,10 +68,6 @@ isort-apply:
@echo Check and correct incorrectly sorted imports
$(POETRY_CMD) run isort $(PY_FILES)

mypy:
@echo Run static code checks against source code base
$(POETRY_CMD) run mypy $(PY_FILES)

black:
@echo Run code formatting using black
$(POETRY_CMD) run black $(PY_FILES)
Expand All @@ -61,20 +76,21 @@ lint:
@echo Run code formatting checks against source code base
$(POETRY_CMD) run flake8 $(PY_FILES)

build: test mypy isort black lint
@echo Run build process to package application
$(POETRY_CMD) build
# Executing and publishing

run:
@echo Execute package directly
run-venv:
@echo Execute package directly in virtual environment
$(POETRY_CMD) run python -m my_module

clear-cache:
@echo Clear poetry cache
$(POETRY_CMD) cache clear pypi --all --no-interaction
install-run:
@echo Install and run package via CLI using the activated Python env
python -m pip install --upgrade .
@echo --- Note: The next command might fail before you reload your shell
my_module_cli

publish:
@echo Release version $(VERSION) to pypi.org and create git tag
# $(POETRY_CMD) publish
@echo Release version $(VERSION)
git tag -a $(VERSION) -m "Version $(VERSION)"
git push --tags
# Uncomment the following line to integrate with pypi publishing
# $(POETRY_CMD) publish
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
## Setup

- [Use this template](https://github.com/BastiTee/python-boilerplate/generate).
- Create a new repository [using this template](https://github.com/BastiTee/python-boilerplate/generate).
- Make sure that `python` is installed and available on system path. I recommend using [`pyenv`](https://github.com/pyenv/pyenv). Note that Python 2 is _not_ supported. It's end of life was on January 1st, 2020.
- Make sure [`poetry`](https://python-poetry.org/) is installed. This usually just means `python -m pip install poetry`.
- On first checkout run `make` to initialize the project configuration and build everything.
- Rename the project using [the provided script](rename_template.sh): `./rename_template.sh`.
- Run `make` to initialize the project configuration and build everything.
- Refer to [the Makefile](Makefile) to learn about the various operations available. Most of them are just facades for `poetry`.
- To rename the project you can use [the provided script](rename_template.sh): `./rename_template.sh`

## Features

Expand All @@ -24,6 +24,7 @@
- Publishing to PyPi.org
- [vscode](https://code.visualstudio.com/) editor configuration including plugin recommendations, debugging support, unit test discovery and on-save formatting
- [Github actions](https://github.com/BastiTee/python-boilerplate/actions) continuous integration with multi-python testing
- Executable script so after package installation you can run from the CLI using `my_module_cli`

## Resources

Expand All @@ -39,7 +40,8 @@
## Future ideas and todos

- Embed flake8 config into `pyproject.toml` once they support it ([see](https://github.com/PyCQA/flake8/issues/234))
- Use cookiecutter instead of [shell script](./rename_template.sh) (it does work fine at the moment though)

## Licensing

This project is licensed under [Apache License 2.0](LICENSE.txt)
This project is licensed under [Apache License 2.0](LICENSE.txt).
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "my_module"
version = "0.1.0"
version = "0.2.0"
description = ""
license = "Apache 2.0"
authors = ["Basti Tee <[email protected]>"]
Expand Down Expand Up @@ -39,6 +39,9 @@ typing-extensions = "^4.2.0"
black = "^22.3.0"
pipdeptree = "^2.2.1"

[tool.poetry.scripts]
my_module_cli = 'my_module.__main__:main'

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Expand Down

0 comments on commit c056b53

Please sign in to comment.