Skip to content

Commit e0cc819

Browse files
committed
feat: First version of cookiecuter packager
0 parents  commit e0cc819

File tree

18 files changed

+806
-0
lines changed

18 files changed

+806
-0
lines changed

.gitignore

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
lsp/
8+
.idea/
9+
10+
# C extensions
11+
*.so
12+
13+
# Distribution / packaging
14+
.Python
15+
build/
16+
develop-eggs/
17+
dist/
18+
downloads/
19+
eggs/
20+
.eggs/
21+
lib/
22+
lib64/
23+
parts/
24+
sdist/
25+
var/
26+
wheels/
27+
share/python-wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.nox/
47+
.coverage
48+
.coverage.*
49+
.cache
50+
nosetests.xml
51+
coverage.xml
52+
*.cover
53+
*.py,cover
54+
.hypothesis/
55+
.pytest_cache/
56+
cover/
57+
58+
# Translations
59+
*.mo
60+
*.pot
61+
62+
# Django stuff:
63+
*.log
64+
local_settings.py
65+
db.sqlite3
66+
db.sqlite3-journal
67+
68+
# Flask stuff:
69+
instance/
70+
.webassets-cache
71+
72+
# Scrapy stuff:
73+
.scrapy
74+
75+
# Sphinx documentation
76+
docs/_build/
77+
78+
# PyBuilder
79+
.pybuilder/
80+
target/
81+
82+
# Jupyter Notebook
83+
.ipynb_checkpoints
84+
85+
# IPython
86+
profile_default/
87+
ipython_config.py
88+
89+
# pyenv
90+
# For a library or package, you might want to ignore these files since the code is
91+
# intended to run in multiple environments; otherwise, check them in:
92+
# .python-version
93+
94+
# pipenv
95+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
97+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
98+
# install all needed dependencies.
99+
#Pipfile.lock
100+
101+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
102+
__pypackages__/
103+
104+
# Celery stuff
105+
celerybeat-schedule
106+
celerybeat.pid
107+
108+
# SageMath parsed files
109+
*.sage.py
110+
111+
# Environments
112+
.env
113+
.venv
114+
env/
115+
venv/
116+
ENV/
117+
env.bak/
118+
venv.bak/
119+
120+
# Spyder project settings
121+
.spyderproject
122+
.spyproject
123+
124+
# Rope project settings
125+
.ropeproject
126+
127+
# mkdocs documentation
128+
/site
129+
130+
# mypy
131+
.mypy_cache/
132+
.dmypy.json
133+
dmypy.json
134+
135+
# Pyre type checker
136+
.pyre/
137+
138+
# pytype static type analyzer
139+
.pytype/
140+
141+
# Cython debug symbols
142+
cython_debug/
143+

AUTHORS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
3+
# Credits
4+
5+
---
6+
7+
# Development Lead
8+
9+
* [Elias Ojeda Medina @eocode]() [email protected]
10+
11+
# Contributors
12+
13+
---
14+
15+
None yet. Why not be the first?

LICENCE

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2020, Activando Ideas
4+
All rights reserved.
5+
6+
Redistribution and use in source and binary forms, with or without
7+
modification, are permitted provided that the following conditions are met:
8+
9+
1. Redistributions of source code must retain the above copyright notice, this
10+
list of conditions and the following disclaimer.
11+
12+
2. Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
16+
3. Neither the name of the copyright holder nor the names of its
17+
contributors may be used to endorse or promote products derived from
18+
this software without specific prior written permission.
19+
20+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<div align="center">
2+
<img width="64" src="https://avatars1.githubusercontent.com/u/66532658?s=400&u=f2457dec96897c5dbc843372ec8b325589ab84d5&v=4" alt="cookiecutter-django-rest">
3+
<h3 align="center">Python Packager</h3>
4+
<p align="center">
5+
This is a <a href="https://github.com/cookiecutter/cookiecutter" target="__blank">cookiecutter</a> template for generate a package
6+
</p>
7+
<p align="center">
8+
<a href="https://github.com/ActivandoIdeas/Cookiecutter-Flask-Microservice-SQLAlchemy/blob/master/LICENSE">
9+
<img src="https://img.shields.io/badge/License-BSD3-blue.svg" alt="license badge"/>
10+
</a>
11+
<a href="https://www.python.org/">
12+
<img src="https://img.shields.io/pypi/pyversions/Django.svg?style=flat-square" alt="python badge">
13+
</a>
14+
</p>
15+
</div>
16+
17+
# About this cookiecutter
18+
19+
## Features
20+
21+
- Simple and basic configuration for make a package and publish in pypi
22+
23+
# Prerequisites
24+
25+
* Python 3.6 or higger https://www.python.org/
26+
* Pip https://pip.pypa.io/en/stable/installing/
27+
28+
Install cookiecutter
29+
30+
```shell
31+
pip install --user cookiecutter
32+
```
33+
34+
# Install
35+
36+
Use this command
37+
38+
```shell
39+
cookiecutter https://github.com/ActivandoIdeas/Python-Package-Cookiecutter
40+
```
41+
42+
### `setup.py`
43+
44+
* **Use setuptools**
45+
It's the standard packaging library for Python. `distribute` has merged back into `setuptools`, and `distutils` is less capable.
46+
* **setup.py should not import anything from the package**
47+
When installing from source, the user may not have the packages dependencies installed, and importing the package is likely to raise an `ImportError`.
48+
* **setup.py should be the canonical source of package dependencies**
49+
There is no reason to duplicate dependency specifiers (i.e. also using a `requirements.txt` file). See the testing section below for testing dependencies.
50+
51+
### Testing
52+
53+
* **Use [Tox](https://tox.readthedocs.io) to manage test environments**
54+
Tox provides isolation, runs tests across multiple Python versions, and ensures the package can be installed.
55+
* **Uses [pytest](https://docs.pytest.org) as the default test runner**
56+
This can be changed easily, though pytest is a easier, more powerful test library and runner than the standard library's unittest.
57+
* **Define testing dependencies in `tox.ini`**
58+
Avoid duplicating dependency definitions, and use `tox.ini` as the canonical description of how the unittests should be run.
59+
* **`tests` directory should not be a package**
60+
The `tests` directory should not be a Python package unless you want to define some fixtures.
61+
But the best practices are to use [PyTest fixtures](https://docs.pytest.org/en/latest/fixture.html) which provides a better solution.
62+
Therefore, the `tests` directory has no `__init__.py` file.
63+
64+
### Build the solution
65+
```sh
66+
python -m pip install --user --upgrade setuptools wheel
67+
python setup.py sdist bdist_wheel
68+
python -m pip install --user --upgrade twine
69+
python -m twine upload dist/*
70+
```
71+
72+
73+
# License
74+
75+
BSD 3-Clause "New" or "Revised" License
76+
View in https://github.com/ActivandoIdeas/Cookiecutter-Django-AppEngine-GitLab/blob/master/LICENSE
77+
78+
# Contributing
79+
80+
Contributors are always welcome!
81+
Feel free to raise an issue or submit a PR.
82+
Read the code of Conduct here: https://github.com/ActivandoIdeas/Codigo-de-Conducta-y-Guia-Rapida
83+
84+
This project is based on cuokiecutter:
85+
* Read this for project contribution:
86+
* https://raphael.codes/blog/create-your-own-cookiecutter-template/
87+
* https://cookiecutter.readthedocs.io/en/1.7.2/tutorials.html

cookiecutter.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"full_name": "your_name",
3+
"email": "username@your_mail.com",
4+
"author_name": "{{cookiecutter.full_name}} | @{{cookiecutter.github_username}}",
5+
"github_username": "username",
6+
7+
"project_name": "Cookiecutter-Flask-Travis-Docker",
8+
"project_slug": "{{cookiecutter.project_name.lower().replace(' ', '_').replace('-', '_')}}",
9+
"project_short_description": "Flask best practices template",
10+
"description": "{{cookiecutter.project_short_description}}",
11+
12+
"version": "0.1.0",
13+
"open_source_license": [
14+
"MIT license",
15+
"BSD license",
16+
"ISC license",
17+
"Apache Software License 2.0",
18+
"GNU General Public License v3",
19+
"Not open source"
20+
],
21+
}

hooks/post_gen_project.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
PROJECT_DIRECTORY = os.path.realpath(os.path.curdir)
4+
5+
6+
def remove_file(filepath):
7+
os.remove(os.path.join(PROJECT_DIRECTORY, filepath))
8+
9+
10+
if __name__ == '__main__':
11+
12+
if 'Not open source' == '{{ cookiecutter.open_source_license }}':
13+
remove_file('LICENSE')
14+
15+
remove_file('MANIFEST.in')

0 commit comments

Comments
 (0)