workers-py 1.6.2__py3-none-any.whl → 1.7.0__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/sync.py +40 -3
- pywrangler/utils.py +8 -4
- {workers_py-1.6.2.dist-info → workers_py-1.7.0.dist-info}/METADATA +1 -1
- {workers_py-1.6.2.dist-info → workers_py-1.7.0.dist-info}/RECORD +6 -6
- {workers_py-1.6.2.dist-info → workers_py-1.7.0.dist-info}/WHEEL +0 -0
- {workers_py-1.6.2.dist-info → workers_py-1.7.0.dist-info}/entry_points.txt +0 -0
pywrangler/sync.py
CHANGED
|
@@ -177,7 +177,7 @@ def _install_requirements_to_vendor(requirements: list[str]) -> None:
|
|
|
177
177
|
extra={"markup": True},
|
|
178
178
|
)
|
|
179
179
|
with temp_requirements_file(requirements) as requirements_file:
|
|
180
|
-
run_command(
|
|
180
|
+
result = run_command(
|
|
181
181
|
[
|
|
182
182
|
"uv",
|
|
183
183
|
"pip",
|
|
@@ -190,8 +190,31 @@ def _install_requirements_to_vendor(requirements: list[str]) -> None:
|
|
|
190
190
|
"--index-strategy",
|
|
191
191
|
"unsafe-best-match",
|
|
192
192
|
],
|
|
193
|
+
capture_output=True,
|
|
194
|
+
check=False,
|
|
193
195
|
env=os.environ | {"VIRTUAL_ENV": get_pyodide_venv_path()},
|
|
194
196
|
)
|
|
197
|
+
if result.returncode != 0:
|
|
198
|
+
logger.warning(result.stdout.strip())
|
|
199
|
+
# Handle some common failures and give nicer error messages for them.
|
|
200
|
+
lowered_stdout = result.stdout.lower()
|
|
201
|
+
if "invalid peer certificate" in lowered_stdout:
|
|
202
|
+
logger.error(
|
|
203
|
+
"Installation failed because of an invalid peer certificate. Are your systems certificates correctly installed? Do you have an Enterprise VPN enabled?"
|
|
204
|
+
)
|
|
205
|
+
elif "failed to fetch" in lowered_stdout:
|
|
206
|
+
logger.error(
|
|
207
|
+
"Installation failed because of a failed fetch. Is your network connection working?"
|
|
208
|
+
)
|
|
209
|
+
elif "no solution found when resolving dependencies" in lowered_stdout:
|
|
210
|
+
logger.error(
|
|
211
|
+
"Installation failed because the packages you requested are not supported by Python Workers. See above for details."
|
|
212
|
+
)
|
|
213
|
+
else:
|
|
214
|
+
logger.error(
|
|
215
|
+
"Installation of packages into the Python Worker failed. Possibly because these packages are not currently supported. See above for details."
|
|
216
|
+
)
|
|
217
|
+
raise click.exceptions.Exit(code=result.returncode)
|
|
195
218
|
pyv = get_python_version()
|
|
196
219
|
shutil.rmtree(vendor_path)
|
|
197
220
|
shutil.copytree(
|
|
@@ -221,7 +244,7 @@ def _install_requirements_to_venv(requirements: list[str]) -> None:
|
|
|
221
244
|
extra={"markup": True},
|
|
222
245
|
)
|
|
223
246
|
with temp_requirements_file(requirements) as requirements_file:
|
|
224
|
-
run_command(
|
|
247
|
+
result = run_command(
|
|
225
248
|
[
|
|
226
249
|
"uv",
|
|
227
250
|
"pip",
|
|
@@ -229,8 +252,16 @@ def _install_requirements_to_venv(requirements: list[str]) -> None:
|
|
|
229
252
|
"-r",
|
|
230
253
|
requirements_file,
|
|
231
254
|
],
|
|
255
|
+
check=False,
|
|
232
256
|
env=os.environ | {"VIRTUAL_ENV": venv_workers_path},
|
|
257
|
+
capture_output=True,
|
|
233
258
|
)
|
|
259
|
+
if result.returncode != 0:
|
|
260
|
+
logger.warning(result.stdout.strip())
|
|
261
|
+
logger.error(
|
|
262
|
+
"Failed to install the requirements defined in your pyproject.toml file. See above for details."
|
|
263
|
+
)
|
|
264
|
+
raise click.exceptions.Exit(code=result.returncode)
|
|
234
265
|
|
|
235
266
|
get_venv_workers_token_path().touch()
|
|
236
267
|
logger.info(
|
|
@@ -240,8 +271,14 @@ def _install_requirements_to_venv(requirements: list[str]) -> None:
|
|
|
240
271
|
|
|
241
272
|
|
|
242
273
|
def install_requirements(requirements: list[str]) -> None:
|
|
243
|
-
|
|
274
|
+
# Note: the order these are executed is important.
|
|
275
|
+
# We need to install to .venv-workers first, so that we can determine if the packages requested
|
|
276
|
+
# by the user are valid.
|
|
244
277
|
_install_requirements_to_venv(requirements)
|
|
278
|
+
# Then we install the same requirements to the vendor directory. If this installation
|
|
279
|
+
# fails while the above succeeded, it implies that Pyodide does not support these package
|
|
280
|
+
# requirements which allows us to give a nicer error message to the user.
|
|
281
|
+
_install_requirements_to_vendor(requirements)
|
|
245
282
|
|
|
246
283
|
|
|
247
284
|
def _is_out_of_date(token: Path, time: float) -> bool:
|
pywrangler/utils.py
CHANGED
|
@@ -79,20 +79,24 @@ def run_command(
|
|
|
79
79
|
"""
|
|
80
80
|
logger.log(RUNNING_LEVEL, f"{' '.join(str(arg) for arg in command)}")
|
|
81
81
|
try:
|
|
82
|
+
kwargs = {}
|
|
83
|
+
if capture_output:
|
|
84
|
+
kwargs = dict(stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
|
85
|
+
|
|
82
86
|
process = subprocess.run(
|
|
83
87
|
command,
|
|
84
88
|
cwd=cwd,
|
|
85
89
|
env=env,
|
|
86
90
|
check=check,
|
|
87
|
-
capture_output=capture_output,
|
|
88
91
|
text=True,
|
|
89
|
-
|
|
92
|
+
**kwargs,
|
|
93
|
+
) # type: ignore[call-overload]
|
|
90
94
|
if process.stdout and not capture_output:
|
|
91
95
|
logger.log(OUTPUT_LEVEL, f"{process.stdout.strip()}")
|
|
92
|
-
return process
|
|
96
|
+
return process # type: ignore[no-any-return]
|
|
93
97
|
except subprocess.CalledProcessError as e:
|
|
94
98
|
logger.error(
|
|
95
|
-
f"Error running command: {' '.join(str(arg) for arg in command)}\nExit code: {e.returncode}\nOutput:\n{e.stdout.strip() if e.stdout else ''}
|
|
99
|
+
f"Error running command: {' '.join(str(arg) for arg in command)}\nExit code: {e.returncode}\nOutput:\n{e.stdout.strip() if e.stdout else ''}"
|
|
96
100
|
)
|
|
97
101
|
raise click.exceptions.Exit(code=e.returncode) from None
|
|
98
102
|
except FileNotFoundError:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: workers-py
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.7.0
|
|
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
|
|
@@ -3,10 +3,10 @@ pywrangler/__main__.py,sha256=wcCrL4PjG51r5wVKqJhcoJPTLfHW0wNbD31DrUN0MWI,28
|
|
|
3
3
|
pywrangler/cli.py,sha256=8C4iBntruyMkQqOb0KfH_H0QNGYYWEBtKFA7b7zGSmE,5467
|
|
4
4
|
pywrangler/metadata.py,sha256=ndh584ALzshSXwduTmqVczfF5Mpn7z0F9ztn3Dugf70,408
|
|
5
5
|
pywrangler/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
pywrangler/sync.py,sha256=
|
|
6
|
+
pywrangler/sync.py,sha256=TuM_bmBdgi37xYFtD62GTNwyNaDgO87QwfS-OYLR8OM,11647
|
|
7
7
|
pywrangler/types.py,sha256=hYJ6hNIjWb0faBGW82AWfCBsF_JPb7sXKCXPtFM3Mhk,1183
|
|
8
|
-
pywrangler/utils.py,sha256=
|
|
9
|
-
workers_py-1.
|
|
10
|
-
workers_py-1.
|
|
11
|
-
workers_py-1.
|
|
12
|
-
workers_py-1.
|
|
8
|
+
pywrangler/utils.py,sha256=mPY8LcRqYMuyVzyWS_077-4MX3K6sIThV1gY8_br9U0,10495
|
|
9
|
+
workers_py-1.7.0.dist-info/METADATA,sha256=z6R2A_5LLb2hE5xY6NOpqXxX0ooA3kexOp1BIho7qlc,1774
|
|
10
|
+
workers_py-1.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
11
|
+
workers_py-1.7.0.dist-info/entry_points.txt,sha256=pt6X-Nv5-gSiKUwrnvLwzlSXs9yP37m7zdTAi8f6nAM,50
|
|
12
|
+
workers_py-1.7.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|