-
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.
Merge pull request #158 from jedie/make-uv-python
Make uv python
- Loading branch information
Showing
37 changed files
with
4,002 additions
and
6 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
23 changes: 23 additions & 0 deletions
23
generated_templates/make-uv-python/your_cool_package/.editorconfig
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,23 @@ | ||
# see https://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 4 | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.{html,css,js}] | ||
insert_final_newline = false | ||
|
||
[*.py] | ||
max_line_length = 119 | ||
|
||
[{Makefile,**.mk}] | ||
indent_style = tab | ||
insert_final_newline = false | ||
|
||
[{*.yaml,*.yml}] | ||
indent_size = 2 |
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,7 @@ | ||
# | ||
# Move to pyproject.toml after: https://github.com/PyCQA/flake8/issues/234 | ||
# | ||
[flake8] | ||
exclude = .*, dist, htmlcov | ||
#ignore = E402 | ||
max-line-length = 119 |
52 changes: 52 additions & 0 deletions
52
generated_templates/make-uv-python/your_cool_package/.github/workflows/tests.yml
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,52 @@ | ||
|
||
|
||
name: tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
schedule: | ||
- cron: '0 8 * * *' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: ["3.12", "3.11"] | ||
steps: | ||
- name: Checkout | ||
run: | | ||
echo $GITHUB_REF $GITHUB_SHA | ||
git clone https://github.com/$GITHUB_REPOSITORY.git . | ||
git fetch origin $GITHUB_SHA:temporary-ci-branch | ||
git checkout $GITHUB_SHA || (git fetch && git checkout $GITHUB_SHA) | ||
- name: 'Set up Python ${{ matrix.python-version }}' | ||
uses: actions/setup-python@v5 | ||
# https://github.com/marketplace/actions/setup-python | ||
with: | ||
python-version: '${{ matrix.python-version }}' | ||
cache: 'pip' # caching pip dependencies | ||
|
||
- name: 'Install' | ||
run: | | ||
make install | ||
- name: 'Run tests with Python v${{ matrix.python-version }}' | ||
env: | ||
PYTHONUNBUFFERED: 1 | ||
PYTHONWARNINGS: always | ||
run: | | ||
make coverage | ||
- name: 'Upload coverage report' | ||
uses: codecov/codecov-action@v4 | ||
# https://github.com/marketplace/actions/codecov | ||
with: | ||
fail_ci_if_error: false | ||
verbose: true | ||
|
13 changes: 13 additions & 0 deletions
13
generated_templates/make-uv-python/your_cool_package/.gitignore
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,13 @@ | ||
.* | ||
*.egg-info | ||
__pycache__ | ||
/dist/ | ||
/build/ | ||
/coverage.* | ||
*.orig | ||
|
||
!.github | ||
!.editorconfig | ||
!.flake8 | ||
!.gitignore | ||
!.gitkeep |
67 changes: 67 additions & 0 deletions
67
generated_templates/make-uv-python/your_cool_package/Makefile
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,67 @@ | ||
SHELL := /bin/bash | ||
export PATH := .venv/bin:$(PATH) | ||
|
||
all: help | ||
|
||
help: ## List all commands | ||
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9 -_]+:.*?## / {printf "\033[36m%-26s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | ||
|
||
install-base-req: ## Install needed base packages via apt | ||
sudo apt install python3-pip python3-venv | ||
|
||
install: ## Install the project in a Python virtualenv | ||
python3 -m venv .venv | ||
.venv/bin/pip install -U pip | ||
.venv/bin/pip install -U uv | ||
.venv/bin/uv sync | ||
|
||
update-requirements: ## Update requirements | ||
python3 -m venv .venv | ||
.venv/bin/pip install -U pip | ||
.venv/bin/pip install -U uv | ||
.venv/bin/uv lock --upgrade | ||
.venv/bin/uv sync | ||
|
||
lint: ## Run code formatters and linter | ||
.venv/bin/darker --diff --check | ||
.venv/bin/flake8 . | ||
|
||
fix-code-style: ## Fix code formatting | ||
.venv/bin/darker | ||
.venv/bin/flake8 . | ||
|
||
tox-listenvs: ## List all tox test environments | ||
.venv/bin/tox --listenvs | ||
|
||
tox: ## Run tests via tox with all environments | ||
.venv/bin/tox | ||
|
||
test: ## Run tests | ||
.venv/bin/python3 -m unittest --verbose --locals | ||
|
||
coverage: ## Run tests with coverage | ||
.venv/bin/coverage run | ||
.venv/bin/coverage combine --append | ||
.venv/bin/coverage report | ||
.venv/bin/coverage xml | ||
.venv/bin/coverage json | ||
|
||
update-test-snapshot-files: ## Update all snapshot files (by remove and recreate all snapshot files) | ||
find . -type f -name '*.snapshot.*' -delete | ||
RAISE_SNAPSHOT_ERRORS=0 .venv/bin/python3 -m unittest | ||
|
||
mypy: ## Run mypy | ||
.venv/bin/mypy . | ||
|
||
pip-audit: ## Run https://github.com/pypa/pip-audit | ||
.venv/bin/uv export --no-header --frozen --no-editable --no-emit-project -o /tmp/temp_requirements.txt | ||
.venv/bin/pip-audit --strict --require-hashes -r /tmp/temp_requirements.txt | ||
|
||
publish: ## Release new version to PyPi | ||
.venv/bin/pip install -e . | ||
.venv/bin/python3 your_cool_package_tests/publish.py | ||
|
||
clean: ## Remove created files from the test project | ||
git clean -dfX your_cool_package_tests/ | ||
|
||
.PHONY: help install lint fix publish test clean |
9 changes: 9 additions & 0 deletions
9
generated_templates/make-uv-python/your_cool_package/README.md
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,9 @@ | ||
# your_cool_package | ||
|
||
[![tests](https://github.com/john-doh/your_cool_package/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/john-doh/your_cool_package/actions/workflows/tests.yml) | ||
[![codecov](https://codecov.io/github/john-doh/your_cool_package/branch/main/graph/badge.svg)](https://app.codecov.io/github/john-doh/your_cool_package) | ||
[![your_cool_package @ PyPi](https://img.shields.io/pypi/v/your_cool_package?label=your_cool_package%20%40%20PyPi)](https://pypi.org/project/your_cool_package/) | ||
[![Python Versions](https://img.shields.io/pypi/pyversions/your_cool_package)](https://github.com/john-doh/your_cool_package/blob/main/pyproject.toml) | ||
[![License GPL-3.0-or-later](https://img.shields.io/pypi/l/your_cool_package)](https://github.com/john-doh/your_cool_package/blob/main/LICENSE) | ||
|
||
A minimal Python package |
124 changes: 124 additions & 0 deletions
124
generated_templates/make-uv-python/your_cool_package/pyproject.toml
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,124 @@ | ||
[project] | ||
name = "your_cool_package" | ||
dynamic = ["version"] | ||
description = "A minimal Python package" | ||
license = {text = "GPL-3.0-or-later"} | ||
readme = "README.md" | ||
authors = [ | ||
{name = 'John Doh', email = '[email protected]'} | ||
] | ||
requires-python = ">=3.11" | ||
dependencies = [] | ||
[dependency-groups] | ||
dev = [ | ||
"manageprojects", # https://github.com/jedie/manageprojects | ||
"urllib3", # for bx_py_utils.test_utils.deny_requests.deny_any_real_request() in tests | ||
"uv", # https://github.com/astral-sh/uv | ||
"tox", # https://github.com/tox-dev/tox | ||
"tox-uv", # https://github.com/tox-dev/tox-uv | ||
"coverage", # https://github.com/nedbat/coveragepy | ||
"autopep8", # https://github.com/hhatto/autopep8 | ||
"pyupgrade", # https://github.com/asottile/pyupgrade | ||
"flake8", # https://github.com/pycqa/flake8 | ||
"flake8-bugbear", # https://github.com/PyCQA/flake8-bugbear | ||
"pyflakes", # https://github.com/PyCQA/pyflakes | ||
"codespell", # https://github.com/codespell-project/codespell | ||
"EditorConfig", # https://github.com/editorconfig/editorconfig-core-py | ||
"pip-audit", # https://github.com/pypa/pip-audit | ||
"mypy", # https://github.com/python/mypy | ||
"twine", # https://github.com/pypa/twine | ||
"typeguard", # https://github.com/agronholm/typeguard/ | ||
|
||
# https://github.com/akaihola/darker | ||
# https://github.com/ikamensh/flynt | ||
# https://github.com/pycqa/isort | ||
# https://github.com/pygments/pygments | ||
"darker[flynt, isort, color]", | ||
|
||
# Work-a-round for: https://github.com/jazzband/pip-tools/issues/1866 | ||
# see also: https://github.com/jazzband/pip-tools/issues/994#issuecomment-1321226661 | ||
# backports.tarfile is needed for python <3.12 | ||
'backports.tarfile', # via jaraco-context -> keyring -> twine | ||
] | ||
|
||
[project.urls] | ||
Documentation = "https://github.com/john-doh/your_cool_package/" | ||
Source = "https://github.com/john-doh/your_cool_package/" | ||
|
||
[project.scripts] | ||
your_cool_package = "your_cool_package.__main__:main" | ||
|
||
[build-system] | ||
requires = ["setuptools>=61.0", "setuptools_scm>=7.1"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
include = ["your_cool_package*"] | ||
|
||
[tool.setuptools.dynamic] | ||
version = {attr = "your_cool_package.__version__"} | ||
|
||
|
||
[tool.darker] | ||
src = ['.'] | ||
revision = "origin/main..." | ||
line_length = 119 | ||
color = true | ||
skip_string_normalization = true | ||
diff = false | ||
check = false | ||
stdout = false | ||
isort = true | ||
lint = [] | ||
log_level = "INFO" | ||
|
||
|
||
[tool.isort] | ||
profile = "black" | ||
|
||
|
||
[tool.pytest.ini_options] | ||
filterwarnings = [] | ||
|
||
|
||
[tool.coverage.run] | ||
branch = true | ||
parallel = true | ||
source = ['.'] | ||
concurrency = ["multiprocessing"] | ||
command_line = "-m unittest --locals --verbose" | ||
|
||
[tool.coverage.report] | ||
omit = ['.*', '*/tests/*'] | ||
skip_empty = true | ||
fail_under = 30 | ||
show_missing = true | ||
exclude_lines = [ | ||
'if self.debug:', | ||
'pragma: no cover', | ||
'raise NotImplementedError', | ||
'if __name__ == .__main__.:', | ||
] | ||
|
||
|
||
[tool.tox] # https://tox.wiki/en/latest/config.html#pyproject-toml | ||
isolated_build = true | ||
env_list = ["3.13", "3.12", "3.11"] | ||
skip_missing_interpreters = true | ||
|
||
[tool.tox.env_run_base] | ||
runner = "uv-venv-lock-runner" | ||
with_dev = true | ||
commands = [ | ||
["python3", "-m", "coverage", "run", "--context", "'{envname}'"] | ||
] | ||
|
||
|
||
[tool.mypy] | ||
warn_unused_configs = true | ||
ignore_missing_imports = true | ||
allow_redefinition = true # https://github.com/python/mypy/issues/7165 | ||
show_error_codes = true | ||
plugins = [] | ||
exclude = ['.venv', 'tests'] |
Oops, something went wrong.