Skip to content

Commit aa41403

Browse files
develop a cookiecutter template for python projects (#206)
--------- Co-authored-by: Nicola Coretti <[email protected]>
1 parent fae0689 commit aa41403

35 files changed

+629
-18
lines changed
Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1-
**< PR SPECIFIC CONTENT >**
1+
# ✔ Checklist
22

3-
-------
4-
# ✔ Checklist(s)
5-
6-
* [ ] Is the title of the Pull Request correct?
7-
* [ ] Is the title of the corresponding issue correct?
83
* [ ] Have you updated the changelog?
9-
* [ ] Have you updated the templates?
10-
* [ ] Have you checked to ensure there aren't other open Pull Requests for the same update/change?
4+
* [ ] Have you updated the cookiecutter-template?
115
* [ ] Are you mentioning the issue which this PullRequest fixes ("Fixes...")
126

137
Note: If any of the above is not relevant to your PR just check the box.

doc/changes/changes_0.14.0.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# 0.14.0 - 2024-07-02
22

3-
## Doc
3+
## 📚 Documentation
44

55
* #204: Added a guideline for removing `ci-job` from workflow `pr-merge.yml`
66

7-
## Internal
7+
## 🔩 Internal
88

9-
* Relock dependencies
9+
* Relock dependencies

doc/changes/unreleased.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
# Unreleased
2+
3+
## ✨ Added
4+
* Added cookiecutter-template for creating new project
5+

doc/user_guide/getting_started.rst

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,84 @@
11
Getting Started
22
===============
33

4-
Preparing the Project
5-
---------------------
4+
Your usage of the `exasol-toolbox` will likely fall into one of two scenarios:
5+
6+
#. Integration into an existing project.
7+
8+
If this is your situation, proceed to the section titled :ref:`Integrating Exasol-Toolbox into your Project <existing>`.
9+
10+
#. Creation of a new project.
11+
12+
If you are starting a new project, please read the section :ref:`Create a New Project with Exasol-Toolbox Support <new>`.
13+
14+
.. _new:
15+
16+
Create a New Project with Exasol-Toolbox Support
17+
-------------------------------------------------
18+
19+
.. important::
20+
21+
To establish a new project with toolbox support, you need to have `Cookiecutter <https://www.cookiecutter.io>`_ installed.
22+
23+
**TL;DR:**
24+
:code:`pipx install cookiecutter`
25+
26+
27+
**1. Create a new project**
28+
29+
Use the following command to create a new project:
30+
31+
.. code-block:: shell
32+
33+
cookiecutter https://github.com/exasol/python-toolbox.git --directory project-template
34+
35+
**2. Follow the interactive project setup prompt**
36+
37+
**3. Bootstrapp the development environment**
38+
39+
Navigate to the directory of the newly created project:
40+
41+
.. code-block:: shell
42+
43+
cd <your-project-name>
44+
45+
Generate a poetry environment for the project:
46+
47+
.. code-block:: shell
48+
49+
poetry shell
50+
51+
Install all necessary project and development dependencies for the project:
52+
53+
.. code-block:: shell
54+
55+
poetry install
56+
57+
**4. Start using your project**
58+
59+
List all available nox tasks:
60+
61+
.. code-block:: shell
62+
63+
nox -l
64+
65+
Build and open the documentation:
66+
67+
.. code-block:: shell
68+
69+
nox -s build-docs open-docs
70+
71+
Execute the unit tests of the project:
72+
73+
.. code-block:: shell
74+
75+
nox -s unit-tests
76+
77+
78+
.. _existing:
79+
80+
Integrating Exasol-Toolbox into your Project
81+
--------------------------------------------
682

783
1. Add the toolbox as dependency
884
++++++++++++++++++++++++++++++++

noxconfig.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class Config:
3535
root: Path = Path(__file__).parent
3636
doc: Path = Path(__file__).parent / "doc"
3737
version_file: Path = Path(__file__).parent / "exasol" / "toolbox" / "version.py"
38-
path_filters: Iterable[str] = ("dist", ".eggs", "venv", "metrics-schema")
38+
path_filters: Iterable[str] = ("dist", ".eggs", "venv", "metrics-schema", "project-template")
3939
plugins = [UpdateTemplates]
40-
40+
4141

4242
PROJECT_CONFIG = Config()

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

project-template/cookiecutter.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"project_name": "Yet Another Project",
3+
"repo_name": "{{cookiecutter.project_name | lower | replace(' ', '-')}}",
4+
"package_name": "{{cookiecutter.repo_name | replace('-', '_')}}",
5+
"description": "",
6+
"autor_full_name": "",
7+
"autor_email": "",
8+
"error_tags": "",
9+
"license_year": "{% now 'utc', '%Y' %}",
10+
"__repo_name_slug": "{{cookiecutter.package_name}}",
11+
"__package_name_slug": "{{cookiecutter.package_name}}",
12+
"_extensions": ["cookiecutter.extensions.TimeExtension"]
13+
}
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
131+
# PyCharm
132+
.idea
133+
134+
# Sphinx
135+
doc/_build
136+
doc/.build-docu
137+
doc/api
138+
139+
# Language container
140+
.build_output
141+
.html-documentation
142+
itde/
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
default_stages: [ commit ]
2+
repos:
3+
4+
- repo: local
5+
hooks:
6+
- id: code-format
7+
name: code-format
8+
types: [ python ]
9+
pass_filenames: false
10+
language: system
11+
entry: poetry run nox -s fix
12+
13+
- repo: local
14+
hooks:
15+
- id: type-check
16+
name: type-check
17+
types: [ python ]
18+
pass_filenames: false
19+
language: system
20+
entry: poetry run nox -s type-check
21+
22+
- repo: local
23+
hooks:
24+
- id: lint
25+
name: lint
26+
types: [ python ]
27+
pass_filenames: false
28+
language: system
29+
entry: poetry run nox -s lint
30+
31+
- repo: https://github.com/pre-commit/pre-commit-hooks
32+
rev: v4.4.0
33+
hooks:
34+
- id: check-yaml
35+
- id: end-of-file-fixer
36+
- id: trailing-whitespace
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) {{cookiecutter.license_year}} Exasol
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

0 commit comments

Comments
 (0)