Skip to content

Commit 7127932

Browse files
committed
update the python toolchain to support both Rye and Poetry
1 parent d737c5c commit 7127932

File tree

7 files changed

+106
-4
lines changed

7 files changed

+106
-4
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# python generated files
2+
__pycache__/
3+
*.py[oc]
4+
build/
5+
dist/
6+
wheels/
7+
*.egg-info
8+
9+
# venv
10+
.venv
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Substrate Example Templates in Python
2+
3+
This is a Substrate example template written in Python. To run this example,
4+
5+
```bash
6+
# Set your API key as an environment variable.
7+
# Get one here https://www.substrate.run/dashboard/keys if this is your first time.
8+
export SUBSTRATE_API_KEY=<your Substrate API key>
9+
10+
# Navigate to the python example directory.
11+
cd python
12+
```
13+
14+
To run the example with Poetry, uncomment the Poetry sections in `pyproject.toml` and run the following.
15+
16+
```bash
17+
poetry install
18+
poetry run main
19+
```
20+
21+
To run the example with Rye, uncomment the Rye sections in `pyproject.toml` and run the following.
22+
23+
```bash
24+
rye sync
25+
rye run main
26+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[virtualenvs]
2+
in-project = true
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[project]
2+
name = "template"
3+
version = "0.1.0"
4+
description = ""
5+
authors = [{ name = "Hanwen Wu", email = "[email protected]" }]
6+
readme = "README.md"
7+
8+
requires-python = ">= 3.9"
9+
dependencies = ["substrate"]
10+
11+
[project.scripts]
12+
main = "python.example:main"
13+
14+
[tool.ruff]
15+
line-length = 120
16+
output-format = "grouped"
17+
target-version = "py310"
18+
19+
[tool.pyright]
20+
venvPath = "."
21+
venv = ".venv"
22+
23+
##############################
24+
# Uncomment for Poetry support
25+
##############################
26+
27+
# [build-system]
28+
# requires = ["poetry-core"]
29+
# build-backend = "poetry.core.masonry.api"
30+
31+
# [tool.poetry]
32+
# name = "template"
33+
# version = "0.1.0"
34+
# description = ""
35+
# authors = ["Hanwen Wu <[email protected]>"]
36+
# readme = "README.md"
37+
38+
# packages = [{ include = "python", from = "src" }]
39+
40+
# [tool.poetry.dependencies]
41+
# python = "^3.9"
42+
# substrate = "220240617.*"
43+
44+
# [tool.poetry.group.dev.dependencies]
45+
# ruff = "^0.6.1"
46+
# marimo = "^0.8.0"
47+
48+
# [tool.poetry.scripts]
49+
# main = "python.example:main"
50+
51+
52+
###########################
53+
# Uncomment for Rye support
54+
###########################
55+
56+
# [build-system]
57+
# requires = ["hatchling"]
58+
# build-backend = "hatchling.build"
59+
60+
# [tool.rye]
61+
# managed = true
62+
# dev-dependencies = ["ruff>=0.6.1", "marimo>=0.8.0"]
63+
64+
# [tool.hatch.metadata]
65+
# allow-direct-references = true
66+
67+
# [tool.hatch.build.targets.wheel]
68+
# packages = ["src/python"]

_internal/_template/python/src/python/__init__.py

Whitespace-only changes.

pyrightconfig.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)