@@ -44,41 +44,36 @@ cd ./rick-portal-gun
4444
4545## Dependencies and environment
4646
47- Add ` typer[all] ` to your dependencies:
47+ Add ` typer ` to your dependencies:
4848
4949<div class =" termy " >
5050
5151``` console
52- $ poetry add " typer[all] "
52+ $ poetry add " typer"
5353
5454// It creates a virtual environment for your project
5555Creating virtualenv rick-portal-gun-w31dJa0b-py3.10 in /home/rick/.cache/pypoetry/virtualenvs
56- Using version ^0.1 .0 for typer
56+ Using version ^0.12 .0 for typer
5757
5858Updating dependencies
5959Resolving dependencies... (1.2s)
6060
61- Writing lock file
62-
6361---> 100%
6462
65- Package operations: 15 installs, 0 updates, 0 removals
66-
67- - Installing zipp (3.1.0)
68- - Installing importlib-metadata (1.5.0)
69- - Installing pyparsing (2.4.6)
70- - Installing six (1.14.0)
71- - Installing attrs (19.3.0)
72- - Installing click (7.1.1)
73- - Installing colorama (0.4.3)
74- - Installing more-itertools (8.2.0)
75- - Installing packaging (20.3)
76- - Installing pluggy (0.13.1)
77- - Installing py (1.8.1)
78- - Installing shellingham (1.3.2)
79- - Installing wcwidth (0.1.8)
80- - Installing pytest (5.4.1)
81- - Installing typer (0.0.11)
63+ Package operations: 10 installs, 0 updates, 0 removals
64+
65+ - Installing mdurl (0.1.2)
66+ - Installing markdown-it-py (3.0.0)
67+ - Installing pygments (2.17.2)
68+ - Installing click (8.1.7)
69+ - Installing rich (13.7.1)
70+ - Installing shellingham (1.5.4)
71+ - Installing typing-extensions (4.10.0)
72+ - Installing typer-slim (0.12.0)
73+ - Installing typer-cli (0.12.0)
74+ - Installing typer (0.12.0)
75+
76+ Writing lock file
8277
8378// Activate that new virtual environment
8479$ poetry shell
@@ -97,12 +92,11 @@ You can see that you have a generated project structure that looks like:
9792.
9893├── poetry.lock
9994├── pyproject.toml
100- ├── README.rst
95+ ├── README.md
10196├── rick_portal_gun
10297│ └── __init__.py
10398└── tests
10499 ├── __init__.py
105- └── test_rick_portal_gun.py
106100```
107101
108102## Create your app
@@ -146,69 +140,16 @@ def load():
146140
147141## Modify the README
148142
149- Let's change the README. By default it's a file ` README .rst` .
143+ The default README has ` .md ` extension so we can use Markdown syntax. It can be replaced with ` .rst ` (reStructuredText), along with the corresponding change in ` pyproject.toml ` 's project metadata .
150144
151- Let's change it to ` README.md ` . So, change the extension from ` .rst ` to ` .md ` .
152-
153- So that we can use Markdown instead of reStructuredText.
154-
155- And change the file to have something like:
145+ Change ` README.md ` to have something like:
156146
157147``` Markdown
158148# Portal Gun
159149
160150The awesome Portal Gun
161151```
162152
163- ## Modify your project metadata
164-
165- Edit your file ` pyproject.toml ` .
166-
167- It would look something like:
168-
169- ``` TOML
170- [tool .poetry ]
171- name = " rick-portal-gun"
172- version = " 0.1.0"
173- description = " "
174- authors = [
" Rick Sanchez <[email protected] >" ]
175-
176- [tool .poetry .dependencies ]
177- python = " ^3.10"
178- typer = {extras = [" all" ], version = " ^0.1.0" }
179-
180- [tool .poetry .dev-dependencies ]
181- pytest = " ^5.2"
182-
183- [build-system ]
184- requires = [" poetry>=0.12" ]
185- build-backend = " poetry.masonry.api"
186- ```
187-
188- We changed the default README, so let's make it use the new ` README.md ` .
189-
190- Add the line:
191-
192- ``` TOML hl_lines="6"
193- [tool .poetry ]
194- name = " rick-portal-gun"
195- version = " 0.1.0"
196- description = " "
197- authors = [
" Rick Sanchez <[email protected] >" ]
198- readme = " README.md"
199-
200- [tool .poetry .dependencies ]
201- python = " ^3.10"
202- typer = {extras = [" all" ], version = " ^0.1.0" }
203-
204- [tool .poetry .dev-dependencies ]
205- pytest = " ^5.2"
206-
207- [build-system ]
208- requires = [" poetry>=0.12" ]
209- build-backend = " poetry.masonry.api"
210- ```
211-
212153## Add a "script"
213154
214155We are creating a Python package that can be installed with ` pip install ` .
@@ -230,14 +171,11 @@ rick-portal-gun = "rick_portal_gun.main:app"
230171
231172[tool .poetry .dependencies ]
232173python = " ^3.10"
233- typer = {extras = [" all" ], version = " ^0.1.0" }
234-
235- [tool .poetry .dev-dependencies ]
236- pytest = " ^5.2"
174+ typer = " ^0.12.0"
237175
238176[build-system ]
239- requires = [" poetry>=0.12 " ]
240- build-backend = " poetry.masonry.api"
177+ requires = [" poetry-core " ]
178+ build-backend = " poetry.core. masonry.api"
241179```
242180
243181Here's what that line means:
@@ -286,7 +224,7 @@ Installing dependencies from lock file
286224
287225No dependencies to install or update
288226
289- - Installing rick-portal-gun (0.1.0)
227+ - Installing the current project: rick-portal-gun (0.1.0)
290228```
291229
292230</div >
@@ -305,7 +243,7 @@ $ which rick-portal-gun
305243/home/rick/.cache/pypoetry/virtualenvs/rick-portal-gun-w31dJa0b-py3.10/bin/rick-portal-gun
306244
307245// Try it
308- $ rick-portal-gun
246+ $ rick-portal-gun --help
309247
310248// You get all the standard help
311249Usage: rick-portal-gun [OPTIONS] COMMAND [ARGS]...
@@ -339,7 +277,6 @@ $ poetry build
339277Building rick-portal-gun (0.1.0)
340278 - Building sdist
341279 - Built rick-portal-gun-0.1.0.tar.gz
342-
343280 - Building wheel
344281 - Built rick_portal_gun-0.1.0-py3-none-any.whl
345282```
@@ -367,7 +304,7 @@ Now you can open another terminal and install that package from the file for you
367304<div class =" termy " >
368305
369306``` console
370- $ pip install --user /home/rock/code /rick-portal-gun/dist/rick_portal_gun-0.1.0-py3-none-any.whl
307+ $ pip install --user /home/rick /rick-portal-gun/dist/rick_portal_gun-0.1.0-py3-none-any.whl
371308
372309---> 100%
373310```
@@ -402,7 +339,7 @@ Having it installed globally (and not in a single environment), you can now inst
402339``` console
403340$ rick-portal-gun --install-completion
404341
405- zsh completion installed in /home/user /.zshrc.
342+ zsh completion installed in /home/rick /.zshrc.
406343Completion will take effect once you restart the terminal.
407344```
408345
@@ -468,14 +405,13 @@ The file would live right beside `__init__.py`:
468405.
469406├── poetry.lock
470407├── pyproject.toml
471- ├── README.rst
408+ ├── README.md
472409├── rick_portal_gun
473410│ ├── __init__.py
474411│ ├── __main__.py
475412│ └── main.py
476413└── tests
477414 ├── __init__.py
478- └── test_rick_portal_gun.py
479415```
480416
481417No other file has to import it, you don't have to reference it in your ` pyproject.toml ` or anything else, it just works by default, as it is standard Python behavior.
@@ -492,7 +428,7 @@ Now, after installing your package, if you call it with `python -m` it will work
492428<div class =" termy " >
493429
494430``` console
495- $ python -m rick_portal_gun
431+ $ python -m rick_portal_gun --help
496432
497433Usage: __main__.py [OPTIONS] COMMAND [ARGS]...
498434
@@ -542,7 +478,7 @@ app(prog_name="rick-portal-gun")
542478<div class =" termy " >
543479
544480``` console
545- $ python -m rick_portal_gun
481+ $ python -m rick_portal_gun --help
546482
547483Usage: rick-portal-gun [OPTIONS] COMMAND [ARGS]...
548484
@@ -632,7 +568,6 @@ $ poetry publish --build
632568Building rick-portal-gun (0.1.0)
633569 - Building sdist
634570 - Built rick-portal-gun-0.1.0.tar.gz
635-
636571 - Building wheel
637572 - Built rick_portal_gun-0.1.0-py3-none-any.whl
638573
@@ -659,9 +594,9 @@ $ pip uninstall rick-portal-gun
659594Found existing installation: rick-portal-gun 0.1.0
660595Uninstalling rick-portal-gun-0.1.0:
661596 Would remove:
662- /home/user /.local/bin/rick-portal-gun
663- /home/user /.local/lib/python3.10/site-packages/rick_portal_gun-0.1.0.dist-info/*
664- /home/user /.local/lib/python3.10/site-packages/rick_portal_gun/*
597+ /home/rick /.local/bin/rick-portal-gun
598+ /home/rick /.local/lib/python3.10/site-packages/rick_portal_gun-0.1.0.dist-info/*
599+ /home/rick /.local/lib/python3.10/site-packages/rick_portal_gun/*
665600# Proceed (y/n)? $ y
666601 Successfully uninstalled rick-portal-gun-0.1.0
667602```
@@ -677,11 +612,18 @@ $ pip install --user rick-portal-gun
677612
678613// Notice that it says "Downloading" 🚀
679614Collecting rick-portal-gun
680- Downloading rick_portal_gun-0.1.0-py3-none-any.whl (1.8 kB)
681- Requirement already satisfied: typer[all]<0.0.12,>=0.0.11 in ./.local/lib/python3.10/site-packages (from rick-portal-gun) (0.0.11)
682- Requirement already satisfied: click<7.2.0,>=7.1.1 in ./anaconda3/lib/python3.10/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (7.1.1)
683- Requirement already satisfied: colorama; extra == "all" in ./anaconda3/lib/python3.10/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (0.4.3)
684- Requirement already satisfied: shellingham; extra == "all" in ./anaconda3/lib/python3.10/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (1.3.1)
615+ Downloading rick_portal_gun-0.1.0-py3-none-any.whl.metadata (435 bytes)
616+ Requirement already satisfied: typer<0.13.0,>=0.12.0 in ./.local/lib/python3.10/site-packages (from rick-portal-gun==0.1.0) (0.12.0)
617+ Requirement already satisfied: typer-cli==0.12.0 in ./.local/lib/python3.10/site-packages (from typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (0.12.0)
618+ Requirement already satisfied: typer-slim[standard]==0.12.0 in ./.local/lib/python3.10/site-packages (from typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (0.12.0)
619+ Requirement already satisfied: typing-extensions>=3.7.4.3 in ./.local/lib/python3.10/site-packages (from typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (4.10.0)
620+ Requirement already satisfied: click>=8.0.0 in ./.local/lib/python3.10/site-packages (from typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (8.1.7)
621+ Requirement already satisfied: shellingham>=1.3.0 in ./.local/lib/python3.10/site-packages (from typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (1.5.4)
622+ Requirement already satisfied: rich>=10.11.0 in ./.local/lib/python3.10/site-packages (from typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (13.7.1)
623+ Requirement already satisfied: pygments<3.0.0,>=2.13.0 in ./.local/lib/python3.10/site-packages (from rich>=10.11.0->typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (2.17.2)
624+ Requirement already satisfied: markdown-it-py>=2.2.0 in ./.local/lib/python3.10/site-packages (from rich>=10.11.0->typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (3.0.0)
625+ Requirement already satisfied: mdurl~=0.1 in ./.local/lib/python3.10/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer-slim[standard]==0.12.0->typer<0.13.0,>=0.12.0->rick-portal-gun==0.1.0) (0.1.2)
626+ Downloading rick_portal_gun-0.1.0-py3-none-any.whl (1.8 kB)
685627Installing collected packages: rick-portal-gun
686628Successfully installed rick-portal-gun-0.1.0
687629```
@@ -741,14 +683,11 @@ rick-portal-gun = "rick_portal_gun.main:app"
741683
742684[tool .poetry .dependencies ]
743685python = " ^3.10"
744- typer = {extras = [" all" ], version = " ^0.1.0" }
745-
746- [tool .poetry .dev-dependencies ]
747- pytest = " ^5.2"
686+ typer = " ^0.12.0"
748687
749688[build-system ]
750- requires = [" poetry>=0.12 " ]
751- build-backend = " poetry.masonry.api"
689+ requires = [" poetry-core " ]
690+ build-backend = " poetry.core. masonry.api"
752691```
753692
754693And in the file ` rick_portal_gun/__init__.py ` :
@@ -769,7 +708,6 @@ $ poetry publish --build
769708Building rick-portal-gun (0.2.0)
770709 - Building sdist
771710 - Built rick-portal-gun-0.2.0.tar.gz
772-
773711 - Building wheel
774712 - Built rick_portal_gun-0.2.0-py3-none-any.whl
775713
0 commit comments