Skip to content

Commit b8d2033

Browse files
committed
Setting Poetry as the default
1 parent 18272a4 commit b8d2033

File tree

5 files changed

+59
-53
lines changed

5 files changed

+59
-53
lines changed

_internal/_template/README.md

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Title
22

33
<details>
4-
<summary>How to run this example</summary>
4+
<summary>How to run this example</summary>
5+
<br/>
56

67
```bash
78
# Set your API key as an environment variable.
@@ -12,10 +13,16 @@ cd typescript # Navigate to the typescript example
1213
npm install # Install dependencies
1314
ts-node example.ts # Run the example
1415

15-
# Run the Python example
16-
# Note: First install dependencies in the root examples directory.
16+
# If using Poetry:
1717
cd python # Navigate to the python example
18-
poetry run python example.py # Run the example
18+
poetry install # Install dependencies and build the example
19+
poetry run main # Run the example
20+
21+
# If using Rye:
22+
# Update pyproject.toml to switch to Rye.
23+
cd python # Navigate to the python example
24+
rye sync # Install dependencies and build the example
25+
rye run main # Run the example
1926
```
2027

2128
</details>
@@ -24,13 +31,13 @@ We follow this procedure to create consistent, high volume content.
2431

2532
1. Come up with a short readable slug, e.g. `generate-json` and a title.
2633
2. Create a folder in the [examples repo](https://github.com/SubstrateLabs/examples), copying this folder
27-
3. Write the code in TS or Python, and keep it simple. Ideally it’s just a script with no additional dependencies.
28-
1. Consider creating illustrative variations of the script (e.g. `ComputeText` and `MultiComputeText` - [example](https://github.com/SubstrateLabs/examples/tree/main/basics/generate-text))
29-
2. Translate your script to the other language. (TODO: automated translation with Substrate)
30-
3. Make sure both examples run and produce simple polished output.
31-
4. Simplify the code
32-
1. Wrap lines (multi-line node declarations are easier to read)
33-
2. Consider inlining variables
34+
3. Write the code in TS or Python, and keep it simple. Ideally it’s just a script with no additional dependencies.
35+
1. Consider creating illustrative variations of the script (e.g. `ComputeText` and `MultiComputeText` - [example](https://github.com/SubstrateLabs/examples/tree/main/basics/generate-text))
36+
2. Translate your script to the other language. (TODO: automated translation with Substrate)
37+
3. Make sure both examples run and produce simple polished output.
38+
4. Simplify the code
39+
1. Wrap lines (multi-line node declarations are easier to read)
40+
2. Consider inlining variables
3441
4. Fill out this README with walkthrough text and generate new image assets.
3542

3643
![hero](hero.png)
@@ -82,7 +89,6 @@ If your example is a graph, create a diagram.
8289

8390
![diagram](diagram.svg)
8491

85-
8692
To edit the diagram, run:
8793

8894
```bash

_internal/_template/python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ export SUBSTRATE_API_KEY=<your Substrate API key>
1111
cd python
1212
```
1313

14-
To run the example with Poetry, uncomment the Poetry sections in `pyproject.toml` and run the following.
14+
To run the example with Poetry (default), run the following.
1515

1616
```bash
1717
poetry install
1818
poetry run main
1919
```
2020

21-
To run the example with Rye, uncomment the Rye sections in `pyproject.toml` and run the following.
21+
To run the example with Rye, comment out the Poetry sections and uncomment the Rye sections in `pyproject.toml` and run the following.
2222

2323
```bash
2424
rye sync

_internal/_template/python/pyproject.toml

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,29 +24,29 @@ venv = ".venv"
2424
# Uncomment for Poetry support
2525
##############################
2626

27-
# [build-system]
28-
# requires = ["poetry-core"]
29-
# build-backend = "poetry.core.masonry.api"
27+
[build-system]
28+
requires = ["poetry-core"]
29+
build-backend = "poetry.core.masonry.api"
3030

31-
# [tool.poetry]
32-
# name = "template"
33-
# version = "0.1.0"
34-
# description = ""
35-
# authors = ["Hanwen Wu <[email protected]>"]
36-
# readme = "README.md"
31+
[tool.poetry]
32+
name = "template"
33+
version = "0.1.0"
34+
description = ""
35+
authors = ["Hanwen Wu <[email protected]>"]
36+
readme = "README.md"
3737

38-
# packages = [{ include = "python", from = "src" }]
38+
packages = [{ include = "python", from = "src" }]
3939

40-
# [tool.poetry.dependencies]
41-
# python = "^3.9"
42-
# substrate = "220240617.*"
40+
[tool.poetry.dependencies]
41+
python = "^3.9"
42+
substrate = "220240617.*"
4343

44-
# [tool.poetry.group.dev.dependencies]
45-
# ruff = "^0.6.1"
46-
# marimo = "^0.8.0"
44+
[tool.poetry.group.dev.dependencies]
45+
ruff = "^0.6.1"
46+
marimo = "^0.8.0"
4747

48-
# [tool.poetry.scripts]
49-
# main = "python.example:main"
48+
[tool.poetry.scripts]
49+
main = "python.example:main"
5050

5151

5252
###########################

basics/generate-text/python/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ export SUBSTRATE_API_KEY=<your Substrate API key>
1111
cd python
1212
```
1313

14-
To run the example with Poetry, uncomment the Poetry sections in `pyproject.toml` and run the following.
14+
To run the example with Poetry (default),
1515

1616
```bash
1717
poetry install
1818
poetry run example
1919
poetry run example-multi
2020
```
2121

22-
To run the example with Rye, uncomment the Rye sections in `pyproject.toml` and run the following.
22+
To run the example with Rye, comment out the Poetry sections and uncomment the Rye sections in `pyproject.toml` and run the following.
2323

2424
```bash
2525
rye sync

basics/generate-text/python/pyproject.toml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,30 @@ venv = ".venv"
2525
# Uncomment for Poetry support
2626
##############################
2727

28-
# [build-system]
29-
# requires = ["poetry-core"]
30-
# build-backend = "poetry.core.masonry.api"
28+
[build-system]
29+
requires = ["poetry-core"]
30+
build-backend = "poetry.core.masonry.api"
3131

32-
# [tool.poetry]
33-
# name = "example-generate-text"
34-
# version = "0.1.0"
35-
# description = ""
36-
# authors = ["Ben Guo <[email protected]>"]
37-
# readme = "README.md"
32+
[tool.poetry]
33+
name = "example-generate-text"
34+
version = "0.1.0"
35+
description = ""
36+
authors = ["Ben Guo <[email protected]>"]
37+
readme = "README.md"
3838

39-
# packages = [{ include = "generatetext", from = "src" }]
39+
packages = [{ include = "generatetext", from = "src" }]
4040

41-
# [tool.poetry.dependencies]
42-
# python = "^3.9"
43-
# substrate = "220240617.*"
41+
[tool.poetry.dependencies]
42+
python = "^3.9"
43+
substrate = "220240617.*"
4444

45-
# [tool.poetry.group.dev.dependencies]
46-
# ruff = "^0.6.1"
47-
# marimo = "^0.8.0"
45+
[tool.poetry.group.dev.dependencies]
46+
ruff = "^0.6.1"
47+
marimo = "^0.8.0"
4848

49-
# [tool.poetry.scripts]
50-
# example = "generatetext.example:main"
51-
# example-multi = "generatetext.example_multi:main"
49+
[tool.poetry.scripts]
50+
example = "generatetext.example:main"
51+
example-multi = "generatetext.example_multi:main"
5252

5353
###########################
5454
# Uncomment for Rye support

0 commit comments

Comments
 (0)