cookiecutter-pypackage 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cookiecutter_pypackage-0.2.0/LICENSE +27 -0
- cookiecutter_pypackage-0.2.0/PKG-INFO +33 -0
- cookiecutter_pypackage-0.2.0/README.md +0 -0
- cookiecutter_pypackage-0.2.0/README.rst +135 -0
- cookiecutter_pypackage-0.2.0/cookiecutter_pypackage.egg-info/PKG-INFO +33 -0
- cookiecutter_pypackage-0.2.0/cookiecutter_pypackage.egg-info/SOURCES.txt +12 -0
- cookiecutter_pypackage-0.2.0/cookiecutter_pypackage.egg-info/dependency_links.txt +1 -0
- cookiecutter_pypackage-0.2.0/cookiecutter_pypackage.egg-info/requires.txt +8 -0
- cookiecutter_pypackage-0.2.0/cookiecutter_pypackage.egg-info/top_level.txt +1 -0
- cookiecutter_pypackage-0.2.0/hooks/post_gen_project.py +12 -0
- cookiecutter_pypackage-0.2.0/hooks/pre_gen_project.py +13 -0
- cookiecutter_pypackage-0.2.0/pyproject.toml +50 -0
- cookiecutter_pypackage-0.2.0/setup.cfg +4 -0
- cookiecutter_pypackage-0.2.0/tests/test_bake_project.py +197 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
Copyright (c) Audrey Roy Greenfeld and individual contributors.
|
|
2
|
+
|
|
3
|
+
All rights reserved.
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without modification,
|
|
6
|
+
are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
* Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
this list of conditions and the following disclaimer.
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
* Neither the name of Audrey Roy Greenfeld nor the names of its contributors
|
|
14
|
+
may be used to endorse or promote products derived from this software
|
|
15
|
+
without specific prior written permission.
|
|
16
|
+
|
|
17
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
18
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
19
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
20
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
21
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
22
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
23
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
24
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
25
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
26
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cookiecutter-pypackage
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Cookiecutter template for a Python package
|
|
5
|
+
Author-email: "Audrey M. Roy Greenfeld" <audrey@feldroy.com>
|
|
6
|
+
License: BSD
|
|
7
|
+
Project-URL: homepage, https://github.com/audreyfeldroy/cookiecutter-pypackage
|
|
8
|
+
Keywords: cookiecutter,template,package
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
21
|
+
Classifier: Topic :: Software Development
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: cookiecutter>=2.6.0
|
|
26
|
+
Requires-Dist: ruff>=0.12.4
|
|
27
|
+
Requires-Dist: pytest>=8.4.1
|
|
28
|
+
Requires-Dist: pytest-cookies>=0.7.0
|
|
29
|
+
Requires-Dist: typer>=0.16.0
|
|
30
|
+
Requires-Dist: nox>=2025.5.1
|
|
31
|
+
Requires-Dist: alabaster>=1.0.0
|
|
32
|
+
Requires-Dist: watchdog>=6.0.0
|
|
33
|
+
Dynamic: license-file
|
|
File without changes
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
======================
|
|
2
|
+
Cookiecutter PyPackage
|
|
3
|
+
======================
|
|
4
|
+
|
|
5
|
+
.. image:: https://pyup.io/repos/github/audreyfeldroy/cookiecutter-pypackage/shield.svg
|
|
6
|
+
:target: https://pyup.io/repos/github/audreyfeldroy/cookiecutter-pypackage/
|
|
7
|
+
:alt: Updates
|
|
8
|
+
|
|
9
|
+
.. image:: https://readthedocs.org/projects/cookiecutter-pypackage/badge/?version=latest
|
|
10
|
+
:target: https://cookiecutter-pypackage.readthedocs.io/en/latest/?badge=latest
|
|
11
|
+
:alt: Documentation Status
|
|
12
|
+
|
|
13
|
+
Cookiecutter_ template for a Python package.
|
|
14
|
+
|
|
15
|
+
* GitHub repo: https://github.com/audreyfeldroy/cookiecutter-pypackage/
|
|
16
|
+
* Documentation: https://cookiecutter-pypackage.readthedocs.io/
|
|
17
|
+
* Free software: BSD license
|
|
18
|
+
* Discord: https://discord.gg/PWXJr3upUE
|
|
19
|
+
|
|
20
|
+
Features
|
|
21
|
+
--------
|
|
22
|
+
|
|
23
|
+
* Testing setup with pytest
|
|
24
|
+
* GitHub Actions testing: Setup to easily test for Python 3.12 and 3.13
|
|
25
|
+
* bump2version_: Pre-configured version bumping with a single command
|
|
26
|
+
* Auto-release to PyPI_ when you push a new tag to master (optional)
|
|
27
|
+
* Command line interface using Typer
|
|
28
|
+
|
|
29
|
+
.. _Cookiecutter: https://github.com/cookiecutter/cookiecutter
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Quickstart
|
|
33
|
+
----------
|
|
34
|
+
|
|
35
|
+
Install the latest Cookiecutter if you haven't installed it yet (this requires
|
|
36
|
+
Cookiecutter 1.4.0 or higher)::
|
|
37
|
+
|
|
38
|
+
pip install -U cookiecutter
|
|
39
|
+
|
|
40
|
+
Generate a Python package project::
|
|
41
|
+
|
|
42
|
+
cookiecutter https://github.com/audreyfeldroy/cookiecutter-pypackage.git
|
|
43
|
+
|
|
44
|
+
Then:
|
|
45
|
+
|
|
46
|
+
* Create a repo and put it there.
|
|
47
|
+
|
|
48
|
+
* Register_ your project with PyPI.
|
|
49
|
+
* Add the repo to your `Read the Docs`_ account + turn on the Read the Docs service hook.
|
|
50
|
+
* Release your package by pushing a new tag to master.
|
|
51
|
+
|
|
52
|
+
.. _Register: https://packaging.python.org/tutorials/packaging-projects/#uploading-the-distribution-archives
|
|
53
|
+
|
|
54
|
+
For more details, see the `cookiecutter-pypackage tutorial`_.
|
|
55
|
+
|
|
56
|
+
.. _`cookiecutter-pypackage tutorial`: https://cookiecutter-pypackage.readthedocs.io/en/latest/tutorial.html
|
|
57
|
+
|
|
58
|
+
Not Exactly What You Want?
|
|
59
|
+
--------------------------
|
|
60
|
+
|
|
61
|
+
Don't worry, you have options:
|
|
62
|
+
|
|
63
|
+
Similar Cookiecutter Templates
|
|
64
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
65
|
+
|
|
66
|
+
* `Nekroze/cookiecutter-pypackage`_: A fork of this with a PyTest test runner,
|
|
67
|
+
strict flake8 checking with Travis/Tox, and some docs and ``setup.py`` differences.
|
|
68
|
+
|
|
69
|
+
* `tony/cookiecutter-pypackage-pythonic`_: Fork with py2.7+3.3 optimizations.
|
|
70
|
+
Flask/Werkzeug-style test runner, ``_compat`` module and module/doc conventions.
|
|
71
|
+
See ``README.rst`` or the `github comparison view`_ for exhaustive list of
|
|
72
|
+
additions and modifications.
|
|
73
|
+
|
|
74
|
+
* `ardydedase/cookiecutter-pypackage`_: A fork with separate requirements files rather than a requirements list in the ``setup.py`` file.
|
|
75
|
+
|
|
76
|
+
* `lgiordani/cookiecutter-pypackage`_: A fork of Cookiecutter that uses Punch_ instead of bump2version_ and with separate requirements files.
|
|
77
|
+
|
|
78
|
+
* `briggySmalls/cookiecutter-pypackage`_: A fork using Poetry_ for neat package management and deployment, with linting, formatting, no makefiles and more.
|
|
79
|
+
|
|
80
|
+
* `veit/cookiecutter-namespace-template`_: A cookiecutter template for python modules with a namespace
|
|
81
|
+
|
|
82
|
+
* `zillionare/cookiecutter-pypackage`_: A template containing Poetry_, Mkdocs_, Github CI and many more. It's a template and a package also (can be installed with `pip`)
|
|
83
|
+
|
|
84
|
+
* `waynerv/cookiecutter-pypackage`_: A fork using Poetry_, Mkdocs_, Pre-commit_, Black_ and Mypy_. Run test, staging and release workflows with GitHub Actions, automatically generate release notes from CHANGELOG.
|
|
85
|
+
|
|
86
|
+
* `x-pt/template`_: A CookieCutter-based template designed to serve as a robust starting point for most startup projects hosted on GitHub, supporting `Python`, `C++/CUDA`, `Rust`, `Golang`, `TypeScript`.
|
|
87
|
+
|
|
88
|
+
* Also see the `network`_ and `family tree`_ for this repo. (If you find
|
|
89
|
+
anything that should be listed here, please add it and send a pull request!)
|
|
90
|
+
|
|
91
|
+
Fork This / Create Your Own
|
|
92
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
93
|
+
|
|
94
|
+
If you have differences in your preferred setup, I encourage you to fork this
|
|
95
|
+
to create your own version. Or create your own; it doesn't strictly have to
|
|
96
|
+
be a fork.
|
|
97
|
+
|
|
98
|
+
* Once you have your own version working, add it to the Similar Cookiecutter
|
|
99
|
+
Templates list above with a brief description.
|
|
100
|
+
|
|
101
|
+
* It's up to you whether or not to rename your fork/own version. Do whatever
|
|
102
|
+
you think sounds good.
|
|
103
|
+
|
|
104
|
+
Or Submit a Pull Request
|
|
105
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
106
|
+
|
|
107
|
+
I also accept pull requests on this, if they're small, atomic, and if they
|
|
108
|
+
make my own packaging experience better.
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
.. _Tox: https://tox.wiki/en/latest/
|
|
112
|
+
.. _Sphinx: http://sphinx-doc.org/
|
|
113
|
+
.. _Read the Docs: https://readthedocs.io/
|
|
114
|
+
.. _`pyup.io`: https://pyup.io/
|
|
115
|
+
.. _bump2version: https://github.com/c4urself/bump2version
|
|
116
|
+
.. _Punch: https://github.com/lgiordani/punch
|
|
117
|
+
.. _Poetry: https://python-poetry.org/
|
|
118
|
+
.. _PyPi: https://pypi.python.org/pypi
|
|
119
|
+
.. _Mkdocs: https://pypi.org/project/mkdocs/
|
|
120
|
+
.. _Pre-commit: https://pre-commit.com/
|
|
121
|
+
.. _Black: https://black.readthedocs.io/en/stable/
|
|
122
|
+
.. _Mypy: https://mypy.readthedocs.io/en/stable/
|
|
123
|
+
|
|
124
|
+
.. _`Nekroze/cookiecutter-pypackage`: https://github.com/Nekroze/cookiecutter-pypackage
|
|
125
|
+
.. _`tony/cookiecutter-pypackage-pythonic`: https://github.com/tony/cookiecutter-pypackage-pythonic
|
|
126
|
+
.. _`ardydedase/cookiecutter-pypackage`: https://github.com/ardydedase/cookiecutter-pypackage
|
|
127
|
+
.. _`lgiordani/cookiecutter-pypackage`: https://github.com/lgiordani/cookiecutter-pypackage
|
|
128
|
+
.. _`briggySmalls/cookiecutter-pypackage`: https://github.com/briggySmalls/cookiecutter-pypackage
|
|
129
|
+
.. _`veit/cookiecutter-namespace-template`: https://github.com/veit/cookiecutter-namespace-template
|
|
130
|
+
.. _`zillionare/cookiecutter-pypackage`: https://zillionare.github.io/cookiecutter-pypackage/
|
|
131
|
+
.. _`waynerv/cookiecutter-pypackage`: https://waynerv.github.io/cookiecutter-pypackage/
|
|
132
|
+
.. _`x-pt/template`: https://github.com/x-pt/template
|
|
133
|
+
.. _github comparison view: https://github.com/tony/cookiecutter-pypackage-pythonic/compare/audreyr:master...master
|
|
134
|
+
.. _`network`: https://github.com/audreyr/cookiecutter-pypackage/network
|
|
135
|
+
.. _`family tree`: https://github.com/audreyr/cookiecutter-pypackage/network/members
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cookiecutter-pypackage
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Cookiecutter template for a Python package
|
|
5
|
+
Author-email: "Audrey M. Roy Greenfeld" <audrey@feldroy.com>
|
|
6
|
+
License: BSD
|
|
7
|
+
Project-URL: homepage, https://github.com/audreyfeldroy/cookiecutter-pypackage
|
|
8
|
+
Keywords: cookiecutter,template,package
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Natural Language :: English
|
|
13
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
20
|
+
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
21
|
+
Classifier: Topic :: Software Development
|
|
22
|
+
Requires-Python: >=3.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: cookiecutter>=2.6.0
|
|
26
|
+
Requires-Dist: ruff>=0.12.4
|
|
27
|
+
Requires-Dist: pytest>=8.4.1
|
|
28
|
+
Requires-Dist: pytest-cookies>=0.7.0
|
|
29
|
+
Requires-Dist: typer>=0.16.0
|
|
30
|
+
Requires-Dist: nox>=2025.5.1
|
|
31
|
+
Requires-Dist: alabaster>=1.0.0
|
|
32
|
+
Requires-Dist: watchdog>=6.0.0
|
|
33
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
README.rst
|
|
4
|
+
pyproject.toml
|
|
5
|
+
cookiecutter_pypackage.egg-info/PKG-INFO
|
|
6
|
+
cookiecutter_pypackage.egg-info/SOURCES.txt
|
|
7
|
+
cookiecutter_pypackage.egg-info/dependency_links.txt
|
|
8
|
+
cookiecutter_pypackage.egg-info/requires.txt
|
|
9
|
+
cookiecutter_pypackage.egg-info/top_level.txt
|
|
10
|
+
hooks/post_gen_project.py
|
|
11
|
+
hooks/pre_gen_project.py
|
|
12
|
+
tests/test_bake_project.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
hooks
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
import pathlib
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
if __name__ == '__main__':
|
|
6
|
+
|
|
7
|
+
if '{{ cookiecutter.create_author_file }}' != 'y':
|
|
8
|
+
pathlib.Path('AUTHORS.rst').unlink()
|
|
9
|
+
pathlib.Path('docs', 'authors.rst').unlink()
|
|
10
|
+
|
|
11
|
+
if 'Not open source' == '{{ cookiecutter.open_source_license }}':
|
|
12
|
+
pathlib.Path('LICENSE').unlink()
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import re
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
MODULE_REGEX = r'^[_a-zA-Z][_a-zA-Z0-9]+$'
|
|
6
|
+
|
|
7
|
+
module_name = '{{ cookiecutter.project_slug}}'
|
|
8
|
+
|
|
9
|
+
if not re.match(MODULE_REGEX, module_name):
|
|
10
|
+
print('ERROR: The project slug (%s) is not a valid Python module name. '
|
|
11
|
+
'Please do not use a - and use _ instead' % module_name)
|
|
12
|
+
#Exit to cancel project
|
|
13
|
+
sys.exit(1)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "cookiecutter-pypackage"
|
|
3
|
+
version = "0.2.0"
|
|
4
|
+
description = "Cookiecutter template for a Python package"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.10"
|
|
7
|
+
license = { text = "BSD" }
|
|
8
|
+
authors = [
|
|
9
|
+
{ name = "Audrey M. Roy Greenfeld", email = "audrey@feldroy.com" }
|
|
10
|
+
]
|
|
11
|
+
keywords = ["cookiecutter", "template", "package"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 4 - Beta",
|
|
14
|
+
"Environment :: Console",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Natural Language :: English",
|
|
17
|
+
"License :: OSI Approved :: BSD License",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: Implementation :: CPython",
|
|
24
|
+
"Programming Language :: Python :: Implementation :: PyPy",
|
|
25
|
+
"Topic :: Software Development",
|
|
26
|
+
]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"cookiecutter>=2.6.0",
|
|
29
|
+
"ruff>=0.12.4",
|
|
30
|
+
"pytest>=8.4.1",
|
|
31
|
+
"pytest-cookies>=0.7.0",
|
|
32
|
+
"typer>=0.16.0",
|
|
33
|
+
"nox>=2025.5.1",
|
|
34
|
+
"alabaster>=1.0.0",
|
|
35
|
+
"watchdog>=6.0.0",
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
[project.urls]
|
|
39
|
+
homepage = "https://github.com/audreyfeldroy/cookiecutter-pypackage"
|
|
40
|
+
|
|
41
|
+
[tool.ruff]
|
|
42
|
+
exclude = [
|
|
43
|
+
"*cookiecutter.project_slug*"
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[tool.pytest.ini_options]
|
|
47
|
+
testpaths = [
|
|
48
|
+
"tests",
|
|
49
|
+
]
|
|
50
|
+
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
from contextlib import contextmanager
|
|
2
|
+
import importlib
|
|
3
|
+
import shlex
|
|
4
|
+
import os
|
|
5
|
+
import sys
|
|
6
|
+
import subprocess
|
|
7
|
+
import yaml
|
|
8
|
+
import datetime
|
|
9
|
+
import pytest
|
|
10
|
+
from cookiecutter.utils import rmtree
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@contextmanager
|
|
15
|
+
def inside_dir(dirpath):
|
|
16
|
+
"""
|
|
17
|
+
Execute code from inside the given directory
|
|
18
|
+
:param dirpath: String, path of the directory the command is being run.
|
|
19
|
+
"""
|
|
20
|
+
old_path = os.getcwd()
|
|
21
|
+
try:
|
|
22
|
+
os.chdir(dirpath)
|
|
23
|
+
yield
|
|
24
|
+
finally:
|
|
25
|
+
os.chdir(old_path)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@contextmanager
|
|
29
|
+
def bake_in_temp_dir(cookies, *args, **kwargs):
|
|
30
|
+
"""
|
|
31
|
+
Delete the temporal directory that is created when executing the tests
|
|
32
|
+
:param cookies: pytest_cookies.Cookies,
|
|
33
|
+
cookie to be baked and its temporal files will be removed
|
|
34
|
+
"""
|
|
35
|
+
result = cookies.bake(*args, **kwargs)
|
|
36
|
+
try:
|
|
37
|
+
yield result
|
|
38
|
+
finally:
|
|
39
|
+
rmtree(str(result.project))
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def run_inside_dir(command, dirpath):
|
|
43
|
+
"""
|
|
44
|
+
Run a command from inside a given directory, returning the exit status
|
|
45
|
+
:param command: Command that will be executed
|
|
46
|
+
:param dirpath: String, path of the directory the command is being run.
|
|
47
|
+
"""
|
|
48
|
+
with inside_dir(dirpath):
|
|
49
|
+
return subprocess.check_call(shlex.split(command))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def check_output_inside_dir(command, dirpath):
|
|
53
|
+
"Run a command from inside a given directory, returning the command output"
|
|
54
|
+
with inside_dir(dirpath):
|
|
55
|
+
return subprocess.check_output(shlex.split(command))
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_year_compute_in_license_file(cookies):
|
|
59
|
+
with bake_in_temp_dir(cookies) as result:
|
|
60
|
+
license_file_path = result.project.join('LICENSE')
|
|
61
|
+
now = datetime.datetime.now()
|
|
62
|
+
assert str(now.year) in license_file_path.read()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def project_info(result):
|
|
66
|
+
"""Get toplevel dir, project_slug, and project dir from baked cookies"""
|
|
67
|
+
assert result.exception is None
|
|
68
|
+
assert result.project.isdir()
|
|
69
|
+
|
|
70
|
+
project_path = str(result.project)
|
|
71
|
+
project_slug = os.path.split(project_path)[-1]
|
|
72
|
+
project_dir = os.path.join(project_path, project_slug)
|
|
73
|
+
return project_path, project_slug, project_dir
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def test_bake_with_defaults(cookies):
|
|
77
|
+
with bake_in_temp_dir(cookies) as result:
|
|
78
|
+
assert result.project.isdir()
|
|
79
|
+
assert result.exit_code == 0
|
|
80
|
+
assert result.exception is None
|
|
81
|
+
found_toplevel_files = [f.basename for f in result.project.listdir()]
|
|
82
|
+
assert 'src' in found_toplevel_files
|
|
83
|
+
assert 'tests' in found_toplevel_files
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_bake_and_run_tests(cookies):
|
|
87
|
+
with bake_in_temp_dir(cookies) as result:
|
|
88
|
+
assert result.project.isdir()
|
|
89
|
+
run_inside_dir('pytest', str(result.project)) == 0
|
|
90
|
+
print("test_bake_and_run_tests path", str(result.project))
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
@pytest.mark.skip(reason="A rare edge case, probably Cookiecutter's fault")
|
|
94
|
+
def test_bake_withspecialchars_and_run_tests(cookies):
|
|
95
|
+
"""Ensure that a `full_name` with double quotes does not break pytest"""
|
|
96
|
+
with bake_in_temp_dir(
|
|
97
|
+
cookies,
|
|
98
|
+
extra_context={'full_name': 'name "quote" name'}
|
|
99
|
+
) as result:
|
|
100
|
+
assert result.project.isdir()
|
|
101
|
+
run_inside_dir('pytest', str(result.project)) == 0
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def test_bake_with_apostrophe_and_run_tests(cookies):
|
|
105
|
+
"""Ensure that a `full_name` with apostrophes does not break setup.py"""
|
|
106
|
+
with bake_in_temp_dir(
|
|
107
|
+
cookies,
|
|
108
|
+
extra_context={'full_name': "O'connor"}
|
|
109
|
+
) as result:
|
|
110
|
+
assert result.project.isdir()
|
|
111
|
+
run_inside_dir('pytest', str(result.project)) == 0
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def test_bake_without_author_file(cookies):
|
|
115
|
+
with bake_in_temp_dir(
|
|
116
|
+
cookies,
|
|
117
|
+
extra_context={'create_author_file': 'n'}
|
|
118
|
+
) as result:
|
|
119
|
+
found_toplevel_files = [f.basename for f in result.project.listdir()]
|
|
120
|
+
assert 'AUTHORS.rst' not in found_toplevel_files
|
|
121
|
+
doc_files = [f.basename for f in result.project.join('docs').listdir()]
|
|
122
|
+
assert 'authors.rst' not in doc_files
|
|
123
|
+
|
|
124
|
+
# Assert there are no spaces in the toc tree
|
|
125
|
+
docs_index_path = result.project.join('docs/index.rst')
|
|
126
|
+
with open(str(docs_index_path)) as index_file:
|
|
127
|
+
assert 'contributing\n history' in index_file.read()
|
|
128
|
+
|
|
129
|
+
# Check that
|
|
130
|
+
manifest_path = result.project.join('MANIFEST.in')
|
|
131
|
+
with open(str(manifest_path)) as manifest_file:
|
|
132
|
+
assert 'AUTHORS.rst' not in manifest_file.read()
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def test_make_help(cookies):
|
|
136
|
+
with bake_in_temp_dir(cookies) as result:
|
|
137
|
+
# The supplied Makefile does not support win32
|
|
138
|
+
if sys.platform != "win32":
|
|
139
|
+
output = check_output_inside_dir(
|
|
140
|
+
'make help',
|
|
141
|
+
str(result.project)
|
|
142
|
+
)
|
|
143
|
+
assert b"check code coverage quickly with the default Python" in \
|
|
144
|
+
output
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_bake_selecting_license(cookies):
|
|
148
|
+
license_strings = {
|
|
149
|
+
'MIT license': 'MIT ',
|
|
150
|
+
'BSD license': 'Redistributions of source code must retain the ' +
|
|
151
|
+
'above copyright notice, this',
|
|
152
|
+
'ISC license': 'ISC License',
|
|
153
|
+
'Apache Software License 2.0':
|
|
154
|
+
'Licensed under the Apache License, Version 2.0',
|
|
155
|
+
'GNU General Public License v3': 'GNU GENERAL PUBLIC LICENSE',
|
|
156
|
+
'GNU Affero General Public License': 'GNU AFFERO GENERAL PUBLIC LICENSE',
|
|
157
|
+
}
|
|
158
|
+
for license, target_string in license_strings.items():
|
|
159
|
+
with bake_in_temp_dir(
|
|
160
|
+
cookies,
|
|
161
|
+
extra_context={'open_source_license': license}
|
|
162
|
+
) as result:
|
|
163
|
+
assert target_string in result.project.join('LICENSE').read()
|
|
164
|
+
assert license in result.project.join('pyproject.toml').read()
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def test_bake_not_open_source(cookies):
|
|
168
|
+
with bake_in_temp_dir(
|
|
169
|
+
cookies,
|
|
170
|
+
extra_context={'open_source_license': 'Not open source'}
|
|
171
|
+
) as result:
|
|
172
|
+
found_toplevel_files = [f.basename for f in result.project.listdir()]
|
|
173
|
+
assert 'pyproject.toml' in found_toplevel_files
|
|
174
|
+
assert 'LICENSE' not in found_toplevel_files
|
|
175
|
+
assert 'License' not in result.project.join('README.rst').read()
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def test_using_pytest(cookies):
|
|
179
|
+
with bake_in_temp_dir(
|
|
180
|
+
cookies,
|
|
181
|
+
extra_context={'use_pytest': 'y'}
|
|
182
|
+
) as result:
|
|
183
|
+
assert result.project.isdir()
|
|
184
|
+
test_file_path = result.project.join(
|
|
185
|
+
'tests/test_python_boilerplate.py'
|
|
186
|
+
)
|
|
187
|
+
lines = test_file_path.readlines()
|
|
188
|
+
assert "import pytest" in ''.join(lines)
|
|
189
|
+
# Test the new pytest target
|
|
190
|
+
run_inside_dir('pytest', str(result.project)) == 0
|
|
191
|
+
|
|
192
|
+
# def test_project_with_hyphen_in_module_name(cookies):
|
|
193
|
+
# result = cookies.bake(
|
|
194
|
+
# extra_context={'project_name': 'something-with-a-dash'}
|
|
195
|
+
# )
|
|
196
|
+
# assert result.project is not None
|
|
197
|
+
# project_path = str(result.project)
|