diff --git a/.github/workflows/doc.yaml b/.github/workflows/doc.yaml index e93b84d..fb9b59d 100644 --- a/.github/workflows/doc.yaml +++ b/.github/workflows/doc.yaml @@ -14,10 +14,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.10' - name: Set up cache uses: actions/cache@v2 with: diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 943f059..56d3cb1 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -15,10 +15,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.8 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: '3.8' + python-version: '3.10' - name: Pip Update run: | make -s update-pip diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e2d3a3e..82555e6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: - package - doc -image: python:3.8 +image: python:3.10 lint: stage: lint diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 829cb68..9443ffb 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,7 @@ repos: args: ["--config=pyproject.toml"] - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.252 + rev: v0.0.262 hooks: - id: ruff diff --git a/.rtx.toml b/.rtx.toml new file mode 100644 index 0000000..99923a1 --- /dev/null +++ b/.rtx.toml @@ -0,0 +1,6 @@ +# rtx settings set experimental true +[tools] +# poetry = {version='latest', pyproject='pyproject.toml'} +poetry = '1.4.2' +# python = '3.10' +python = {version = "3.10", virtualenv = ".venv"} # must be after poetry so the poetry bin is first in PATH diff --git a/Makefile b/Makefile index a2cedbe..3cdc860 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ SHELL=/bin/bash ROOT_DIR=python-template PACKAGE=python_template PYTHON = python -PYTHON_VERSION=3.8 +PYTHON_VERSION=3.10 DOC_DIR=./docs TEST_DIR=./tests TEST_MARKER=placeholder @@ -22,12 +22,22 @@ help: awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m\ %s\n", $$1, $$2}' +# If .env file exists, include it and export its variables +ifeq ($(shell test -f .env && echo 1),1) + include .env + export +endif + +python-info: ## List information about the python environment + @which ${PYTHON} + @${PYTHON} --version + update-pip: ${PYTHON} -m pip install -U pip install-poetry: ## Install poetry if it is not already installed (Installing poetry with official method is recommended) $(MAKE) update-pip - ! command -v poetry &> /dev/null && pip install poetry==1.3.2 + ! command -v poetry &> /dev/null && pip install poetry==1.4.2 # poetry config virtualenvs.create false # poetry config repositories.private-pypi # poetry config http-basic.private-pypi ${PYPI_USERNAME} ${PYPI_PASSWORD} @@ -75,7 +85,7 @@ install-precommit: ## Install pre-commit hooks pre-commit install install-lint: - pip install black[d]==23.1.0 ruff==0.0.252 + pip install black[d]==23.1.0 ruff==0.0.262 install-build: ############# PIP ############ diff --git a/README.md b/README.md index 342dd9c..09b65f6 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ curl -sSL https://install.python-poetry.org | python3 - - Install the project dependencies ```bash -conda create -n python-template python=3.8 -y +conda create -n python-template python=3.10 -y conda activate python-template make -s install ``` diff --git a/docker/Dockerfile b/docker/Dockerfile index 856b4be..97f71c3 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -4,7 +4,7 @@ ARG APP_NAME=python_template ARG APP_PATH=/opt/$APP_NAME ARG PYTHON_VERSION=3.10-slim-bullseye -ARG POETRY_VERSION=1.3.2 +ARG POETRY_VERSION=1.4.2 # # Stage: staging @@ -22,7 +22,8 @@ ENV \ POETRY_VERSION=$POETRY_VERSION \ POETRY_HOME="/opt/poetry" \ POETRY_VIRTUALENVS_IN_PROJECT=true \ - POETRY_NO_INTERACTION=1 + POETRY_NO_INTERACTION=1 \ + POETRY_INSTALLER_MAX_WORKERS=10 RUN apt-get update && \ apt-get install --no-install-recommends -y \ @@ -36,6 +37,7 @@ ENV PATH="$POETRY_HOME/bin:$PATH" # Import our project files WORKDIR $APP_PATH COPY ./poetry.lock ./pyproject.toml ./ +RUN poetry install --no-root COPY . . # diff --git a/poetry.lock b/poetry.lock index c4eafbf..4197237 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. [[package]] name = "aiohttp" @@ -1773,29 +1773,29 @@ jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "ruff" -version = "0.0.252" +version = "0.0.262" description = "An extremely fast Python linter, written in Rust." category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.0.252-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:349367a227c4db7abbc3a9993efea8a608b5bea4bb4a1e5fc6f0d56819524f92"}, - {file = "ruff-0.0.252-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:ce77f9106d96b4faf7865860fb5155b9deaf6f699d9c279118c5ad947739ecaf"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:edadb0b050293b4e60dab979ba6a4e734d9c899cbe316a0ee5b65e3cdd39c750"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4efdae98937d1e4d23ab0b7fc7e8e6b6836cc7d2d42238ceeacbc793ef780542"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:c8546d879f7d3f669379a03e7b103d90e11901976ab508aeda59c03dfd8a359e"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:83fdc7169b6c1fb5fe8d1cdf345697f558c1b433ef97df9ca11defa2a8f3ee9e"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:84ed9be1a17e2a556a571a5b959398633dd10910abd8dcf8b098061e746e892d"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:6f5e77bd9ba4438cf2ee32154e2673afe22f538ef29f5d65ca47e3dc46c42cf8"}, - {file = "ruff-0.0.252-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a5179b94b45c0f8512eaff3ab304c14714a46df2e9ca72a9d96084adc376b71"}, - {file = "ruff-0.0.252-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:92efd8a71157595df5bc46aaaa0613d8a2fbc5cddc53ae7b749c16025c324732"}, - {file = "ruff-0.0.252-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fd350fc10832cfd28e681d829a8aa83ea3e653326e0ea9d98637dfb8d46177d2"}, - {file = "ruff-0.0.252-py3-none-musllinux_1_2_i686.whl", hash = "sha256:f119240c9631216e846166e06023b1d878e25fbac93bf20da50069e91cfbfaee"}, - {file = "ruff-0.0.252-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:5c5a49f89f5ede93d16eddfeeadd7e5739ec703e8f63ac95eac30236b9e49da3"}, - {file = "ruff-0.0.252-py3-none-win32.whl", hash = "sha256:89a897dc743f2fe063483ea666097e72e848f4bbe40493fe0533e61799959f6e"}, - {file = "ruff-0.0.252-py3-none-win_amd64.whl", hash = "sha256:cdc89ad6ff88519b1fb1816ac82a9ad910762c90ff5fd64dda7691b72d36aff7"}, - {file = "ruff-0.0.252-py3-none-win_arm64.whl", hash = "sha256:4b594a17cf53077165429486650658a0e1b2ac6ab88954f5afd50d2b1b5657a9"}, - {file = "ruff-0.0.252.tar.gz", hash = "sha256:6992611ab7bdbe7204e4831c95ddd3febfeece2e6f5e44bbed044454c7db0f63"}, + {file = "ruff-0.0.262-py3-none-macosx_10_7_x86_64.whl", hash = "sha256:c26c1abd420d041592d05d63aee8c6a18feb24aed4deb6e91129e9f2c7b4914a"}, + {file = "ruff-0.0.262-py3-none-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:b379e9765afa679316e52288a942df085e590862f8945088936a7bce3116d8f3"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:9b7e0ca6821aafbd2b059df3119fcd5881250721ca8e825789fd2c471f7c59be"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:4cca35e2aeddff72bb4379a1dabc134e0c0d25ebc754a2cb733a1f8d4dbbb5e0"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:15bf5533ce169aebbafa00017987f673e879f60a625d932b464b8cdaf32a4fce"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:3909e249d984c4517194005a1c30eaa0c3a6d906c789d9fc0c9c7e007fb3e759"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:4e2813013a19b3e147e840bdb2e42db5825b53b47364e58e7b467c5fa47ffda2"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d25a94996b2037e566c2a801c8b324c0a826194d5d4d90ad7c1ccb8cf06521fa"}, + {file = "ruff-0.0.262-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:85ca04348372efc59f6ee808d903d35e0d352cf2c78e487757cd48b65104b83e"}, + {file = "ruff-0.0.262-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:24f989363e9bb5d0283490298102a5218682e49ebf300e445d69e24bee03ac83"}, + {file = "ruff-0.0.262-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:3c24e678e43ca4b67e29cc9a7a54eea05f31a5898cbf17bfec47b68f08d32a60"}, + {file = "ruff-0.0.262-py3-none-musllinux_1_2_i686.whl", hash = "sha256:0baff3c9a22227358ea109c165efe62dbdd0f2b9fd5256567dda8682b444fe23"}, + {file = "ruff-0.0.262-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:083bac6e238d8b7d5ac3618666ea63b7ac661cf94c5da160070a58e190082831"}, + {file = "ruff-0.0.262-py3-none-win32.whl", hash = "sha256:15bbfa2d15c137717627e0d56b0e535ae297b734551e34e03fcc25d7642cf43a"}, + {file = "ruff-0.0.262-py3-none-win_amd64.whl", hash = "sha256:973ac29193f718349cf5746b7d86dfeaf7d40e9651ed97790a9b9327305888b9"}, + {file = "ruff-0.0.262-py3-none-win_arm64.whl", hash = "sha256:f102904ebe395acd2a181d295b98120acd7a63f732b691672977fc688674f4af"}, + {file = "ruff-0.0.262.tar.gz", hash = "sha256:faea54231c265f5349975ba6f3d855b71881a01f391b2000c47740390c6d5f68"}, ] [[package]] @@ -2144,4 +2144,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.8,<3.12" -content-hash = "4ec5ebc83450771d787d400e6abb6b3a85372d84c62153b2e7877a050517c3bf" +content-hash = "36a4211a9b4aa36f1613bcfd4975e9b2f212fa7b7675294def026d9e64f108c2" diff --git a/poetry.toml b/poetry.toml index 084377a..9f8ebc4 100644 --- a/poetry.toml +++ b/poetry.toml @@ -1,2 +1,4 @@ [virtualenvs] create = false +in-project = true +prefer-active-python = true diff --git a/pyproject.toml b/pyproject.toml index d4d938c..d983f02 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,7 +67,7 @@ mkdocstrings = {version = "^0.20.0", extras = ["python"]} [tool.poetry.group.dev.dependencies] pre-commit = "^2.19.0" -ruff = "0.0.252" +ruff = "0.0.262" black = {version = "23.1.0", extras = ["d", "jupyter"]} mypy = "^1.0.0" scalene = "^1.5.19" @@ -113,22 +113,23 @@ target-version = "py38" # required-version = "0.0.238" line-length = 88 select = [ + "B", # flake8-bugbear + "C", # flake8-comprehensions + "C9", # mccabe + "D", # flake8-docstrings "E", # pycodestyle errors (default) "F", # pyflakes (default) - "W", # pycodestyle warnings - "I001", # isort - "C", # flake8-comprehensions - "B", # flake8-bugbear + "I", # isort + "PD", # pandas-vet + "PIE", # pie + "PL", # pylint + "PTH", # pathlib "Q", # flake8-quotes - "D", # flake8-docstrings - "T", # (disallow print statements) keep debugging statements out of the codebase + "RET", # return "RUF", # Enable all ruff-specific checks - # (pylint) use all pylint rules (ruff currently implements only a subset of - # pylint's rules) - "PLC", - "PLE", - "PLR", - "PLW", + "SIM", # simplify + "T20", # (disallow print statements) keep debugging statements out of the codebase + "W", # pycodestyle warnings ] #extend-select = [] respect-gitignore = true @@ -140,8 +141,6 @@ ignore-init-module-imports = true # ignore = [] extend-ignore = [ "E501", # Line too long, handled by black - # "B008", # Do not perform function calls in argument defaults - # "C901", # Too complex "D107", # "Missing docstring in __init__", ] extend-exclude = [ diff --git a/pyproject_pip.toml b/pyproject_pip.toml index c30725b..723aee4 100644 --- a/pyproject_pip.toml +++ b/pyproject_pip.toml @@ -58,7 +58,7 @@ doc = [ dev = [ "black[d]==23.1.0", - "ruff==0.0.252", + "ruff==0.0.262", "pre-commit", "mypy", # "build", # NOTE: Uncomment if using pip instead of poetry. diff --git a/python_template/scripts/placeholder.py b/python_template/scripts/placeholder.py index e2262f7..b4a5fe9 100644 --- a/python_template/scripts/placeholder.py +++ b/python_template/scripts/placeholder.py @@ -6,4 +6,4 @@ def placeholder_script(): More detail: https://setuptools.pypa.io/en/latest/userguide/entry_point.html """ - print("This is a placeholder script that can be run as `entry point`") + print("This is a placeholder script that can be run as `entry point`") # noqa: T201