Skip to content

Commit d2f0c94

Browse files
authored
Merge pull request #602 from realpython/pyproject-toml
`pyproject.toml` article materials
2 parents b565cb2 + e554943 commit d2f0c94

File tree

8 files changed

+127
-0
lines changed

8 files changed

+127
-0
lines changed

python-pyproject-toml/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Python pyproject.toml Project Example
2+
3+
Here are supporting materials for the Real Python tutorial [How to Manage Python Projects With `pyproject.toml`](https://realpython.com/python-pyproject-toml/).
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.egg-info
5+
venv/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2024 Real Python
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Snakesay
2+
3+
A simple Python project that prints a message in a speech bubble inspired by the classic [`cowsay`](https://en.wikipedia.org/wiki/Cowsay) program. Originally created by [Ian Currie](https://realpython.com/team/icurrie/) and [Geir Arne Hjelle](https://realpython.com/team/gahjelle/) for the [Everyday Project Packaging With `pyproject.toml`](https://realpython.com/courses/packaging-with-pyproject-toml/) course on Real Python.
4+
5+
```console
6+
$ ssay Hello World!
7+
8+
______________
9+
( Hello World! )
10+
‾‾‾‾‾‾‾‾‾‾‾‾‾‾
11+
\
12+
\ ___
13+
\ (o o)
14+
\_/ \
15+
λ \ \
16+
_\ \_
17+
(_____)_
18+
(________)=Oo°
19+
```
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[build-system]
2+
requires = ["setuptools>=75.3.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "snakesay"
7+
dependencies = ["rich>=13.9.0"]
8+
authors = [{name = "Jin Doe", email = "[email protected]"}]
9+
keywords = ["CLI", "ASCII Art"]
10+
readme = {file = "README.md", content-type = "text/markdown"}
11+
requires-python = ">=3.9"
12+
classifiers = [
13+
"Development Status :: 3 - Alpha",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: MIT License",
16+
"Programming Language :: Python :: 3",
17+
"Programming Language :: Python :: 3.9",
18+
"Programming Language :: Python :: 3.10",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
]
23+
dynamic = ["version"]
24+
25+
[project.urls]
26+
Repository = "https://github.com/me/spam.git"
27+
Issues = "https://github.com/me/spam/issues"
28+
29+
[project.optional-dependencies]
30+
dev = ["black>=24.1.0", "isort>=5.13.0", "build", "twine"]
31+
32+
[project.scripts]
33+
ssay = "snakesay.__main__:main"
34+
35+
[tool.setuptools.packages.find]
36+
where = ["."]
37+
38+
[tool.setuptools.dynamic]
39+
version = {attr = "snakesay.__version__"}
40+
41+
[tool.black]
42+
line-length = 88
43+
44+
[tool.isort]
45+
profile = "black"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Snakesay - cowsay, but with a snake."""
2+
3+
__version__ = "1.0.0"
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
3+
from snakesay import snake
4+
5+
6+
def main():
7+
snake.say(" ".join(sys.argv[1:]))
8+
9+
10+
if __name__ == "__main__":
11+
main()
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
SNAKE = r""" \
2+
\ ___
3+
\ (o o)
4+
\_/ \
5+
λ \ \
6+
_\ \_
7+
(_____)_
8+
(________)=Oo°
9+
"""
10+
11+
12+
def bubble(message):
13+
bubble_length = len(message) + 2
14+
return f"""
15+
{"_" * bubble_length}
16+
( {message} )
17+
{"‾" * bubble_length}"""
18+
19+
20+
def say(message):
21+
print(bubble(message.replace("s", "ss").replace("S", "SS")))
22+
print(SNAKE)

0 commit comments

Comments
 (0)