pypj


Namepypj JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/edge-minato/pypj
SummaryPython project initializer
upload_time2022-12-28 09:42:45
maintainer
docs_urlNone
authoredge-minato
requires_python>=3.8,<4.0
licenseMIT
keywords packaging developent environment poetry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![pypj Logo](https://raw.githubusercontent.com/edge-minato/pypj/main/doc/img/logo.png)

[![pypi version](https://img.shields.io/pypi/v/pypj.svg?style=flat)](https://pypi.org/pypi/pypj/)
[![python versions](https://img.shields.io/pypi/pyversions/pypj.svg?style=flat)](https://pypi.org/pypi/pypj/)
[![license](https://img.shields.io/pypi/l/pypj.svg?style=flat)](https://github.com/edge-minato/pypj/blob/master/LICENSE)
[![Unittest](https://github.com/edge-minato/pypj/actions/workflows/unittest.yml/badge.svg)](https://github.com/edge-minato/pypj/actions/workflows/unittest.yml)
[![codecov](https://codecov.io/gh/edge-minato/pypj/branch/main/graph/badge.svg?token=YDZAMKUNS0)](https://codecov.io/gh/edge-minato/pypj)
[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black")
[![Downloads](https://pepy.tech/badge/pypj)](https://pepy.tech/project/pypj)
[![Downloads](https://pepy.tech/badge/pypj/week)](https://pepy.tech/project/pypj)

`pypj` provides you a modern python project template. All the basic dev package installations, their configurations, and test workflows will be done, so you can focus on coding.

## What will be provided

What the _"Modern"_ means is expressed as following directory structure. Some developers prefer another tools, and you can remove or customize the tools to be prepared. Most of all configurations regarding the code style tools, like formatter and linter, are aggregated in `pyproject.toml`.

```
my-package/
├── .github
│   ├── dependabot.yml       # Dependency updater
│   └── workflows
│       ├── publish.yml      # Tagging on GitHub triggers publishing to Pypi
│       └── unittest.yml     # On each push and PR, execute the unittest
├── .pre-commit-config.yaml  # Checks format and styles of each file
├── .venv                    # venv can be outside of project directory
├── .vscode
│   └── settings.json        # Format, Lint, Type check and Import sort on save
├── Makefile                 # Useful command alias
├── README.md                # How to start with pypj
├── my-package               # Your package, can be "src"
├── poetry.lock
├── pyproject.toml           # Configured settings
└── tests
```

## Developing tools pypj provides

- Package manager: [`poetry`](https://github.com/python-poetry/poetry)
- Formatter: [`black`](https://github.com/psf/black)
- Linter: [`pflake8`](https://github.com/csachs/pyproject-flake8) (\*1)
  - Plugin: [`flake8-bugbear`](https://github.com/PyCQA/flake8-bugbear)
- Type checker: [`mypy`](https://github.com/python/mypy)
- Import sorter: [`isort`](https://github.com/PyCQA/isort)
- Test framework:
  - [`pytest`](https://github.com/pytest-dev/pytest)
    - [`pytest-cov`](https://github.com/pytest-dev/pytest-cov)
    - [`pytest-mock`](https://github.com/pytest-dev/pytest-mock)
  - [`tox`](https://github.com/tox-dev/tox)
    - [`tox-gh-actions`](https://github.com/ymyzk/tox-gh-actions)
- Git hooks manager: [`pre-commit`](https://github.com/pre-commit/pre-commit)

(\*1) `pflake8` wraps `flake8` to aggregate settings to `pyproject.toml`

## Coding format pypj provides

- Max line length: `119` as default
- Type hinting: `required`
- And some detailed configurations

## Customize

Here is an actual interaction to customize.

```
Package name: my-package
Do you want to customize settings? (y/N): y
Max line length (119):
Use src directory (y/N):
Keep venv in project (Y/n):
Use github workflows (Y/n):
Use vscode settings (Y/n):
Use pre-commit (Y/n):
Use command alias as Makefile (Y/n):
Are you sure? (Y/n): y
```

## Other features

- Single filed configurations on `pyproject.toml`
- Single sourced versioning: [`single-source`](https://github.com/rabbit72/single-source)
- Command alias: [`make`](https://www.gnu.org/software/make/)
- CI/CD
  - unittest workflow
  - publish package workflow
  - dependency updater configuration

## Requirements

- `python3`
- `poetry` [[Installation guide](https://python-poetry.org/docs/#installation)]

## Installation

```sh
pip install pypj
```

## Usage

See also [README.md](pypj/resources/README.md) which will be generated with `pypj` command, it shows more actual usage.

```
$ pypj

┌─┐┬ ┬┌─┐┬
├─┘└┬┘├─┘│    python : 3.8.5
┴   ┴ ┴ └┘    poetry : 1.1.8

Package name: my-package
Do you want to customize settings? (y/N): N
Do you want to proceed? (y/N): y
Task: Initialize package: my-package
      Command: poetry new my-package ✨
      Poetry new done 🚀
      Command: poetry config virtualenvs.in-project true ✨
      Command: poetry add -D black ✨
      Command: poetry add -D pyproject-flake8 ✨
      Command: poetry add -D mypy ✨
      Command: poetry add -D isort ✨
      Command: poetry add -D pytest ✨
      Command: poetry add -D tox ✨
      Command: poetry add -D pytest-cov ✨
      Command: poetry add -D pytest-mock ✨
      Command: poetry add -D tox-gh-actions ✨
      Configure: __init__.py  ✨
      Create : my-package ✨
Task: Create README.md
      Create : README.md ✨
Task: Configure pyproject.toml settings
      Write  : pyproject.toml ✨
Task: Create github actions
      Create : unittest.yml ✨
      Create : publish.yml ✨
      Create : dependabot.yml ✨
Task: Configure vscode settings
      Create : .vscode/settings.json ✨
Task: Create makefile
      Create : Makefile ✨
Task: Configure pre-commit
      Create : .pre-commit-config.yaml ✨

Complete! 🚀
Let's make the world better! ✨😋🐍🌎
```

## Example configurations on `pyproject.toml`

With default setting, this kind of `pyproject.toml` file will be generated.

```toml
[tool.poetry]
name = "my-package"
version = "0.1.0"
description = ""
authors = ["you <you@example.com>"]

[tool.poetry.dependencies]
python = "^3.8"

[tool.poetry.dev-dependencies]
pytest = "^5.2"
black = "^21.8b0"
pyproject-flake8 = "^0.0.1-alpha.2"
mypy = "^0.910"
isort = "^5.9.3"
tox = "^3.24.3"
pytest-cov = "^2.12.1"
pytest-mock = "^3.6.1"
tox-gh-actions = "^2.7.0"

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

[tool.black]
line-length = 119
exclude = '''
(
    migrations
    | .mypy_cache
    | .pytest_cache
    | .tox
    | .venv
    | dist
)
'''

[tool.flake8]
max-line-length = 119
max-complexity = 10
select = "C,E,F,W,B"
ignore = "E203"

[tool.mypy]
# common
python_version = 3.8
show_column_numbers = true
show_error_context = true
ignore_missing_imports = true
check_untyped_defs = true
disallow_untyped_defs = true
# warning
warn_return_any = true
warn_unused_configs = true
warn_redundant_casts = true

[tool.isort]
profile = "black"
line_length = 119

[tool.tox]
legacy_tox_ini = """
[tox]
envlist = py38, flake8, black, mypy, isort
skipsdist = true
isolated_build = true
skip_missing_interpreters = true
[testenv]
whitelist_externals = poetry
require_locked_deps = true
install_dev_deps = true
commands =
    poetry install -vv --no-root
    pytest ./tests -v --cov=pypj --cov-branch --durations=0
[testenv:flake8]
commands = poetry run pflake8 ./my-package
[testenv:black]
commands = poetry run black ./my-package
[testenv:mypy]
commands = poetry run mypy ./my-package
[testenv:isort]
commands = poetry run isort ./my-package
"""
```

## Alias as Makefile

```Makefile
.PHONY: install update clean build run debug test style
PACKAGE := $(shell grep name pyproject.toml -m1 | awk -F" " '{print $$3}')
VERSION := $(shell grep version pyproject.toml -m1 | awk -F" " '{print $$3}')

install:
        poetry install
        poetry run pre-commit install

update:
        poetry update
        poetry run pre-commit autoupdate

clean:
        rm -rf dist

build: clean
        poetry build

run:
        poetry run ${PACKAGE} # Just in case the package provides a command

debug:
        poetry run pytest ./tests -s -v --cov=pypj --cov-branch --durations=0

test:
        poetry run tox

style:
        poetry run tox -e black,flake8,mypy,isort
```

## Supported python versions

- Supported: `3.8`, `3.9`, `3.10`
- Not supported: `3.7` or less

**NOTE**: According to [Status of Python branches](https://devguide.python.org/versions/#versions), the EoL of Python 3.7 is `2023-06-27`.

## FAQ

- Is there any restrictions regarding the package naming?
  - A name of python package is defined at [PEP-008 #Package and Module Names](https://www.python.org/dev/peps/pep-0008/#package-and-module-names) and it can be expressed as regex: `/^[a-zA-Z][0-9a-zA-Z\-_]*/`. `pypj` follows this rule.
- Can I use current git initialized directory as a package root?
  - NO. Instead of that, you can initialize the generated package directory with git.
    1. `git init`
    2. `git remote add origin https://github.com/USER/my-repository.git`
    3. `git push -u origin main`

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/edge-minato/pypj",
    "name": "pypj",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "packaging,developent,environment,poetry",
    "author": "edge-minato",
    "author_email": "edge.minato@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/21/fa/d19ac2412037946ecaeadf64d9a09b1fb2d621beaecb5e1e922ffb8137a8/pypj-1.2.0.tar.gz",
    "platform": null,
    "description": "![pypj Logo](https://raw.githubusercontent.com/edge-minato/pypj/main/doc/img/logo.png)\n\n[![pypi version](https://img.shields.io/pypi/v/pypj.svg?style=flat)](https://pypi.org/pypi/pypj/)\n[![python versions](https://img.shields.io/pypi/pyversions/pypj.svg?style=flat)](https://pypi.org/pypi/pypj/)\n[![license](https://img.shields.io/pypi/l/pypj.svg?style=flat)](https://github.com/edge-minato/pypj/blob/master/LICENSE)\n[![Unittest](https://github.com/edge-minato/pypj/actions/workflows/unittest.yml/badge.svg)](https://github.com/edge-minato/pypj/actions/workflows/unittest.yml)\n[![codecov](https://codecov.io/gh/edge-minato/pypj/branch/main/graph/badge.svg?token=YDZAMKUNS0)](https://codecov.io/gh/edge-minato/pypj)\n[![Code style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black\")\n[![Downloads](https://pepy.tech/badge/pypj)](https://pepy.tech/project/pypj)\n[![Downloads](https://pepy.tech/badge/pypj/week)](https://pepy.tech/project/pypj)\n\n`pypj` provides you a modern python project template. All the basic dev package installations, their configurations, and test workflows will be done, so you can focus on coding.\n\n## What will be provided\n\nWhat the _\"Modern\"_ means is expressed as following directory structure. Some developers prefer another tools, and you can remove or customize the tools to be prepared. Most of all configurations regarding the code style tools, like formatter and linter, are aggregated in `pyproject.toml`.\n\n```\nmy-package/\n\u251c\u2500\u2500 .github\n\u2502   \u251c\u2500\u2500 dependabot.yml       # Dependency updater\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 workflows\n\u2502\u00a0\u00a0     \u251c\u2500\u2500 publish.yml      # Tagging on GitHub triggers publishing to Pypi\n\u2502\u00a0\u00a0     \u2514\u2500\u2500 unittest.yml     # On each push and PR, execute the unittest\n\u251c\u2500\u2500 .pre-commit-config.yaml  # Checks format and styles of each file\n\u251c\u2500\u2500 .venv                    # venv can be outside of project directory\n\u251c\u2500\u2500 .vscode\n\u2502\u00a0\u00a0 \u2514\u2500\u2500 settings.json        # Format, Lint, Type check and Import sort on save\n\u251c\u2500\u2500 Makefile                 # Useful command alias\n\u251c\u2500\u2500 README.md                # How to start with pypj\n\u251c\u2500\u2500 my-package               # Your package, can be \"src\"\n\u251c\u2500\u2500 poetry.lock\n\u251c\u2500\u2500 pyproject.toml           # Configured settings\n\u2514\u2500\u2500 tests\n```\n\n## Developing tools pypj provides\n\n- Package manager: [`poetry`](https://github.com/python-poetry/poetry)\n- Formatter: [`black`](https://github.com/psf/black)\n- Linter: [`pflake8`](https://github.com/csachs/pyproject-flake8) (\\*1)\n  - Plugin: [`flake8-bugbear`](https://github.com/PyCQA/flake8-bugbear)\n- Type checker: [`mypy`](https://github.com/python/mypy)\n- Import sorter: [`isort`](https://github.com/PyCQA/isort)\n- Test framework:\n  - [`pytest`](https://github.com/pytest-dev/pytest)\n    - [`pytest-cov`](https://github.com/pytest-dev/pytest-cov)\n    - [`pytest-mock`](https://github.com/pytest-dev/pytest-mock)\n  - [`tox`](https://github.com/tox-dev/tox)\n    - [`tox-gh-actions`](https://github.com/ymyzk/tox-gh-actions)\n- Git hooks manager: [`pre-commit`](https://github.com/pre-commit/pre-commit)\n\n(\\*1) `pflake8` wraps `flake8` to aggregate settings to `pyproject.toml`\n\n## Coding format pypj provides\n\n- Max line length: `119` as default\n- Type hinting: `required`\n- And some detailed configurations\n\n## Customize\n\nHere is an actual interaction to customize.\n\n```\nPackage name: my-package\nDo you want to customize settings? (y/N): y\nMax line length (119):\nUse src directory (y/N):\nKeep venv in project (Y/n):\nUse github workflows (Y/n):\nUse vscode settings (Y/n):\nUse pre-commit (Y/n):\nUse command alias as Makefile (Y/n):\nAre you sure? (Y/n): y\n```\n\n## Other features\n\n- Single filed configurations on `pyproject.toml`\n- Single sourced versioning: [`single-source`](https://github.com/rabbit72/single-source)\n- Command alias: [`make`](https://www.gnu.org/software/make/)\n- CI/CD\n  - unittest workflow\n  - publish package workflow\n  - dependency updater configuration\n\n## Requirements\n\n- `python3`\n- `poetry` [[Installation guide](https://python-poetry.org/docs/#installation)]\n\n## Installation\n\n```sh\npip install pypj\n```\n\n## Usage\n\nSee also [README.md](pypj/resources/README.md) which will be generated with `pypj` command, it shows more actual usage.\n\n```\n$ pypj\n\n\u250c\u2500\u2510\u252c \u252c\u250c\u2500\u2510\u252c\n\u251c\u2500\u2518\u2514\u252c\u2518\u251c\u2500\u2518\u2502    python : 3.8.5\n\u2534   \u2534 \u2534 \u2514\u2518    poetry : 1.1.8\n\nPackage name: my-package\nDo you want to customize settings? (y/N): N\nDo you want to proceed? (y/N): y\nTask: Initialize package: my-package\n      Command: poetry new my-package \u2728\n      Poetry new done \ud83d\ude80\n      Command: poetry config virtualenvs.in-project true \u2728\n      Command: poetry add -D black \u2728\n      Command: poetry add -D pyproject-flake8 \u2728\n      Command: poetry add -D mypy \u2728\n      Command: poetry add -D isort \u2728\n      Command: poetry add -D pytest \u2728\n      Command: poetry add -D tox \u2728\n      Command: poetry add -D pytest-cov \u2728\n      Command: poetry add -D pytest-mock \u2728\n      Command: poetry add -D tox-gh-actions \u2728\n      Configure: __init__.py  \u2728\n      Create : my-package \u2728\nTask: Create README.md\n      Create : README.md \u2728\nTask: Configure pyproject.toml settings\n      Write  : pyproject.toml \u2728\nTask: Create github actions\n      Create : unittest.yml \u2728\n      Create : publish.yml \u2728\n      Create : dependabot.yml \u2728\nTask: Configure vscode settings\n      Create : .vscode/settings.json \u2728\nTask: Create makefile\n      Create : Makefile \u2728\nTask: Configure pre-commit\n      Create : .pre-commit-config.yaml \u2728\n\nComplete! \ud83d\ude80\nLet's make the world better! \u2728\ud83d\ude0b\ud83d\udc0d\ud83c\udf0e\n```\n\n## Example configurations on `pyproject.toml`\n\nWith default setting, this kind of `pyproject.toml` file will be generated.\n\n```toml\n[tool.poetry]\nname = \"my-package\"\nversion = \"0.1.0\"\ndescription = \"\"\nauthors = [\"you <you@example.com>\"]\n\n[tool.poetry.dependencies]\npython = \"^3.8\"\n\n[tool.poetry.dev-dependencies]\npytest = \"^5.2\"\nblack = \"^21.8b0\"\npyproject-flake8 = \"^0.0.1-alpha.2\"\nmypy = \"^0.910\"\nisort = \"^5.9.3\"\ntox = \"^3.24.3\"\npytest-cov = \"^2.12.1\"\npytest-mock = \"^3.6.1\"\ntox-gh-actions = \"^2.7.0\"\n\n[build-system]\nrequires = [\"poetry-core>=1.0.0\"]\nbuild-backend = \"poetry.core.masonry.api\"\n\n[tool.black]\nline-length = 119\nexclude = '''\n(\n    migrations\n    | .mypy_cache\n    | .pytest_cache\n    | .tox\n    | .venv\n    | dist\n)\n'''\n\n[tool.flake8]\nmax-line-length = 119\nmax-complexity = 10\nselect = \"C,E,F,W,B\"\nignore = \"E203\"\n\n[tool.mypy]\n# common\npython_version = 3.8\nshow_column_numbers = true\nshow_error_context = true\nignore_missing_imports = true\ncheck_untyped_defs = true\ndisallow_untyped_defs = true\n# warning\nwarn_return_any = true\nwarn_unused_configs = true\nwarn_redundant_casts = true\n\n[tool.isort]\nprofile = \"black\"\nline_length = 119\n\n[tool.tox]\nlegacy_tox_ini = \"\"\"\n[tox]\nenvlist = py38, flake8, black, mypy, isort\nskipsdist = true\nisolated_build = true\nskip_missing_interpreters = true\n[testenv]\nwhitelist_externals = poetry\nrequire_locked_deps = true\ninstall_dev_deps = true\ncommands =\n    poetry install -vv --no-root\n    pytest ./tests -v --cov=pypj --cov-branch --durations=0\n[testenv:flake8]\ncommands = poetry run pflake8 ./my-package\n[testenv:black]\ncommands = poetry run black ./my-package\n[testenv:mypy]\ncommands = poetry run mypy ./my-package\n[testenv:isort]\ncommands = poetry run isort ./my-package\n\"\"\"\n```\n\n## Alias as Makefile\n\n```Makefile\n.PHONY: install update clean build run debug test style\nPACKAGE := $(shell grep name pyproject.toml -m1 | awk -F\" \" '{print $$3}')\nVERSION := $(shell grep version pyproject.toml -m1 | awk -F\" \" '{print $$3}')\n\ninstall:\n        poetry install\n        poetry run pre-commit install\n\nupdate:\n        poetry update\n        poetry run pre-commit autoupdate\n\nclean:\n        rm -rf dist\n\nbuild: clean\n        poetry build\n\nrun:\n        poetry run ${PACKAGE} # Just in case the package provides a command\n\ndebug:\n        poetry run pytest ./tests -s -v --cov=pypj --cov-branch --durations=0\n\ntest:\n        poetry run tox\n\nstyle:\n        poetry run tox -e black,flake8,mypy,isort\n```\n\n## Supported python versions\n\n- Supported: `3.8`, `3.9`, `3.10`\n- Not supported: `3.7` or less\n\n**NOTE**: According to [Status of Python branches](https://devguide.python.org/versions/#versions), the EoL of Python 3.7 is `2023-06-27`.\n\n## FAQ\n\n- Is there any restrictions regarding the package naming?\n  - A name of python package is defined at [PEP-008 #Package and Module Names](https://www.python.org/dev/peps/pep-0008/#package-and-module-names) and it can be expressed as regex: `/^[a-zA-Z][0-9a-zA-Z\\-_]*/`. `pypj` follows this rule.\n- Can I use current git initialized directory as a package root?\n  - NO. Instead of that, you can initialize the generated package directory with git.\n    1. `git init`\n    2. `git remote add origin https://github.com/USER/my-repository.git`\n    3. `git push -u origin main`\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python project initializer",
    "version": "1.2.0",
    "split_keywords": [
        "packaging",
        "developent",
        "environment",
        "poetry"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "c3bf5766a3efe47697eb7c9fb9c6bf75",
                "sha256": "2b785dda1fb77a9233e5bc33907cdae961f26f8de0051be30313aeace62c71b9"
            },
            "downloads": -1,
            "filename": "pypj-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c3bf5766a3efe47697eb7c9fb9c6bf75",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 24693,
            "upload_time": "2022-12-28T09:42:37",
            "upload_time_iso_8601": "2022-12-28T09:42:37.639419Z",
            "url": "https://files.pythonhosted.org/packages/3d/a4/ece4bd153ce22b6fd7243128de367c9ee33427c954975703d1ab3abf450a/pypj-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "7ae920a24dfae7b86a1205934a1ad2c1",
                "sha256": "6c8036dbe1873db1e286cb8aed8dfed1cdb75418e26b35af2e7cdd036978ea81"
            },
            "downloads": -1,
            "filename": "pypj-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "7ae920a24dfae7b86a1205934a1ad2c1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 19899,
            "upload_time": "2022-12-28T09:42:45",
            "upload_time_iso_8601": "2022-12-28T09:42:45.974487Z",
            "url": "https://files.pythonhosted.org/packages/21/fa/d19ac2412037946ecaeadf64d9a09b1fb2d621beaecb5e1e922ffb8137a8/pypj-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-28 09:42:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "edge-minato",
    "github_project": "pypj",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "pypj"
}
        
Elapsed time: 0.18125s