workers-py 1.1.8__tar.gz → 1.2.1__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.
@@ -2,6 +2,28 @@
2
2
 
3
3
  <!-- version list -->
4
4
 
5
+ ## v1.2.1 (2025-10-07)
6
+
7
+ ### Bug Fixes
8
+
9
+ - Add version check for uv ([#36](https://github.com/cloudflare/workers-py/pull/36),
10
+ [`f9b16ab`](https://github.com/cloudflare/workers-py/commit/f9b16ab2cd08b0c5afe7e10b053f982d3d536633))
11
+
12
+ ### Documentation
13
+
14
+ - Update README.md to use `uv tool`
15
+ ([`14770ae`](https://github.com/cloudflare/workers-py/commit/14770aea1c2bc2dd052c7f162f8fc4192815c550))
16
+
17
+
18
+ ## v1.2.0 (2025-09-26)
19
+
20
+ ### Features
21
+
22
+ - Use uv instead of pyodide-build to manage pyodide install and venv
23
+ ([#30](https://github.com/cloudflare/workers-py/pull/30),
24
+ [`1629919`](https://github.com/cloudflare/workers-py/commit/16299198db73f1e3efb99eb6ef928fc46978acd9))
25
+
26
+
5
27
  ## v1.1.8 (2025-09-25)
6
28
 
7
29
  ### Bug Fixes
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: workers-py
3
- Version: 1.1.8
3
+ Version: 1.2.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
@@ -29,7 +29,7 @@ A CLI tool for managing vendored packages in a Python Workers project.
29
29
  On Linux, you may be able to install the tool globally by running:
30
30
 
31
31
  ```
32
- uv pip install --system workers-py
32
+ uv tool install workers-py
33
33
  ```
34
34
 
35
35
  Alternatively, you can add `workers-py` to your pyproject.toml:
@@ -60,7 +60,7 @@ uv run --project $REPO_ROOT $REPO_ROOT/src/pywrangler --help
60
60
  On Linux, to install it globally, you may also be able to run:
61
61
 
62
62
  ```
63
- uv pip install --system -e .
63
+ uv tool install -e .
64
64
  ```
65
65
 
66
66
  Alternatively, you can add `workers-py` to your pyproject.toml:
@@ -12,7 +12,7 @@ A CLI tool for managing vendored packages in a Python Workers project.
12
12
  On Linux, you may be able to install the tool globally by running:
13
13
 
14
14
  ```
15
- uv pip install --system workers-py
15
+ uv tool install workers-py
16
16
  ```
17
17
 
18
18
  Alternatively, you can add `workers-py` to your pyproject.toml:
@@ -43,7 +43,7 @@ uv run --project $REPO_ROOT $REPO_ROOT/src/pywrangler --help
43
43
  On Linux, to install it globally, you may also be able to run:
44
44
 
45
45
  ```
46
- uv pip install --system -e .
46
+ uv tool install -e .
47
47
  ```
48
48
 
49
49
  Alternatively, you can add `workers-py` to your pyproject.toml:
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "workers-py"
7
- version = "1.1.8"
7
+ version = "1.2.1"
8
8
  description = "A set of libraries and tools for Python Workers"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -106,7 +106,6 @@ def sync_command(force=False, directly_requested=True):
106
106
  create_pyodide_venv,
107
107
  create_workers_venv,
108
108
  parse_requirements,
109
- install_pyodide_build,
110
109
  install_requirements,
111
110
  )
112
111
 
@@ -129,7 +128,6 @@ def sync_command(force=False, directly_requested=True):
129
128
  create_workers_venv()
130
129
 
131
130
  # Set up Pyodide virtual env
132
- install_pyodide_build()
133
131
  create_pyodide_venv()
134
132
 
135
133
  # Generate requirements.txt from pyproject.toml by directly parsing the TOML file then install into vendor folder.
@@ -1,8 +1,10 @@
1
1
  import logging
2
2
  import os
3
3
  import shutil
4
- from pathlib import Path
5
4
  import tempfile
5
+ from contextlib import contextmanager
6
+ from pathlib import Path
7
+ from typing import Literal
6
8
 
7
9
  import click
8
10
 
@@ -58,8 +60,33 @@ def check_wrangler_config():
58
60
  raise click.exceptions.Exit(code=1)
59
61
 
60
62
 
61
- def _get_python_version():
62
- return os.environ.get("_PYWRANGLER_PYTHON_VERSION", "3.12")
63
+ def _get_python_version() -> Literal["3.12", "3.13"]:
64
+ res = os.environ.get("_PYWRANGLER_PYTHON_VERSION", "3.12")
65
+ match res:
66
+ case "3.12" | "3.13":
67
+ return res
68
+ case _:
69
+ raise ValueError(
70
+ f"Unexpected value for Python version '{res}', expected '3.12' or '3.13'"
71
+ )
72
+
73
+
74
+ def _get_uv_pyodide_interp_name():
75
+ match _get_python_version():
76
+ case "3.12":
77
+ v = "3.12.7"
78
+ case "3.13":
79
+ v = "3.13.2"
80
+ return f"cpython-{v}-emscripten-wasm32-musl"
81
+
82
+
83
+ def _get_pyodide_index():
84
+ match _get_python_version():
85
+ case "3.12":
86
+ v = "0.27.7"
87
+ case "3.13":
88
+ v = "0.28.3"
89
+ return "https://index.pyodide.org/" + v
63
90
 
64
91
 
65
92
  def _get_venv_python_version() -> str | None:
@@ -125,65 +152,34 @@ def create_workers_venv():
125
152
  )
126
153
 
127
154
 
128
- def _get_pyodide_cli_path():
129
- venv_bin_path = VENV_WORKERS_PATH / ("Scripts" if os.name == "nt" else "bin")
130
- pyodide_cli_path = venv_bin_path / ("pyodide.exe" if os.name == "nt" else "pyodide")
131
- return pyodide_cli_path
155
+ MIN_UV_VERSION = (0, 8, 10)
132
156
 
133
157
 
134
- def install_pyodide_build():
135
- pyodide_cli_path = _get_pyodide_cli_path()
136
-
137
- if pyodide_cli_path.is_file():
138
- logger.debug(
139
- f"pyodide-build CLI already found at {pyodide_cli_path} (skipping install.)"
140
- )
158
+ def check_uv_version():
159
+ res = run_command(["uv", "--version"], capture_output=True)
160
+ ver_str = res.stdout.split(" ")[1]
161
+ ver = tuple(int(x) for x in ver_str.split("."))
162
+ if ver >= MIN_UV_VERSION:
141
163
  return
142
-
143
- logger.debug(
144
- f"Installing pyodide-build in {VENV_WORKERS_PATH} using 'uv pip install'..."
145
- )
146
- venv_bin_path = pyodide_cli_path.parent
147
-
148
- # Ensure the python executable path is correct for the venv
149
- venv_python_executable = venv_bin_path / (
150
- "python.exe" if os.name == "nt" else "python"
151
- )
152
- if not venv_python_executable.is_file():
153
- logger.error(f"Python executable not found at {venv_python_executable}")
154
- raise click.exceptions.Exit(code=1)
155
-
156
- run_command(["uv", "pip", "install", "-p", str(venv_python_executable), "pip"])
157
-
158
- run_command(
159
- [
160
- "uv",
161
- "pip",
162
- "install",
163
- "-p",
164
- str(venv_python_executable),
165
- "pyodide-build==0.30.7",
166
- ]
167
- )
164
+ min_version_str = ".".join(str(x) for x in MIN_UV_VERSION)
165
+ logger.error(f"uv version at least {min_version_str} required, have {ver_str}.")
166
+ logger.error("Update uv with `uv self update`.")
167
+ raise click.exceptions.Exit(code=1)
168
168
 
169
169
 
170
170
  def create_pyodide_venv():
171
- pyodide_cli_path = _get_pyodide_cli_path()
172
171
  if PYODIDE_VENV_PATH.is_dir():
173
172
  logger.debug(
174
173
  f"Pyodide virtual environment at {PYODIDE_VENV_PATH} already exists."
175
174
  )
176
175
  return
177
176
 
178
- # Workaround to fix caching issue on some machines.
179
- #
180
- # Fix is here: pyodide/pyodide-build#239
181
- logger.debug("Installing xbuildenv...")
182
- run_command([str(pyodide_cli_path), "xbuildenv", "install"])
183
-
177
+ check_uv_version()
184
178
  logger.debug(f"Creating Pyodide virtual environment at {PYODIDE_VENV_PATH}...")
185
179
  PYODIDE_VENV_PATH.parent.mkdir(parents=True, exist_ok=True)
186
- run_command([str(pyodide_cli_path), "venv", str(PYODIDE_VENV_PATH)])
180
+ interp_name = _get_uv_pyodide_interp_name()
181
+ run_command(["uv", "python", "install", interp_name])
182
+ run_command(["uv", "venv", PYODIDE_VENV_PATH, "--python", interp_name])
187
183
 
188
184
 
189
185
  def parse_requirements() -> list[str]:
@@ -202,6 +198,15 @@ def parse_requirements() -> list[str]:
202
198
  raise click.exceptions.Exit(code=1)
203
199
 
204
200
 
201
+ @contextmanager
202
+ def temp_requirements_file(requirements: list[str]):
203
+ # Write dependencies to a requirements.txt-style temp file.
204
+ with tempfile.NamedTemporaryFile(mode="w", suffix=".txt") as temp_file:
205
+ temp_file.write("\n".join(requirements))
206
+ temp_file.flush()
207
+ yield temp_file.name
208
+
209
+
205
210
  def _install_requirements_to_vendor(requirements: list[str]):
206
211
  vendor_path = PROJECT_ROOT / "python_modules"
207
212
  logger.debug(f"Using vendor path: {vendor_path}")
@@ -212,97 +217,72 @@ def _install_requirements_to_vendor(requirements: list[str]):
212
217
  )
213
218
  return
214
219
 
215
- # Write dependencies to a requirements.txt-style temp file.
216
- with tempfile.NamedTemporaryFile(
217
- mode="w", suffix=".txt", dir=PYODIDE_VENV_PATH
218
- ) as temp_file:
219
- temp_file.write("\n".join(requirements))
220
- temp_file.flush()
221
- temp_file_path = Path(temp_file.name)
222
-
223
- # Install packages into vendor directory
224
- vendor_path.mkdir(parents=True, exist_ok=True)
225
- pyodide_venv_pip_path = (
226
- PYODIDE_VENV_PATH
227
- / ("Scripts" if os.name == "nt" else "bin")
228
- / ("pip.exe" if os.name == "nt" else "pip")
229
- )
230
- relative_vendor_path = vendor_path.relative_to(PROJECT_ROOT)
231
- logger.info(
232
- f"Installing packages into [bold]{relative_vendor_path}[/bold] using Pyodide pip...",
233
- extra={"markup": True},
234
- )
220
+ # Install packages into vendor directory
221
+ vendor_path.mkdir(parents=True, exist_ok=True)
222
+ relative_vendor_path = vendor_path.relative_to(PROJECT_ROOT)
223
+ logger.info(
224
+ f"Installing packages into [bold]{relative_vendor_path}[/bold]...",
225
+ extra={"markup": True},
226
+ )
227
+ with temp_requirements_file(requirements) as requirements_file:
235
228
  run_command(
236
229
  [
237
- str(pyodide_venv_pip_path),
230
+ "uv",
231
+ "pip",
238
232
  "install",
239
- "-t",
240
- str(vendor_path),
233
+ "--no-build",
241
234
  "-r",
242
- str(temp_file_path),
243
- ]
235
+ requirements_file,
236
+ "--extra-index-url",
237
+ _get_pyodide_index(),
238
+ "--index-strategy",
239
+ "unsafe-best-match",
240
+ ],
241
+ env=os.environ | {"VIRTUAL_ENV": PYODIDE_VENV_PATH},
242
+ )
243
+ pyv = _get_python_version()
244
+ shutil.rmtree(vendor_path)
245
+ shutil.copytree(
246
+ PYODIDE_VENV_PATH / f"lib/python{pyv}/site-packages", vendor_path
244
247
  )
245
248
 
246
- # Create a pyvenv.cfg file in python_modules to mark it as a virtual environment
247
- (vendor_path / "pyvenv.cfg").touch()
248
- VENDOR_TOKEN.write_text("")
249
+ # Create a pyvenv.cfg file in python_modules to mark it as a virtual environment
250
+ (vendor_path / "pyvenv.cfg").touch()
251
+ VENDOR_TOKEN.touch()
249
252
 
250
- logger.info(
251
- f"Packages installed in [bold]{relative_vendor_path}[/bold].",
252
- extra={"markup": True},
253
- )
253
+ logger.info(
254
+ f"Packages installed in [bold]{relative_vendor_path}[/bold].",
255
+ extra={"markup": True},
256
+ )
254
257
 
255
258
 
256
259
  def _install_requirements_to_venv(requirements: list[str]):
257
260
  # Create a requirements file for .venv-workers that includes webtypy and pyodide-py
258
- VENV_REQUIREMENTS_PATH.parent.mkdir(parents=True, exist_ok=True)
259
-
261
+ relative_venv_workers_path = VENV_WORKERS_PATH.relative_to(PROJECT_ROOT)
260
262
  requirements = requirements.copy()
261
263
  requirements.append("webtypy")
262
264
  requirements.append("pyodide-py")
263
265
 
264
- # Write dependencies to a requirements.txt-style temp file.
265
- with tempfile.NamedTemporaryFile(
266
- mode="w", suffix=".txt", dir=VENV_REQUIREMENTS_PATH.parent
267
- ) as temp_file:
268
- temp_file.write("\n".join(requirements))
269
- temp_file.flush()
270
- temp_file_path = Path(temp_file.name)
271
-
272
- # Install packages into .venv-workers so that user's IDE can see the packages.
273
- venv_bin_path = VENV_WORKERS_PATH / ("Scripts" if os.name == "nt" else "bin")
274
- venv_python_executable = venv_bin_path / (
275
- "python.exe" if os.name == "nt" else "python"
266
+ logger.info(
267
+ f"Installing packages into [bold]{relative_venv_workers_path}[/bold]...",
268
+ extra={"markup": True},
269
+ )
270
+ with temp_requirements_file(requirements) as requirements_file:
271
+ run_command(
272
+ [
273
+ "uv",
274
+ "pip",
275
+ "install",
276
+ "-r",
277
+ requirements_file,
278
+ ],
279
+ env=os.environ | {"VIRTUAL_ENV": VENV_WORKERS_PATH},
276
280
  )
277
-
278
- # For nicer logs, output the relative path.
279
- relative_venv_workers_path = VENV_WORKERS_PATH.relative_to(PROJECT_ROOT)
280
- if venv_python_executable.is_file():
281
- logger.info(
282
- f"Installing packages into [bold]{relative_venv_workers_path}[/bold] using uv pip...",
283
- extra={"markup": True},
284
- )
285
- run_command(
286
- [
287
- "uv",
288
- "pip",
289
- "install",
290
- "-p",
291
- venv_python_executable,
292
- "-r",
293
- str(temp_file_path),
294
- ]
295
- )
296
- VENV_WORKERS_TOKEN.write_text("")
297
- logger.info(
298
- f"Packages installed in [bold]{relative_venv_workers_path}[/bold].",
299
- extra={"markup": True},
300
- )
301
- else:
302
- logger.warning(
303
- f"Python executable not found at {venv_python_executable}. Skipping installation in [bold]{relative_venv_workers_path}[/bold].",
304
- extra={"markup": True},
305
- )
281
+ VENV_WORKERS_TOKEN.touch()
282
+ logger.info(
283
+ f"Packages installed in [bold]{relative_venv_workers_path}[/bold].",
284
+ extra={"markup": True},
285
+ )
306
286
 
307
287
 
308
288
  def install_requirements(requirements: list[str]):
@@ -310,6 +290,12 @@ def install_requirements(requirements: list[str]):
310
290
  _install_requirements_to_venv(requirements)
311
291
 
312
292
 
293
+ def _is_out_of_date(token: Path, time: float) -> bool:
294
+ if not token.exists():
295
+ return True
296
+ return time > token.stat().st_mtime
297
+
298
+
313
299
  def is_sync_needed():
314
300
  """
315
301
  Checks if pyproject.toml has been modified since the last sync.
@@ -323,20 +309,6 @@ def is_sync_needed():
323
309
  return True
324
310
 
325
311
  pyproject_mtime = PYPROJECT_TOML_PATH.stat().st_mtime
326
-
327
- # Check if .venv-workers exists and get its timestamp
328
- if not VENV_WORKERS_TOKEN.exists():
329
- return True
330
-
331
- venv_mtime = VENV_WORKERS_TOKEN.stat().st_mtime
332
- venv_needs_update = pyproject_mtime > venv_mtime
333
- if venv_needs_update:
334
- return True
335
-
336
- # Check if vendor directory exists and get its timestamp
337
- if not VENDOR_TOKEN.exists():
338
- return True
339
-
340
- vendor_mtime = VENDOR_TOKEN.stat().st_mtime
341
- vendor_needs_update = pyproject_mtime > vendor_mtime
342
- return vendor_needs_update
312
+ return _is_out_of_date(VENDOR_TOKEN, pyproject_mtime) or _is_out_of_date(
313
+ VENV_WORKERS_TOKEN, pyproject_mtime
314
+ )
@@ -135,29 +135,17 @@ def test_sync_command_integration(dependencies, clean_test_dir):
135
135
 
136
136
  # Create a test wrangler.jsonc file
137
137
  create_test_wrangler_jsonc("src/worker.py")
138
+ project_root = Path.cwd().resolve()
138
139
 
139
- # Save the current directory
140
- original_dir = os.getcwd()
140
+ # Get the absolute path to the package root
141
+ # Run the pywrangler CLI directly using uvx
142
+ print("\nRunning pywrangler sync...")
143
+ sync_cmd = ["uvx", "--from", project_root, "pywrangler", "sync"]
141
144
 
142
- try:
143
- # Change to the test directory
144
- os.chdir(TEST_DIR)
145
-
146
- # Get the absolute path to the package root
147
- project_root = Path(original_dir)
148
-
149
- # Run the pywrangler CLI directly using uvx
150
- print("\nRunning pywrangler sync...")
151
- sync_cmd = ["uvx", "--from", str(project_root), "pywrangler", "sync"]
152
-
153
- result = subprocess.run(sync_cmd, capture_output=True, text=True)
154
- print(f"\nCommand output:\n{result.stdout}")
155
- if result.stderr:
156
- print(f"Command errors:\n{result.stderr}")
157
-
158
- finally:
159
- # Change back to the original directory
160
- os.chdir(original_dir)
145
+ result = subprocess.run(sync_cmd, capture_output=True, text=True, cwd=TEST_DIR)
146
+ print(f"\nCommand output:\n{result.stdout}")
147
+ if result.stderr:
148
+ print(f"Command errors:\n{result.stderr}")
161
149
 
162
150
  # Check that the command succeeded
163
151
  assert result.returncode == 0, (
@@ -233,23 +221,12 @@ def test_sync_command_handles_missing_pyproject():
233
221
  assert not (temp_path / "pyproject.toml").exists()
234
222
 
235
223
  # Save original directory
236
- original_dir = os.getcwd()
237
-
238
- try:
239
- # Change to temp directory
240
- os.chdir(temp_path)
241
-
242
- # Get the absolute path to the package root
243
- project_root = Path(original_dir)
224
+ project_root = Path.cwd().resolve()
244
225
 
245
- # Run pywrangler sync from the temp directory (should fail)
246
- sync_cmd = ["uvx", "--from", str(project_root), "pywrangler", "sync"]
226
+ # Run pywrangler sync from the temp directory (should fail)
227
+ sync_cmd = ["uvx", "--from", project_root, "pywrangler", "sync"]
247
228
 
248
- result = subprocess.run(sync_cmd, capture_output=True, text=True)
249
-
250
- finally:
251
- # Change back to original directory
252
- os.chdir(original_dir)
229
+ result = subprocess.run(sync_cmd, capture_output=True, text=True, cwd=temp_path)
253
230
 
254
231
  # Check that the command failed with the expected error
255
232
  assert result.returncode != 0
@@ -447,27 +424,15 @@ def test_sync_command_finds_pyproject_in_parent_directory(clean_test_dir):
447
424
  subdir = TEST_DIR / "subproject"
448
425
  subdir.mkdir()
449
426
 
450
- # Save the original directory
451
- original_dir = os.getcwd()
452
-
453
- try:
454
- # Change to the subdirectory
455
- os.chdir(subdir)
456
-
457
- # Get the absolute path to the package root
458
- project_root = Path(original_dir)
427
+ project_root = Path.cwd().resolve()
459
428
 
460
- # Run the pywrangler CLI from the subdirectory
461
- sync_cmd = ["uvx", "--from", str(project_root), "pywrangler", "sync"]
429
+ # Run the pywrangler CLI from the subdirectory
430
+ sync_cmd = ["uvx", "--from", project_root, "pywrangler", "sync"]
462
431
 
463
- result = subprocess.run(sync_cmd, capture_output=True, text=True)
464
- print(f"\nCommand output:\n{result.stdout}")
465
- if result.stderr:
466
- print(f"Command errors:\n{result.stderr}")
467
-
468
- finally:
469
- # Change back to the original directory
470
- os.chdir(original_dir)
432
+ result = subprocess.run(sync_cmd, capture_output=True, text=True, cwd=subdir)
433
+ print(f"\nCommand output:\n{result.stdout}")
434
+ if result.stderr:
435
+ print(f"Command errors:\n{result.stderr}")
471
436
 
472
437
  # Check that the command succeeded
473
438
  assert result.returncode == 0, (
@@ -496,49 +461,45 @@ def test_sync_recreates_venv_on_python_version_mismatch(clean_test_dir):
496
461
  create_test_pyproject([])
497
462
  create_test_wrangler_jsonc()
498
463
 
499
- original_dir = os.getcwd()
500
- try:
501
- os.chdir(clean_test_dir)
502
- project_root = Path(original_dir)
503
- sync_cmd = ["uvx", "--from", str(project_root), "pywrangler", "sync"]
504
- venv_path = clean_test_dir / ".venv-workers"
505
-
506
- # First run: Create venv with Python 3.12
507
- print("\nRunning sync to create venv with Python 3.12...")
508
- env = os.environ.copy()
509
- env["_PYWRANGLER_PYTHON_VERSION"] = "3.12"
510
- result1 = subprocess.run(sync_cmd, capture_output=True, text=True, env=env)
511
-
512
- assert result1.returncode == 0, (
513
- f"First sync failed: {result1.stdout}\n{result1.stderr}"
514
- )
515
- assert venv_path.exists(), "Venv was not created on the first run."
516
- initial_mtime = venv_path.stat().st_mtime
464
+ project_root = Path.cwd().resolve()
517
465
 
518
- # Second run: Recreate venv with Python 3.13
519
- print("\nRunning sync to recreate venv with Python 3.13...")
520
- env["_PYWRANGLER_PYTHON_VERSION"] = "3.13"
521
- result2 = subprocess.run(sync_cmd, capture_output=True, text=True, env=env)
466
+ sync_cmd = ["uvx", "--from", project_root, "pywrangler", "sync"]
467
+ venv_path = clean_test_dir / ".venv-workers"
522
468
 
523
- assert result2.returncode == 0, (
524
- f"Second sync failed: {result2.stdout}\n{result2.stderr}"
525
- )
526
- assert venv_path.exists(), "Venv was not recreated."
527
- final_mtime = venv_path.stat().st_mtime
469
+ # First run: Create venv with Python 3.12
470
+ print("\nRunning sync to create venv with Python 3.12...")
471
+ env = os.environ | {"_PYWRANGLER_PYTHON_VERSION": "3.12"}
472
+ result1 = subprocess.run(
473
+ sync_cmd, capture_output=True, text=True, env=env, cwd=clean_test_dir
474
+ )
528
475
 
529
- # Check that the venv was actually modified
530
- assert final_mtime > initial_mtime, "Venv modification time did not change."
476
+ assert result1.returncode == 0, (
477
+ f"First sync failed: {result1.stdout}\n{result1.stderr}"
478
+ )
479
+ assert venv_path.exists(), "Venv was not created on the first run."
480
+ initial_mtime = venv_path.stat().st_mtime
481
+
482
+ # Second run: Recreate venv with Python 3.13
483
+ print("\nRunning sync to recreate venv with Python 3.13...")
484
+ env = os.environ | {"_PYWRANGLER_PYTHON_VERSION": "3.13"}
485
+ result2 = subprocess.run(
486
+ sync_cmd, capture_output=True, text=True, env=env, cwd=clean_test_dir
487
+ )
531
488
 
532
- # Verify the python version in the new venv is 3.13.
533
- python_exe = venv_path / (
534
- "Scripts/python.exe" if os.name == "nt" else "bin/python"
535
- )
536
- version_result = subprocess.run(
537
- [str(python_exe), "--version"], capture_output=True, text=True
538
- )
539
- assert "3.13" in version_result.stdout, (
540
- f"Python version is not 3.13: {version_result.stdout}"
541
- )
489
+ assert result2.returncode == 0, (
490
+ f"Second sync failed: {result2.stdout}\n{result2.stderr}"
491
+ )
492
+ assert venv_path.exists(), "Venv was not recreated."
493
+ final_mtime = venv_path.stat().st_mtime
494
+
495
+ # Check that the venv was actually modified
496
+ assert final_mtime > initial_mtime, "Venv modification time did not change."
542
497
 
543
- finally:
544
- os.chdir(original_dir)
498
+ # Verify the python version in the new venv is 3.13.
499
+ python_exe = venv_path / ("Scripts/python.exe" if os.name == "nt" else "bin/python")
500
+ version_result = subprocess.run(
501
+ [python_exe, "--version"], capture_output=True, text=True, cwd=clean_test_dir
502
+ )
503
+ assert "3.13" in version_result.stdout, (
504
+ f"Python version is not 3.13: {version_result.stdout}"
505
+ )
@@ -522,7 +522,7 @@ wheels = [
522
522
 
523
523
  [[package]]
524
524
  name = "workers-py"
525
- version = "1.1.8"
525
+ version = "1.2.1"
526
526
  source = { editable = "." }
527
527
  dependencies = [
528
528
  { name = "click", version = "8.1.8", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.12'" },
File without changes
File without changes
File without changes
File without changes