1+ ###########################
12Cookiecutter Python Project
23###########################
34
@@ -64,28 +65,121 @@ It is assumed that the new Python package will eventually be:
6465The generated docs have some references and links to those sites.
6566
6667
68+ ===============
6769Getting Started
6870===============
6971
72+ --------------------
7073One Time Setup Steps
7174--------------------
7275
76+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
77+ Install cookiecutter via pip
78+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79+
7380The process for using Cookiecutter to create a new Python package project
7481starts with installing Cookiecutter. This is best done by creating a new
7582virtual environment specifically for cookiecutter and then installing
7683cookiecutter using ``pip ``. The example below shows how to do this.
7784
78- .. code-block :: console
85+ .. code-block :: shell-session
7986
8087 $ python -m venv --prompt cc ccvenv
88+ $
8189 $ source ccvenv/bin/activate
90+ $ # or for cmd.exe:
91+ $ # ccvenv\Scripts\activate.bat
92+ $ # or for PowerShell:
93+ $ # ccvenv\Scripts\Activate.ps1
94+ $
8295 (cc) $ pip install -U pip # update pip to avoid any warnings
8396 (cc) $ pip install cookiecutter
8497
85- You are now ready to create a new Python project from the Cookiecutter
86- template provided by this project.
8798
99+ ^^^^^^^^^^^^^
100+ Install hatch
101+ ^^^^^^^^^^^^^
102+
103+ If you do not yet have Hatch installed, now would be a good time to do
104+ so. Refer to the installation instructions for your operating system
105+ `here <https://hatch.pypa.io/latest/install/ >`_.
106+
107+
108+ ^^^^^^^^^^^^^^^^^^^^^^
109+ Install git (optional)
110+ ^^^^^^^^^^^^^^^^^^^^^^
111+
112+ It may also be a good idea to ensure you have ``git `` installed (and
113+ it may be required for cookiecutter to function if using it to clone
114+ this template). Under Windows, you can use `winget
115+ <https://learn.microsoft.com/en-us/windows/package-manager/winget/> `_.
116+
117+ .. code-block :: shell-session
118+
119+ (cc) $ winget install --id Git.Git --exact --source winget
120+
121+ Under macOS you can use `brew <https://brew.sh/ >`_.
122+
123+ .. code-block :: shell-session
124+
125+ (cc) $ brew install git
126+
127+ Users of other operating systems likely already have it installed or
128+ will be able to install it via their operating system's package
129+ manager.
130+
131+
132+ ^^^^^^^^^^^^^^^^^^^^^^^
133+ Install make (optional)
134+ ^^^^^^^^^^^^^^^^^^^^^^^
135+
136+ If you wish to use the fancy Makefile included in this project, you
137+ may wish to install the ``make `` command. Under Windows, again using
138+ winget:
139+
140+ .. code-block :: shell-session
141+
142+ (cc) $ winget install --id GnuWin32.Make --exact --source winget
143+
144+ Unlike with git, you will need to `manually add
145+ <https://stackoverflow.com/a/44272417/8243194> `_ the directory
146+ containing ``make.exe `` to your PATH, which is typically something like:
147+ ``C:\Program Files(x86)\GnuWin32\bin\ ``.
148+
149+ Under macOS you can again use brew.
150+
151+ .. code-block :: shell-session
152+
153+ (cc) $ brew install make
154+
155+ Users of other operating systems should again have no trouble finding
156+ it in their operating system's package manager.
88157
158+
159+ .. code-block :: console
160+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
161+ An important note for Windows users running make
162+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
163+
164+ If you are using the Makefile system, be aware that two of the targets
165+ (``help `` and ``dist-test ``) make use of PowerShell scripts to achieve
166+ Windows compatibility. These may not run unless you adjust an
167+ execution policy to permit them. This can be done by opening a Windows
168+ PowerShell as an administrator (just right-click the launcher and
169+ select ``Run as Administrator ``) and issuing the following command:
170+
171+ .. code-block :: shell-session
172+
173+ PS > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
174+
175+ You can read more about this `here
176+ <https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies> `_.
177+
178+ Finally, you are ready to create a new Python project from the
179+ Cookiecutter template provided by this project.
180+
181+
182+ --------------------
89183Create a new project
90184--------------------
91185
@@ -94,17 +188,18 @@ simply navigate to a directory where you want to create the new project, then
94188run the ``cookiecutter `` command with a command line argument referencing this
95189template.
96190
97- The easiest method is to reference this template via its GitHub URL (where 'gh'
98- is a shortened form for GitHub):
191+ The easiest method (which will fail if ``git `` is not installed) is to
192+ reference this template via its GitHub URL (where 'gh' is a shortened
193+ form for GitHub):
99194
100- .. code-block :: console
195+ .. code-block :: shell-session
101196
102197 (cc) $ cookiecutter gh:boltronics/cookiecutter-python-project
103198
104- Alternatively, if you have cloned a local copy of this template you can
105- reference it directly:
199+ Alternatively, if you have cloned or downloaded a local copy of this
200+ template, you can reference it directly:
106201
107- .. code-block :: console
202+ .. code-block :: shell-session
108203
109204 (cc) $ cookiecutter path/to/cookiecutter-python-project
110205
@@ -115,12 +210,13 @@ shown in order.
115210Once you have generated your new Python package project you can exit the
116211cookiecutter virtual environment as it is no longer required.
117212
118- .. code-block :: console
213+ .. code-block :: shell-session
119214
120215 (cc) $ deactivate
121216 $
122217
123218
219+ --------------------
124220Manual Modifications
125221--------------------
126222
@@ -141,6 +237,7 @@ using the new project.
141237 <https://pypi.python.org/pypi?:action=list_classifiers> `_.
142238
143239
240+ =======
144241Example
145242=======
146243
@@ -161,7 +258,7 @@ and hyphens in it. The package display name is first converted to lowercase
161258text and then any spaces or hyphens are converted to underscores to produce a
162259Python package name.
163260
164- .. code-block :: console
261+ .. code-block :: shell-session
165262
166263 (cc) $ cookiecutter gh:boltronics/cookiecutter-python-project
167264 [1/10] package_display_name (Package-Name): abc 123
@@ -187,18 +284,18 @@ Python package name.
187284
188285 The project has been created in the ``abc_123 `` directory.
189286
190- .. code-block :: console
287+ .. code-block :: shell-session
191288
192289 $ cd abc_123
193290
194291 If you are planning to use git, it might be a good idea to create a
195292new repository at this point.
196293
197- .. code-block :: console
294+ .. code-block :: shell-session
198295
199296 $ git init
200297 $ git add .
201- $ git commit -m ' Initial cookiecutter-python-project setup'
298+ $ git commit -m " Initial cookiecutter-python-project setup"
202299
203300 With that out of the way, it will be easy to use git to undo any
204301potential mistakes made while experimenting.
@@ -210,7 +307,7 @@ First, let's enter a project-specific virtual environment. Hatch
210307will install any of the project's dependencies (if added to pyproject.toml) as well as
211308the project itself as an editable package.
212309
213- .. code-block :: console
310+ .. code-block :: shell-session
214311
215312 $ hatch shell
216313 (abc_123) $
@@ -224,7 +321,7 @@ There are a number of other virtual environments available to you, and
224321most of these have their own packages and scripts to ease
225322development. You can bring up a summary like so:
226323
227- .. code-block :: console
324+ .. code-block :: shell-session
228325
229326 $ hatch env show
230327 Standalone
@@ -261,7 +358,7 @@ development. You can bring up a summary like so:
261358
262359 You can enter use these virtual environments like so:
263360
264- .. code-block :: console
361+ .. code-block :: shell-session
265362
266363 $ hatch shell types
267364 (types) $ pip freeze
@@ -294,7 +391,7 @@ If you have make installed, the included Makefile provides handy
294391shortcuts for various Hatch commands and the configured scripts. You
295392can print a summary of options via the `make help ` command, like so:
296393
297- .. code-block :: console
394+ .. code-block :: shell-session
298395
299396 $ make help
300397
@@ -323,10 +420,12 @@ can print a summary of options via the `make help` command, like so:
323420 dist-test - test a wheel distribution package
324421 dist-upload - upload a wheel distribution package
325422
423+ $
424+
326425
327426 Here is an example of one in action:
328427
329- .. code-block :: console
428+ .. code-block :: shell-session
330429
331430 $ make test-verbose
332431 ────────────────────────────── hatch-test.py3.13 ───────────────────────────────
@@ -384,6 +483,7 @@ Here is an example of one in action:
384483 $
385484
386485
486+ =====================================
387487Suggestions? Contributions? Problems?
388488=====================================
389489
0 commit comments