forked from GazzolaLab/MiV-OS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adopt pyproject.toml and poetry packaging system
- Loading branch information
Showing
40 changed files
with
2,114 additions
and
357 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Check http://editorconfig.org for more information | ||
# This is the main config file for this project: | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 2 | ||
trim_trailing_whitespace = true | ||
|
||
[*.{py, pyi}] | ||
indent_style = space | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.{diff,patch}] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: publish | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python | ||
uses: actions/[email protected] | ||
with: | ||
python-version: "3.x" | ||
- name: Install Poetry | ||
uses: snok/[email protected] | ||
- name: Build | ||
run: | | ||
poetry build | ||
- name: Publish distribution 📦 to PyPI | ||
if: startsWith(github.ref, 'refs/tags') | ||
uses: pypa/gh-action-pypi-publish@master | ||
with: | ||
password: ${{ secrets.PYPI_API_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,43 @@ | ||
default_language_version: | ||
python: python3.8 | ||
|
||
default_stages: [commit, push] | ||
|
||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.3.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-json | ||
- id: end-of-file-fixer | ||
- id: requirements-txt-fixer | ||
- repo: https://github.com/psf/black | ||
rev: 21.12b0 | ||
hooks: | ||
- id: black | ||
additional_dependencies: ['click==8.0.4'] | ||
# args: [--line-length=120] | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 4.0.0 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v2.5.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-json | ||
- id: check-yaml | ||
- id: end-of-file-fixer | ||
exclude: LICENSE | ||
|
||
- repo: local | ||
hooks: | ||
- id: pyupgrade | ||
name: pyupgrade | ||
entry: poetry run pyupgrade --py37-plus | ||
types: [python] | ||
language: system | ||
|
||
- repo: local | ||
hooks: | ||
- id: isort | ||
name: isort | ||
entry: poetry run isort --settings-path pyproject.toml | ||
types: [python] | ||
language: system | ||
|
||
- repo: local | ||
hooks: | ||
- id: black | ||
name: black | ||
entry: poetry run black --config pyproject.toml | ||
types: [python] | ||
language: system | ||
|
||
- repo: https://github.com/pycqa/flake8 | ||
rev: 4.0.0 | ||
hooks: | ||
- id: flake8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,83 @@ | ||
#* Variables | ||
PYTHON := python | ||
PYTHONPATH := `pwd` | ||
|
||
#* Poetry | ||
.PHONY: poetry-download | ||
poetry-download: | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(PYTHON) - | ||
|
||
.PHONY: poetry-remove | ||
poetry-remove: | ||
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | $(PYTHON) - --uninstall | ||
|
||
#* Installation | ||
.PHONY: install | ||
install: | ||
poetry lock -n && poetry export --without-hashes > requirements.txt | ||
poetry install -n | ||
-poetry run mypy --install-types --non-interactive ./ | ||
|
||
.PHONY: pre-commit-install | ||
pre-commit-install: | ||
poetry run pre-commit install | ||
|
||
#* Formatters | ||
.PHONY: codestyle | ||
codestyle: | ||
poetry run pyupgrade --exit-zero-even-if-changed --py38-plus **/*.py | ||
poetry run isort --settings-path pyproject.toml ./ | ||
poetry run black --config pyproject.toml ./ | ||
|
||
.PHONY: formatting | ||
formatting: codestyle | ||
|
||
#* Linting | ||
.PHONY: test | ||
test: | ||
@python -m pytest | ||
PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=miv tests/ | ||
|
||
.PHONY: check-codestyle | ||
check-codestyle: | ||
poetry run isort --diff --check-only --settings-path pyproject.toml ./ | ||
poetry run black --diff --check --config pyproject.toml ./ | ||
poetry run darglint --verbosity 2 miv tests | ||
|
||
.PHONY: mypy | ||
mypy: | ||
@mypy --ignore-missing-imports miv | ||
poetry run mypy --config-file pyproject.toml ./ | ||
|
||
.PHONY: lint | ||
lint: test check-codestyle mypy check-safety | ||
|
||
.PHONY: update-dev-deps | ||
update-dev-deps: | ||
poetry add -D "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest coverage@latest pytest-html@latest pytest-cov@latest black@latest | ||
|
||
#* Cleaning | ||
.PHONY: pycache-remove | ||
pycache-remove: | ||
find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf | ||
|
||
.PHONY: dsstore-remove | ||
dsstore-remove: | ||
find . | grep -E ".DS_Store" | xargs rm -rf | ||
|
||
.PHONY: mypycache-remove | ||
mypycache-remove: | ||
find . | grep -E ".mypy_cache" | xargs rm -rf | ||
|
||
.PHONY: ipynbcheckpoints-remove | ||
ipynbcheckpoints-remove: | ||
find . | grep -E ".ipynb_checkpoints" | xargs rm -rf | ||
|
||
.PHONY: pytestcache-remove | ||
pytestcache-remove: | ||
find . | grep -E ".pytest_cache" | xargs rm -rf | ||
|
||
coverage: | ||
@pytest --cov=miv tests/ | ||
.PHONY: build-remove | ||
build-remove: | ||
rm -rf build/ | ||
|
||
all:test mypy coverage | ||
ci: test mypy | ||
.PHONY: cleanup | ||
cleanup: pycache-remove dsstore-remove mypycache-remove ipynbcheckpoints-remove pytestcache-remove |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# type: ignore[attr-defined] | ||
"""Python software for analysis and computing framework used in MiV project.""" | ||
|
||
import sys | ||
from importlib import metadata as importlib_metadata | ||
|
||
|
||
def get_version() -> str: | ||
try: | ||
return importlib_metadata.version(__name__) | ||
except importlib_metadata.PackageNotFoundError: # pragma: no cover | ||
return "unknown" | ||
|
||
|
||
version: str = get_version() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from miv.io.data import * | ||
from miv.io.binary import * | ||
from miv.io.data import * |
Oops, something went wrong.