workers-py 1.4.0__py3-none-any.whl → 1.5.1__py3-none-any.whl
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.
- pywrangler/cli.py +21 -3
- pywrangler/sync.py +1 -2
- pywrangler/types.py +45 -0
- pywrangler/utils.py +2 -0
- {workers_py-1.4.0.dist-info → workers_py-1.5.1.dist-info}/METADATA +2 -1
- workers_py-1.5.1.dist-info/RECORD +11 -0
- workers_py-1.4.0.dist-info/RECORD +0 -10
- {workers_py-1.4.0.dist-info → workers_py-1.5.1.dist-info}/WHEEL +0 -0
- {workers_py-1.4.0.dist-info → workers_py-1.5.1.dist-info}/entry_points.txt +0 -0
pywrangler/cli.py
CHANGED
|
@@ -4,13 +4,11 @@ import sys
|
|
|
4
4
|
import textwrap
|
|
5
5
|
import click
|
|
6
6
|
|
|
7
|
-
from
|
|
7
|
+
from .utils import setup_logging, write_success, WRANGLER_COMMAND
|
|
8
8
|
|
|
9
9
|
setup_logging()
|
|
10
10
|
logger = logging.getLogger("pywrangler")
|
|
11
11
|
|
|
12
|
-
WRANGLER_COMMAND = ["npx", "--yes", "wrangler"]
|
|
13
|
-
|
|
14
12
|
|
|
15
13
|
class ProxyToWranglerGroup(click.Group):
|
|
16
14
|
def get_help(self, ctx):
|
|
@@ -95,6 +93,26 @@ def app(ctx, debug=False):
|
|
|
95
93
|
logger.setLevel(logging.DEBUG)
|
|
96
94
|
|
|
97
95
|
|
|
96
|
+
@app.command("types")
|
|
97
|
+
@click.option(
|
|
98
|
+
"-o",
|
|
99
|
+
"--outdir",
|
|
100
|
+
type=click.Path(writable=True),
|
|
101
|
+
help="The output directory to write the generated types. Default: ./src",
|
|
102
|
+
)
|
|
103
|
+
@click.option(
|
|
104
|
+
"-c",
|
|
105
|
+
"--config",
|
|
106
|
+
type=click.Path(exists=True, dir_okay=False, readable=True),
|
|
107
|
+
help="Path to Wrangler configuration file",
|
|
108
|
+
)
|
|
109
|
+
def types_command(outdir=None, config=None):
|
|
110
|
+
from .types import wrangler_types
|
|
111
|
+
|
|
112
|
+
wrangler_types(outdir, config)
|
|
113
|
+
raise click.exceptions.Exit(code=0)
|
|
114
|
+
|
|
115
|
+
|
|
98
116
|
@app.command("sync")
|
|
99
117
|
@click.option("--force", is_flag=True, help="Force sync even if no changes detected")
|
|
100
118
|
def sync_command(force=False, directly_requested=True):
|
pywrangler/sync.py
CHANGED
|
@@ -377,10 +377,9 @@ def _install_requirements_to_vendor(requirements: list[str]):
|
|
|
377
377
|
|
|
378
378
|
|
|
379
379
|
def _install_requirements_to_venv(requirements: list[str]):
|
|
380
|
-
# Create a requirements file for .venv-workers that includes
|
|
380
|
+
# Create a requirements file for .venv-workers that includes pyodide-py
|
|
381
381
|
relative_venv_workers_path = VENV_WORKERS_PATH.relative_to(PROJECT_ROOT)
|
|
382
382
|
requirements = requirements.copy()
|
|
383
|
-
requirements.append("webtypy")
|
|
384
383
|
requirements.append("pyodide-py")
|
|
385
384
|
|
|
386
385
|
logger.info(
|
pywrangler/types.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from .utils import WRANGLER_COMMAND, run_command
|
|
2
|
+
from tempfile import TemporaryDirectory
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
import logging
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
TSCONFIG = """
|
|
9
|
+
{
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"target": "esnext",
|
|
12
|
+
"module": "esnext",
|
|
13
|
+
"moduleResolution": "nodenext",
|
|
14
|
+
"lib": ["esnext"]
|
|
15
|
+
},
|
|
16
|
+
"include": ["worker-configuration.d.ts"]
|
|
17
|
+
}
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
PACKAGE_JSON = """
|
|
21
|
+
{
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"typescript": "^5.3.2"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def wrangler_types(outdir_arg: str | None, config: str | None, /):
|
|
30
|
+
args = ["types"]
|
|
31
|
+
if config:
|
|
32
|
+
args += ["--config", config]
|
|
33
|
+
if outdir_arg is None:
|
|
34
|
+
outdir = Path("src")
|
|
35
|
+
else:
|
|
36
|
+
outdir = Path(outdir_arg)
|
|
37
|
+
stubs_dir = outdir / "js-stubs"
|
|
38
|
+
stubs_dir.mkdir(parents=True, exist_ok=True)
|
|
39
|
+
with TemporaryDirectory() as tmp_str:
|
|
40
|
+
tmp = Path(tmp_str)
|
|
41
|
+
run_command(WRANGLER_COMMAND + args + [tmp / "worker-configuration.d.ts"])
|
|
42
|
+
(tmp / "tsconfig.json").write_text(TSCONFIG)
|
|
43
|
+
(tmp / "package.json").write_text(PACKAGE_JSON)
|
|
44
|
+
run_command(["npm", "-C", tmp, "install"])
|
|
45
|
+
run_command(["npx", "@pyodide/ts-to-python", tmp, stubs_dir / "__init__.pyi"])
|
pywrangler/utils.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workers-py
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.1
|
|
4
4
|
Summary: A set of libraries and tools for Python Workers
|
|
5
5
|
Project-URL: Homepage, https://github.com/cloudflare/workers-py
|
|
6
6
|
Project-URL: Bug Tracker, https://github.com/cloudflare/workers-py/issues
|
|
@@ -11,6 +11,7 @@ Requires-Python: >=3.10
|
|
|
11
11
|
Requires-Dist: click<9.0.0,>=8.0.0
|
|
12
12
|
Requires-Dist: pyjson5>=1.6.0
|
|
13
13
|
Requires-Dist: pyodide-cli
|
|
14
|
+
Requires-Dist: pyodide-py
|
|
14
15
|
Requires-Dist: rich>=13.0.0
|
|
15
16
|
Provides-Extra: build
|
|
16
17
|
Requires-Dist: uv~=0.5.23; extra == 'build'
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
pywrangler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
pywrangler/__main__.py,sha256=BnrUM7YiBmlM4HAn2MI9hP1kVNtzeK_kEgQhRy5HTq0,38
|
|
3
|
+
pywrangler/cli.py,sha256=Srvc5mi710HVCjJWjA-o10QEVl2YNfTfd35IQ4esZ0A,5690
|
|
4
|
+
pywrangler/metadata.py,sha256=vttmaCtouSr9ADj8ncvNGqeaWEGFP8pamH2T6ohFjnA,408
|
|
5
|
+
pywrangler/sync.py,sha256=CAJdZRZb_xGBX0c4pskfJFrKt8cq6wBpDtPbrWnVJeQ,14248
|
|
6
|
+
pywrangler/types.py,sha256=RyOTVFFC75vJ0NxGzXWJGouRpQ5k4gsf3Jsiq-i_ans,1174
|
|
7
|
+
pywrangler/utils.py,sha256=Vtg0qenIWArGXPhI2jL_4c8tUQByUqQKUVzGbCeoqrw,3318
|
|
8
|
+
workers_py-1.5.1.dist-info/METADATA,sha256=4BGL7NsUnHjJOreZ-A6v52ECquRrZYz1VD2_VopODKo,1854
|
|
9
|
+
workers_py-1.5.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
10
|
+
workers_py-1.5.1.dist-info/entry_points.txt,sha256=pt6X-Nv5-gSiKUwrnvLwzlSXs9yP37m7zdTAi8f6nAM,50
|
|
11
|
+
workers_py-1.5.1.dist-info/RECORD,,
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
pywrangler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
pywrangler/__main__.py,sha256=BnrUM7YiBmlM4HAn2MI9hP1kVNtzeK_kEgQhRy5HTq0,38
|
|
3
|
-
pywrangler/cli.py,sha256=DX0fX6akSkO34zn41zTqCJJeuFRjFjEzwKNIJFZRomk,5235
|
|
4
|
-
pywrangler/metadata.py,sha256=vttmaCtouSr9ADj8ncvNGqeaWEGFP8pamH2T6ohFjnA,408
|
|
5
|
-
pywrangler/sync.py,sha256=_4pwiStnLZ5vD9pZx7aJ3XayMWa5COR5oJt1tOa8VrU,14295
|
|
6
|
-
pywrangler/utils.py,sha256=wfkT7GbKtgtjHXtV3AjNeb25ohdAfrprdZIlqqidiQU,3269
|
|
7
|
-
workers_py-1.4.0.dist-info/METADATA,sha256=IBJmUfLc1uzsRjVmyzWBGP-WygBcE6us5ZZe0HnmtGk,1828
|
|
8
|
-
workers_py-1.4.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
9
|
-
workers_py-1.4.0.dist-info/entry_points.txt,sha256=pt6X-Nv5-gSiKUwrnvLwzlSXs9yP37m7zdTAi8f6nAM,50
|
|
10
|
-
workers_py-1.4.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|