Name | BO4E-Python-Generator JSON |
Version |
0.0.13
JSON |
| download |
home_page | None |
Summary | This tool auto generates (customizable) pydantic v2 Code to implement the BO4E-Schemas. |
upload_time | 2024-07-30 12:26:05 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | MIT |
keywords |
bo4e
code-generator
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Python Template Repository including a `tox.ini`, Unittests&Coverage, Pylint & MyPy Linting Actions and a PyPI Publishing Workflow
<!--- you need to replace the `organization/repo_name` in the status badge URLs --->
![Unittests status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Unittests/badge.svg)
![Coverage status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Coverage/badge.svg)
![Linting status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Linting/badge.svg)
![Black status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Formatting/badge.svg)
This is a template repository.
It doesn't contain any useful code but only a minimal working setup for a Python project including:
- a basic **project structure** with
- tox.ini
- requirements.in
- and a requirements.txt derived from it
- an example class
- an example unit test (using pytest)
- ready to use **Github Actions** for
- [pytest](https://pytest.org)
- [code coverage measurement](https://coverage.readthedocs.io) (fails below 80% by default)
- [pylint](https://pylint.org/) (only accepts 10/10 code rating by default)
- [mypy](https://github.com/python/mypy) (static type checks where possible)
- [black](https://github.com/psf/black) code formatter check
- [isort](https://pycqa.github.io/isort/) import order check
- [codespell](https://github.com/codespell-project/codespell) spell check (including an ignore list)
- ready-to-use publishing workflow for pypi (see readme section below)
By default, it uses Python version 3.12.
## How to use this Repository on Your Machine
This introduction assumes that you have tox installed already (
see [installation instructions](https://tox.readthedocs.io/en/latest/installation.html)) and that a `.toxbase` environment
has been created.
`.toxbase` is a project independent virtual environment-template for all the tox environments on your machine. If anything is weird during the tox installation or after the installation, try turning your computer off and on again before getting too frustrated.
Also on new windows machines it is possible that the execution policy is set to restricted and you are not allowed execute scripts. You can find detailed information [here](https://learn.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3).
If this is the case, clone this repository and create the `dev` environment on your machine.
```bash
tox -e dev
```
### How to use with PyCharm
1. Create a new project using existing sources with your local working copy of this repository as root directory. Choose
the path `your_repo/.tox/dev/` as path of the "previously configured interpreter".
2. Set the
default [test runner of your project](https://www.jetbrains.com/help/pycharm/choosing-your-testing-framework.html) to
pytest.
3. Set the `src` directory as sources root (via right click, [docs](https://www.jetbrains.com/help/pycharm/content-root.html)).
4. Set
the [working directory of the unit tests](https://www.jetbrains.com/help/pycharm/creating-run-debug-configuration-for-tests.html)
to the project root (instead of the unittest directory).
### How to use with VS Code
1. Open the folder with VS Code.
2. **Select the python interpreter** ([official docs](https://code.visualstudio.com/docs/python/environments#_manually-specify-an-interpreter)) which is created by tox. Open the command pallett with `CTRL + P` and type `Python: Select Interpreter`. Select the interpreter which is placed in `.tox/dev/Scripts/python.exe` under Windows or `.tox/dev/bin/python` under Linux and macOS.
3. **Setup pytest and pylint**. Therefore we open the file `.vscode/settings.json` which should be automatically generated during the interpreter setup. Insert the following lines into the settings:
```json
{
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"pythonTestExplorer.testFramework": "pytest",
"python.testing.pytestArgs": ["unittests"],
"python.linting.pylintEnabled": true
}
```
4. Create a `.env` file and insert the following line
For Windows:
```
PYTHONPATH=src;${PYTHONPATH}
```
For Linux and Mac:
```
PYTHONPATH=src:${PYTHONPATH}
```
This makes sure, that the imports are working for the unittests.
At the moment I am not totally sure that it is the best practise, but it's getting the job done.
5. Enjoy 🤗
## Publishing on PyPI
This repository contains all necessary CI steps to publish any project created from it on PyPI.
It uses the trusted publishers workflow as described in the [official Python documentation](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/).
It just requires some manual adjustments/settings depending on your project:
1. Fill out the metadata in the [`pyproject.toml`](pyproject.toml); Namely the package name and the dependencies which should be in sync with your `requirements.in`.
2. Uncomment the lines in [`.github/workflows/python-publish.yml`](.github/workflows/python-publish.yml)
3. Create a [new environment in your GitHub repository](https://github.com/Hochfrequenz/python_template_repository/settings/environments) and call it `release`.
4. Set up a new trusted publisher [in your PYPI account](https://pypi.org/manage/account/publishing/).
1. PyPI Project Name: The name which you defined in the `pyproject.toml` is the name of the project which you have to enter here.
2. Owner: The GitHub organization name or GitHub username that owns the repository
3. Repository name: The name of the GitHub repository that contains the publishing workflow
4. Workflow name: The filename of the publishing workflow. This file should exist in the .github/workflows/ directory in the repository configured above. Here in our case: `python-publish.yml`
5. Environment name: The name of the GitHub Actions environment that the above workflow uses for publishing. Here in our case: `release`
5. Now create a release by clicking on "Create new release" in the right Github sidebar (or visit `github.com/your-username/your-reponame/releases/new`). This should trigger the workflow (see the "Actions" tab of your repo).
6. Check if the action failed. If it succeeded your PyPI account should now show the new project. It might take some minutes until the package can be installed via `pip install packagename` because the index has to be updated.
7. Now create another PyPI token with limited scope and update the Github repository secret accordingly.
## Contribute
You are very welcome to contribute to this template repository by opening a pull request against the main branch.
Raw data
{
"_id": null,
"home_page": null,
"name": "BO4E-Python-Generator",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "bo4e, code-generator",
"author": null,
"author_email": "Hochfrequenz Unternehmensberatung GmbH <info@hochfrequenz.de>",
"download_url": "https://files.pythonhosted.org/packages/96/47/26b25b9b70b266803fe323d4fb8a10cc33d7827b54daccd437632b2a3b09/bo4e_python_generator-0.0.13.tar.gz",
"platform": null,
"description": "# Python Template Repository including a `tox.ini`, Unittests&Coverage, Pylint & MyPy Linting Actions and a PyPI Publishing Workflow\n\n<!--- you need to replace the `organization/repo_name` in the status badge URLs --->\n\n![Unittests status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Unittests/badge.svg)\n![Coverage status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Coverage/badge.svg)\n![Linting status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Linting/badge.svg)\n![Black status badge](https://github.com/bo4e/BO4E-Python-Generator/workflows/Formatting/badge.svg)\n\nThis is a template repository.\nIt doesn't contain any useful code but only a minimal working setup for a Python project including:\n\n- a basic **project structure** with\n - tox.ini\n - requirements.in\n - and a requirements.txt derived from it\n - an example class\n - an example unit test (using pytest)\n- ready to use **Github Actions** for\n - [pytest](https://pytest.org)\n - [code coverage measurement](https://coverage.readthedocs.io) (fails below 80% by default)\n - [pylint](https://pylint.org/) (only accepts 10/10 code rating by default)\n - [mypy](https://github.com/python/mypy) (static type checks where possible)\n - [black](https://github.com/psf/black) code formatter check\n - [isort](https://pycqa.github.io/isort/) import order check\n - [codespell](https://github.com/codespell-project/codespell) spell check (including an ignore list)\n - ready-to-use publishing workflow for pypi (see readme section below)\n\nBy default, it uses Python version 3.12.\n\n## How to use this Repository on Your Machine\n\nThis introduction assumes that you have tox installed already (\nsee [installation instructions](https://tox.readthedocs.io/en/latest/installation.html)) and that a `.toxbase` environment\nhas been created.\n`.toxbase` is a project independent virtual environment-template for all the tox environments on your machine. If anything is weird during the tox installation or after the installation, try turning your computer off and on again before getting too frustrated.\n\nAlso on new windows machines it is possible that the execution policy is set to restricted and you are not allowed execute scripts. You can find detailed information [here](https://learn.microsoft.com/de-de/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.3).\n\nIf this is the case, clone this repository and create the `dev` environment on your machine.\n\n```bash\ntox -e dev\n```\n\n### How to use with PyCharm\n\n1. Create a new project using existing sources with your local working copy of this repository as root directory. Choose\n the path `your_repo/.tox/dev/` as path of the \"previously configured interpreter\".\n2. Set the\n default [test runner of your project](https://www.jetbrains.com/help/pycharm/choosing-your-testing-framework.html) to\n pytest.\n3. Set the `src` directory as sources root (via right click, [docs](https://www.jetbrains.com/help/pycharm/content-root.html)).\n4. Set\n the [working directory of the unit tests](https://www.jetbrains.com/help/pycharm/creating-run-debug-configuration-for-tests.html)\n to the project root (instead of the unittest directory).\n\n### How to use with VS Code\n\n1. Open the folder with VS Code.\n2. **Select the python interpreter** ([official docs](https://code.visualstudio.com/docs/python/environments#_manually-specify-an-interpreter)) which is created by tox. Open the command pallett with `CTRL + P` and type `Python: Select Interpreter`. Select the interpreter which is placed in `.tox/dev/Scripts/python.exe` under Windows or `.tox/dev/bin/python` under Linux and macOS.\n3. **Setup pytest and pylint**. Therefore we open the file `.vscode/settings.json` which should be automatically generated during the interpreter setup. Insert the following lines into the settings:\n\n```json\n{\n \"python.testing.unittestEnabled\": false,\n \"python.testing.nosetestsEnabled\": false,\n \"python.testing.pytestEnabled\": true,\n \"pythonTestExplorer.testFramework\": \"pytest\",\n \"python.testing.pytestArgs\": [\"unittests\"],\n \"python.linting.pylintEnabled\": true\n}\n```\n\n4. Create a `.env` file and insert the following line\n\nFor Windows:\n\n```\nPYTHONPATH=src;${PYTHONPATH}\n```\n\nFor Linux and Mac:\n\n```\nPYTHONPATH=src:${PYTHONPATH}\n```\n\nThis makes sure, that the imports are working for the unittests.\nAt the moment I am not totally sure that it is the best practise, but it's getting the job done.\n\n5. Enjoy \ud83e\udd17\n\n## Publishing on PyPI\n\nThis repository contains all necessary CI steps to publish any project created from it on PyPI.\nIt uses the trusted publishers workflow as described in the [official Python documentation](https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/).\nIt just requires some manual adjustments/settings depending on your project:\n\n1. Fill out the metadata in the [`pyproject.toml`](pyproject.toml); Namely the package name and the dependencies which should be in sync with your `requirements.in`.\n2. Uncomment the lines in [`.github/workflows/python-publish.yml`](.github/workflows/python-publish.yml)\n3. Create a [new environment in your GitHub repository](https://github.com/Hochfrequenz/python_template_repository/settings/environments) and call it `release`.\n4. Set up a new trusted publisher [in your PYPI account](https://pypi.org/manage/account/publishing/).\n 1. PyPI Project Name: The name which you defined in the `pyproject.toml` is the name of the project which you have to enter here.\n 2. Owner: The GitHub organization name or GitHub username that owns the repository\n 3. Repository name: The name of the GitHub repository that contains the publishing workflow\n 4. Workflow name: The filename of the publishing workflow. This file should exist in the .github/workflows/ directory in the repository configured above. Here in our case: `python-publish.yml`\n 5. Environment name: The name of the GitHub Actions environment that the above workflow uses for publishing. Here in our case: `release`\n5. Now create a release by clicking on \"Create new release\" in the right Github sidebar (or visit `github.com/your-username/your-reponame/releases/new`). This should trigger the workflow (see the \"Actions\" tab of your repo).\n6. Check if the action failed. If it succeeded your PyPI account should now show the new project. It might take some minutes until the package can be installed via `pip install packagename` because the index has to be updated.\n7. Now create another PyPI token with limited scope and update the Github repository secret accordingly.\n\n## Contribute\n\nYou are very welcome to contribute to this template repository by opening a pull request against the main branch.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "This tool auto generates (customizable) pydantic v2 Code to implement the BO4E-Schemas.",
"version": "0.0.13",
"project_urls": {
"Changelog": "https://github.com/bo4e/bo4e-python-generator/releases",
"Homepage": "https://github.com/bo4e/bo4e-python-generator"
},
"split_keywords": [
"bo4e",
" code-generator"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7fc9b8b1d25b5058febd4832d3363fcd454a5d7c1701a6e58f0ab905e01989a8",
"md5": "c77dd4863dec110cf5ca6b3431c2dead",
"sha256": "5d3488838a004f08a21f217c6a9d727947ad207255850773256527485bd43a03"
},
"downloads": -1,
"filename": "bo4e_python_generator-0.0.13-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c77dd4863dec110cf5ca6b3431c2dead",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 19707,
"upload_time": "2024-07-30T12:26:04",
"upload_time_iso_8601": "2024-07-30T12:26:04.303197Z",
"url": "https://files.pythonhosted.org/packages/7f/c9/b8b1d25b5058febd4832d3363fcd454a5d7c1701a6e58f0ab905e01989a8/bo4e_python_generator-0.0.13-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "964726b25b9b70b266803fe323d4fb8a10cc33d7827b54daccd437632b2a3b09",
"md5": "d3b566033b3b64dd26532df10c3adfd9",
"sha256": "ee65106b756dfa4ae1ed325fca1d488e4b7f81338cf6786ec337843886222bb5"
},
"downloads": -1,
"filename": "bo4e_python_generator-0.0.13.tar.gz",
"has_sig": false,
"md5_digest": "d3b566033b3b64dd26532df10c3adfd9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 24053,
"upload_time": "2024-07-30T12:26:05",
"upload_time_iso_8601": "2024-07-30T12:26:05.379291Z",
"url": "https://files.pythonhosted.org/packages/96/47/26b25b9b70b266803fe323d4fb8a10cc33d7827b54daccd437632b2a3b09/bo4e_python_generator-0.0.13.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-30 12:26:05",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "bo4e",
"github_project": "bo4e-python-generator",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "bo4e-python-generator"
}