Skip to content

Commit 0326819

Browse files
committed
Add async optional dependency extra
1 parent e8222b5 commit 0326819

6 files changed

Lines changed: 18 additions & 13 deletions

File tree

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,19 @@ Most of the app's functionality will be inside listener functions (the `fn` para
150150

151151
## Creating an async app
152152

153-
If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can import the [AIOHTTP](https://docs.aiohttp.org/en/stable/) library and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.
153+
If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can install the async extra to include [AIOHTTP](https://docs.aiohttp.org/en/stable/) and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.
154154

155155
```bash
156-
# Python 3.7+ required
156+
# Python 3.9+ required for the async extra
157157
python -m venv .venv
158158
source .venv/bin/activate
159159

160160
pip install -U pip
161-
# aiohttp is required
162-
pip install slack_bolt aiohttp
161+
pip install "slack_bolt[async]"
163162
```
164163

164+
If you're using Python 3.7 or 3.8, install an `aiohttp` version compatible with your Python runtime separately.
165+
165166
In async apps, all middleware/listeners must be async functions. When calling utility methods (like `ack` and `say`) within these functions, it's required to use the `await` keyword.
166167

167168
```python

docs/english/concepts/async.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Using async (asyncio)
22

3-
To use the async version of Bolt, you can import and initialize an `AsyncApp` instance (rather than `App`). `AsyncApp` relies on [AIOHTTP](https://docs.aiohttp.org) to make API requests, which means you'll need to install `aiohttp` (by adding to `requirements.txt` or running `pip install aiohttp`).
3+
To use the async version of Bolt, you can import and initialize an `AsyncApp` instance (rather than `App`). `AsyncApp` relies on [AIOHTTP](https://docs.aiohttp.org) to make API requests. On Python 3.9 and newer, install the async extra by running `pip install "slack_bolt[async]"`. If you're using Python 3.7 or 3.8, install an `aiohttp` version compatible with your Python runtime separately.
44

55
Sample async projects can be found within the repository's [examples](https://github.com/slackapi/bolt-python/tree/main/examples) folder.
66

77
```python
8-
# Requirement: install aiohttp
8+
# Requirement: pip install "slack_bolt[async]"
99
from slack_bolt.async_app import AsyncApp
1010
app = AsyncApp()
1111

docs/japanese/concepts/async.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Async(asyncio)の使用
22

3-
非同期バージョンの Bolt を使用する場合は、`App` の代わりに `AsyncApp` インスタンスをインポートして初期化します。`AsyncApp` では [AIOHTTP](https://docs.aiohttp.org/) を使って API リクエストを行うため、`aiohttp` をインストールする必要があります(`requirements.txt` に追記するか`pip install aiohttp` を実行します)
3+
非同期バージョンの Bolt を使用する場合は、`App` の代わりに `AsyncApp` インスタンスをインポートして初期化します。`AsyncApp` では [AIOHTTP](https://docs.aiohttp.org/) を使って API リクエストを行います。Python 3.9 以降では`pip install "slack_bolt[async]"` を実行して async extra をインストールしてください。Python 3.7 または 3.8 を使用している場合は、その Python ランタイムと互換性のある `aiohttp` のバージョンを別途インストールしてください
44

55
非同期バージョンのプロジェクトのサンプルは、リポジトリの [`examples` フォルダ](https://github.com/slackapi/bolt-python/tree/main/examples)にあります。
66

77
```python
8-
# aiohttp のインストールが必要です
8+
# 必要条件: pip install "slack_bolt[async]"
99
from slack_bolt.async_app import AsyncApp
1010
app = AsyncApp()
1111

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "slack_bolt"
7-
dynamic = ["version", "readme", "authors"]
7+
dynamic = ["version", "readme", "authors", "optional-dependencies"]
88
description = "The Bolt Framework for Python"
99
license = { text = "MIT" }
1010
classifiers = [
@@ -34,6 +34,7 @@ include = ["slack_bolt*"]
3434
[tool.setuptools.dynamic]
3535
version = { attr = "slack_bolt.version.__version__" }
3636
readme = { file = ["README.md"], content-type = "text/markdown" }
37+
optional-dependencies.async = { file = ["requirements/async.txt"] }
3738

3839
[tool.distutils.bdist_wheel]
3940
universal = true

requirements/async.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# pip install -r requirements/async.txt
2+
aiohttp>=3,<4; python_version >= "3.9"

slack_bolt/async_app.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@
22
33
### Creating an async app
44
5-
If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can import the [AIOHTTP](https://docs.aiohttp.org/en/stable/) library and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.
5+
If you'd prefer to build your app with [asyncio](https://docs.python.org/3/library/asyncio.html), you can install the async extra to include [AIOHTTP](https://docs.aiohttp.org/en/stable/) and call the `AsyncApp` constructor. Within async apps, you can use the async/await pattern.
66
77
```bash
8-
# Python 3.7+ required
8+
# Python 3.9+ required for the async extra
99
python -m venv .venv
1010
source .venv/bin/activate
1111
1212
pip install -U pip
13-
# aiohttp is required
14-
pip install slack_bolt aiohttp
13+
pip install "slack_bolt[async]"
1514
```
1615
16+
If you're using Python 3.7 or 3.8, install an `aiohttp` version compatible with your Python runtime separately.
17+
1718
In async apps, all middleware/listeners must be async functions. When calling utility methods (like `ack` and `say`) within these functions, it's required to use the `await` keyword.
1819
1920
```python

0 commit comments

Comments
 (0)