pywa-cloud-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Lev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,83 @@
1
+ Metadata-Version: 2.4
2
+ Name: pywa-cloud-cli
3
+ Version: 0.1.0
4
+ Summary: CLI for Pywa Cloud - deploy and manage pywa WhatsApp bots
5
+ Keywords: whatsapp,whatsapp-cloud-api,pywa,cli,deployment,hosting,whatsapp-bot,chatbot-framework
6
+ Author: David Lev
7
+ Author-email: David Lev <david@davidlev.dev>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Environment :: Console
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Topic :: Communications :: Chat
22
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
23
+ Classifier: Topic :: Software Development :: Build Tools
24
+ Classifier: Topic :: System :: Software Distribution
25
+ Requires-Dist: httpx>=0.27,<1.0
26
+ Requires-Dist: certifi>=2026.10.19
27
+ Requires-Dist: pathspec>=0.12
28
+ Requires-Dist: websockets>=15.0
29
+ Maintainer: David Lev
30
+ Maintainer-email: David Lev <david@davidlev.dev>
31
+ Requires-Python: >=3.10
32
+ Project-URL: Homepage, https://pywa.cloud
33
+ Project-URL: Documentation, https://docs.pywa.cloud
34
+ Description-Content-Type: text/markdown
35
+
36
+ # pywa-cloud-cli
37
+
38
+ Command line for [Pywa Cloud](https://pywa.cloud): deploy and manage WhatsApp bots built with
39
+ [pywa](https://github.com/david-lev/pywa).
40
+
41
+ ```bash
42
+ pip install pywa-cloud-cli
43
+ ```
44
+
45
+ ## Quick start
46
+
47
+ ```bash
48
+ pywa-cloud login # opens your browser to confirm
49
+ cd my-bot
50
+ pywa-cloud deploy # picks or creates a bot, builds, starts it
51
+ pywa-cloud logs --follow
52
+ ```
53
+
54
+ Your project needs `pywa[server]` in `pyproject.toml` or `requirements.txt`. The first deploy links the folder to a
55
+ bot (`.pywacloud/link.json`, git-ignored), so later deploys need no arguments.
56
+
57
+ ## Commands
58
+
59
+ | | |
60
+ |---|---|
61
+ | `login`, `logout`, `whoami` | Sign in, sign out, show the current account (`login --token` for CI) |
62
+ | `bots create/list/get` | Manage bots; `set-entrypoint` and `set-directory` for non-default layouts |
63
+ | `deploy [path]` | Package the folder, upload it, build and start the bot |
64
+ | `status`, `logs`, `stop`, `start`, `restart` | Run and inspect a deployed bot |
65
+ | `env set/get/list/delete` | Environment variables and secrets (`env set KEY --secret`) |
66
+ | `deployments list/get/log/rollback` | Deployment history and rollback |
67
+ | `connect`, `connect-status` | Connect a WhatsApp Business number |
68
+ | `tunnel [--port 8000]` | Send a bot's webhooks to a process on your machine while you develop |
69
+ | `deploy-tokens`, `setup-ci` | Deploy from GitHub Actions |
70
+ | `link`, `unlink` | Tie a folder to a bot |
71
+
72
+ Run `pywa-cloud <command> --help` for options. The full reference is at <https://docs.pywa.cloud>.
73
+
74
+ Files listed in `.gitignore` or `.pywacloudignore` are left out of the upload. If pywa is installed too, the same
75
+ commands are available as `pywa cloud <command>`.
76
+
77
+ ## Requirements
78
+
79
+ Python 3.10 or newer. Set `NO_COLOR=1` to turn colours off.
80
+
81
+ ## License
82
+
83
+ MIT
@@ -0,0 +1,48 @@
1
+ # pywa-cloud-cli
2
+
3
+ Command line for [Pywa Cloud](https://pywa.cloud): deploy and manage WhatsApp bots built with
4
+ [pywa](https://github.com/david-lev/pywa).
5
+
6
+ ```bash
7
+ pip install pywa-cloud-cli
8
+ ```
9
+
10
+ ## Quick start
11
+
12
+ ```bash
13
+ pywa-cloud login # opens your browser to confirm
14
+ cd my-bot
15
+ pywa-cloud deploy # picks or creates a bot, builds, starts it
16
+ pywa-cloud logs --follow
17
+ ```
18
+
19
+ Your project needs `pywa[server]` in `pyproject.toml` or `requirements.txt`. The first deploy links the folder to a
20
+ bot (`.pywacloud/link.json`, git-ignored), so later deploys need no arguments.
21
+
22
+ ## Commands
23
+
24
+ | | |
25
+ |---|---|
26
+ | `login`, `logout`, `whoami` | Sign in, sign out, show the current account (`login --token` for CI) |
27
+ | `bots create/list/get` | Manage bots; `set-entrypoint` and `set-directory` for non-default layouts |
28
+ | `deploy [path]` | Package the folder, upload it, build and start the bot |
29
+ | `status`, `logs`, `stop`, `start`, `restart` | Run and inspect a deployed bot |
30
+ | `env set/get/list/delete` | Environment variables and secrets (`env set KEY --secret`) |
31
+ | `deployments list/get/log/rollback` | Deployment history and rollback |
32
+ | `connect`, `connect-status` | Connect a WhatsApp Business number |
33
+ | `tunnel [--port 8000]` | Send a bot's webhooks to a process on your machine while you develop |
34
+ | `deploy-tokens`, `setup-ci` | Deploy from GitHub Actions |
35
+ | `link`, `unlink` | Tie a folder to a bot |
36
+
37
+ Run `pywa-cloud <command> --help` for options. The full reference is at <https://docs.pywa.cloud>.
38
+
39
+ Files listed in `.gitignore` or `.pywacloudignore` are left out of the upload. If pywa is installed too, the same
40
+ commands are available as `pywa cloud <command>`.
41
+
42
+ ## Requirements
43
+
44
+ Python 3.10 or newer. Set `NO_COLOR=1` to turn colours off.
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,105 @@
1
+ [project]
2
+ name = "pywa-cloud-cli"
3
+ version = "0.1.0"
4
+ description = "CLI for Pywa Cloud - deploy and manage pywa WhatsApp bots"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ keywords = [
10
+ "whatsapp",
11
+ "whatsapp-cloud-api",
12
+ "pywa",
13
+ "cli",
14
+ "deployment",
15
+ "hosting",
16
+ "whatsapp-bot",
17
+ "chatbot-framework",
18
+ ]
19
+ classifiers = [
20
+ "Development Status :: 3 - Alpha",
21
+ "Intended Audience :: Developers",
22
+ "Operating System :: OS Independent",
23
+ "Environment :: Console",
24
+ "Programming Language :: Python :: 3",
25
+ "Programming Language :: Python :: 3 :: Only",
26
+ "Programming Language :: Python :: 3.10",
27
+ "Programming Language :: Python :: 3.11",
28
+ "Programming Language :: Python :: 3.12",
29
+ "Programming Language :: Python :: 3.13",
30
+ "Programming Language :: Python :: 3.14",
31
+ "Topic :: Communications :: Chat",
32
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
33
+ "Topic :: Software Development :: Build Tools",
34
+ "Topic :: System :: Software Distribution",
35
+ ]
36
+ dependencies = [
37
+ "httpx>=0.27,<1.0",
38
+ "certifi>=2026.10.19",
39
+ "pathspec>=0.12",
40
+ "websockets>=15.0",
41
+ ]
42
+
43
+ [[project.authors]]
44
+ name = "David Lev"
45
+ email = "david@davidlev.dev"
46
+
47
+ [[project.maintainers]]
48
+ name = "David Lev"
49
+ email = "david@davidlev.dev"
50
+
51
+ [project.scripts]
52
+ pywa-cloud = "pywa_cloud_cli:main"
53
+
54
+ [project.urls]
55
+ Homepage = "https://pywa.cloud"
56
+ Documentation = "https://docs.pywa.cloud"
57
+
58
+ [dependency-groups]
59
+ dev = [
60
+ "pytest>=8.3",
61
+ "pytest-cov~=7.0",
62
+ "ruff~=0.16",
63
+ "ty>=0.0.65",
64
+ "pre-commit~=4.5",
65
+ ]
66
+
67
+ [build-system]
68
+ requires = ["uv_build>=0.12.3,<0.13.0"]
69
+ build-backend = "uv_build"
70
+
71
+ [tool.uv.build-backend]
72
+ module-name = ["pywa_cloud_cli"]
73
+
74
+ [tool.ruff.format]
75
+ docstring-code-format = true
76
+
77
+ [tool.ruff.lint]
78
+ ignore = ["PYI034"]
79
+ extend-select = [
80
+ "T20",
81
+ "E711",
82
+ "E712",
83
+ "E741",
84
+ ]
85
+
86
+ [tool.ruff.lint.per-file-ignores]
87
+ "src/pywa_cloud_cli/cli.py" = ["T20"]
88
+ "tests/smoke_test.py" = ["T20"]
89
+ "tests/test_*.py" = ["BLE001"]
90
+
91
+ [tool.ty.src]
92
+ include = ["src/pywa_cloud_cli"]
93
+
94
+ [tool.coverage.run]
95
+ include = ["src/pywa_cloud_cli/*"]
96
+
97
+ [tool.coverage.report]
98
+ show_missing = true
99
+ exclude_lines = [
100
+ "pragma: no cover",
101
+ "if TYPE_CHECKING:",
102
+ "raise NotImplementedError",
103
+ "def __repr__",
104
+ '\.\.\.',
105
+ ]
@@ -0,0 +1,106 @@
1
+ [project]
2
+ name = "pywa-cloud-cli"
3
+ version = "0.1.0"
4
+ description = "CLI for Pywa Cloud - deploy and manage pywa WhatsApp bots"
5
+ readme = "README.md"
6
+ license = "MIT"
7
+ license-files = ["LICENSE"]
8
+ requires-python = ">=3.10"
9
+ authors = [
10
+ { name = "David Lev", email = "david@davidlev.dev" }
11
+ ]
12
+ maintainers = [
13
+ { name = "David Lev", email = "david@davidlev.dev" }
14
+ ]
15
+ keywords = [
16
+ "whatsapp",
17
+ "whatsapp-cloud-api",
18
+ "pywa",
19
+ "cli",
20
+ "deployment",
21
+ "hosting",
22
+ "whatsapp-bot",
23
+ "chatbot-framework",
24
+ ]
25
+ classifiers = [
26
+ "Development Status :: 3 - Alpha",
27
+ "Intended Audience :: Developers",
28
+ "Operating System :: OS Independent",
29
+ "Environment :: Console",
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3 :: Only",
32
+ "Programming Language :: Python :: 3.10",
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Programming Language :: Python :: 3.14",
37
+ "Topic :: Communications :: Chat",
38
+ "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
39
+ "Topic :: Software Development :: Build Tools",
40
+ "Topic :: System :: Software Distribution",
41
+ ]
42
+ dependencies = [
43
+ "httpx>=0.27,<1.0",
44
+ # Floor after the eMudhra CA compromise (Oct 2026): older bundles still trust the compromised intermediates.
45
+ "certifi>=2026.10.19",
46
+ "pathspec>=0.12",
47
+ "websockets>=15.0",
48
+ ]
49
+
50
+ [project.scripts]
51
+ pywa-cloud = "pywa_cloud_cli:main"
52
+
53
+ [project.urls]
54
+ "Homepage" = "https://pywa.cloud"
55
+ "Documentation" = "https://docs.pywa.cloud"
56
+
57
+ [dependency-groups]
58
+ dev = [
59
+ "pytest>=8.3",
60
+ "pytest-cov~=7.0",
61
+ "ruff~=0.16",
62
+ "ty>=0.0.65",
63
+ "pre-commit~=4.5",
64
+ ]
65
+
66
+ [build-system]
67
+ requires = ["uv_build>=0.12.3,<0.13.0"]
68
+ build-backend = "uv_build"
69
+
70
+ [tool.uv.build-backend]
71
+ module-name = ["pywa_cloud_cli"]
72
+
73
+ [tool.ruff.format]
74
+ docstring-code-format = true
75
+
76
+ [tool.ruff.lint]
77
+ ignore = [
78
+ "PYI034", # `Self` needs Python 3.11+; this package supports 3.10+ without `typing_extensions`
79
+ ]
80
+ extend-select = [
81
+ "T20", # flake8-print: forbid stray `print()`/`pprint()` calls in library code (use `logging` instead)
82
+ "E711", # forbid `== None` / `!= None`; use `is None` / `is not None` instead
83
+ "E712", # forbid `== True` / `== False`; use `is`/`is not` or plain truthiness instead
84
+ "E741", # forbid ambiguous single-character names (`l`, `O`, `I`)
85
+ ]
86
+
87
+ [tool.ruff.lint.per-file-ignores]
88
+ "src/pywa_cloud_cli/cli.py" = ["T20"] # the CLI's whole job is printing to the user
89
+ "tests/smoke_test.py" = ["T20"] # prints a pass/fail line when run standalone, not via pytest
90
+ "tests/test_*.py" = ["BLE001"] # tests intentionally probe optional tools (e.g. Docker) broadly
91
+
92
+ [tool.ty.src]
93
+ include = ["src/pywa_cloud_cli"]
94
+
95
+ [tool.coverage.run]
96
+ include = ["src/pywa_cloud_cli/*"]
97
+
98
+ [tool.coverage.report]
99
+ show_missing = true
100
+ exclude_lines = [
101
+ "pragma: no cover",
102
+ "if TYPE_CHECKING:",
103
+ "raise NotImplementedError",
104
+ "def __repr__",
105
+ "\\.\\.\\.",
106
+ ]
@@ -0,0 +1,13 @@
1
+ __version__ = "0.1.0"
2
+
3
+ # Re-exported so pywa's own CLI (`pywa/cli.py`) only needs `import pywa_cloud_cli` - it never
4
+ # imports `pywa_cloud_cli.cli` directly, since that submodule is an implementation detail.
5
+ from pywa_cloud_cli.cli import (
6
+ dispatch,
7
+ main,
8
+ register,
9
+ register_shallow,
10
+ start_dev_tunnel,
11
+ )
12
+
13
+ __all__ = ["dispatch", "main", "register", "register_shallow", "start_dev_tunnel"]
@@ -0,0 +1,115 @@
1
+ """Packs a project directory into an in-memory tar.gz for `deploy`.
2
+
3
+ Two layers decide what goes in:
4
+
5
+ 1. `HARD_EXCLUDES` always applies (`.git`, virtual environments, secret-looking dotfiles). `.pywacloudignore`
6
+ cannot un-ignore these.
7
+ 2. `.gitignore` and `.pywacloudignore` are combined into one pattern set (via `pathspec`). The latter is appended
8
+ last, so under gitignore's last-match-wins rule it takes precedence.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import io
14
+ import os
15
+ import pathlib
16
+ import re
17
+ import tarfile
18
+
19
+ import pathspec
20
+
21
+ HARD_EXCLUDES = {
22
+ ".venv",
23
+ "venv",
24
+ ".git",
25
+ "__pycache__",
26
+ ".pywacloud",
27
+ # Tool caches, editor state and JS dependencies: never part of a Python bot, and `node_modules` alone can
28
+ # push an upload past the size limit.
29
+ "node_modules",
30
+ ".mypy_cache",
31
+ ".pytest_cache",
32
+ ".ruff_cache",
33
+ ".tox",
34
+ ".idea",
35
+ ".DS_Store",
36
+ }
37
+
38
+ # The server refuses a larger upload; checking here saves sending it first.
39
+ MAX_ARCHIVE_BYTES = 50 * 1024 * 1024
40
+
41
+
42
+ def _hard_excluded(rel_parts: tuple[str, ...]) -> bool:
43
+ if any(part in HARD_EXCLUDES for part in rel_parts):
44
+ return True
45
+ name = rel_parts[-1]
46
+ if name.startswith(".env"):
47
+ return True
48
+ return bool(name.endswith(".pyc"))
49
+
50
+
51
+ def _walk_files(project_dir: pathlib.Path):
52
+ """Every file under `project_dir`, in a stable order, without descending into the always-excluded directories:
53
+ a `.venv`, `node_modules` or `.git` can hold tens of thousands of files that would only be filtered out one by one."""
54
+ for root, dirnames, filenames in os.walk(project_dir):
55
+ dirnames[:] = sorted(d for d in dirnames if d not in HARD_EXCLUDES)
56
+ for name in sorted(filenames):
57
+ yield pathlib.Path(root) / name
58
+
59
+
60
+ def _load_ignore_spec(project_dir: pathlib.Path) -> pathspec.PathSpec | None:
61
+ patterns: list[str] = []
62
+ for ignore_file in (".gitignore", ".pywacloudignore"):
63
+ path = project_dir / ignore_file
64
+ if path.is_file():
65
+ patterns += path.read_text().splitlines()
66
+ if not patterns:
67
+ return None
68
+ return pathspec.PathSpec.from_lines("gitignore", patterns)
69
+
70
+
71
+ def build_archive(project_dir: pathlib.Path) -> bytes:
72
+ spec = _load_ignore_spec(project_dir)
73
+ buf = io.BytesIO()
74
+ # dereference: a symlinked file is uploaded as the file it points to. As a link it either pointed outside the
75
+ # project (the server refuses such an archive) or to a file that was excluded, and the bot started without it.
76
+ with tarfile.open(fileobj=buf, mode="w:gz", dereference=True) as tar:
77
+ for path in _walk_files(project_dir):
78
+ if not path.is_file():
79
+ continue # e.g. a broken symlink
80
+ rel = path.relative_to(project_dir)
81
+ if _hard_excluded(rel.parts):
82
+ continue
83
+ if spec is not None and spec.match_file(str(rel)):
84
+ continue
85
+ tar.add(path, arcname=str(rel))
86
+ return buf.getvalue()
87
+
88
+
89
+ _SECRET_NAMES = re.compile(
90
+ r"(\.(pem|key|p12|pfx|jks|keystore)|^id_(rsa|dsa|ecdsa|ed25519)(\.pub)?|^\.netrc|^\.htpasswd|^credentials\.json"
91
+ r"|^service[-_]?account.*\.json|^client_secret.*\.json)\Z",
92
+ re.IGNORECASE,
93
+ )
94
+
95
+
96
+ def secret_like(archive_bytes: bytes) -> list[str]:
97
+ """Paths in a built archive whose names look like keys or credentials. Not removed (a bot may really need a
98
+ certificate, and silently dropping a file would start it broken); the deploy summary names them so they are chosen."""
99
+ with tarfile.open(fileobj=io.BytesIO(archive_bytes), mode="r:gz") as tar:
100
+ return sorted(
101
+ m.name
102
+ for m in tar.getmembers()
103
+ if m.isfile() and _SECRET_NAMES.search(pathlib.PurePosixPath(m.name).name)
104
+ )
105
+
106
+
107
+ def describe(
108
+ archive_bytes: bytes, largest: int = 5
109
+ ) -> tuple[int, list[tuple[str, int]]]:
110
+ """(number of files, the `largest` files as (path, bytes)) of a built archive: what the deploy summary
111
+ prints, and what tells the user what to put in `.pywacloudignore` when the upload is too big."""
112
+ with tarfile.open(fileobj=io.BytesIO(archive_bytes), mode="r:gz") as tar:
113
+ members = [m for m in tar.getmembers() if m.isfile()]
114
+ members.sort(key=lambda m: m.size, reverse=True)
115
+ return len(members), [(m.name, m.size) for m in members[:largest]]