anyenv 0.3.3__tar.gz → 0.3.4__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.
Files changed (42) hide show
  1. {anyenv-0.3.3 → anyenv-0.3.4}/PKG-INFO +1 -1
  2. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/__init__.py +1 -1
  3. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/base.py +1 -1
  4. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/functional.py +88 -11
  5. {anyenv-0.3.3 → anyenv-0.3.4}/.copier-answers.yml +0 -0
  6. {anyenv-0.3.3 → anyenv-0.3.4}/.github/FUNDING.yml +0 -0
  7. {anyenv-0.3.3 → anyenv-0.3.4}/.github/copilot-instructions.md +0 -0
  8. {anyenv-0.3.3 → anyenv-0.3.4}/.github/dependabot.yml +0 -0
  9. {anyenv-0.3.3 → anyenv-0.3.4}/.github/workflows/build.yml +0 -0
  10. {anyenv-0.3.3 → anyenv-0.3.4}/.github/workflows/documentation.yml +0 -0
  11. {anyenv-0.3.3 → anyenv-0.3.4}/.gitignore +0 -0
  12. {anyenv-0.3.3 → anyenv-0.3.4}/.pre-commit-config.yaml +0 -0
  13. {anyenv-0.3.3 → anyenv-0.3.4}/LICENSE +0 -0
  14. {anyenv-0.3.3 → anyenv-0.3.4}/README.md +0 -0
  15. {anyenv-0.3.3 → anyenv-0.3.4}/docs/.empty +0 -0
  16. {anyenv-0.3.3 → anyenv-0.3.4}/duties.py +0 -0
  17. {anyenv-0.3.3 → anyenv-0.3.4}/mkdocs.yml +0 -0
  18. {anyenv-0.3.3 → anyenv-0.3.4}/overrides/_dummy.txt +0 -0
  19. {anyenv-0.3.3 → anyenv-0.3.4}/pyproject.toml +0 -0
  20. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/async_run.py +0 -0
  21. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/__init__.py +0 -0
  22. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/aiohttp_backend.py +0 -0
  23. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/exceptions.py +0 -0
  24. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/httpx_backend.py +0 -0
  25. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/httpx_serializer.py +0 -0
  26. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/download/pyodide_backend.py +0 -0
  27. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/json_tools/__init__.py +0 -0
  28. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/json_tools/dumping.py +0 -0
  29. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/json_tools/loading.py +0 -0
  30. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/package_install/__init__.py +0 -0
  31. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/package_install/base.py +0 -0
  32. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/package_install/functional.py +0 -0
  33. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/package_install/micropip_install.py +0 -0
  34. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/package_install/pip_install.py +0 -0
  35. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/py.typed +0 -0
  36. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/testing.py +0 -0
  37. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/threadgroup/__init__.py +0 -0
  38. {anyenv-0.3.3 → anyenv-0.3.4}/src/anyenv/threadgroup/threadgroup.py +0 -0
  39. {anyenv-0.3.3 → anyenv-0.3.4}/tests/__init__.py +0 -0
  40. {anyenv-0.3.3 → anyenv-0.3.4}/tests/conftest.py +0 -0
  41. {anyenv-0.3.3 → anyenv-0.3.4}/tests/test_download.py +0 -0
  42. {anyenv-0.3.3 → anyenv-0.3.4}/tests/test_threadgroup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: anyenv
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Compatibility layer for some basic operations to allow painless operation in PyOdide and Python pre-releases
5
5
  Project-URL: Documentation, https://phil65.github.io/anyenv/
6
6
  Project-URL: Source, https://github.com/phil65/anyenv
@@ -1,6 +1,6 @@
1
1
  """AnyEnv: A library for environment management and utility functions."""
2
2
 
3
- __version__ = "0.3.3"
3
+ __version__ = "0.3.4"
4
4
 
5
5
  from anyenv.async_run import run_sync, run_sync_in_thread
6
6
  from anyenv.download.functional import (
@@ -128,7 +128,7 @@ class HttpBackend(abc.ABC):
128
128
  cache_ttl: Time-to-live for cached responses in seconds.
129
129
  """
130
130
  cache_ttl = cache_ttl or DEFAULT_TTL
131
- dir_ = cache_dir or user_cache_dir("anyenv", "anyenv")
131
+ dir_ = cache_dir or user_cache_dir("anyenv", False)
132
132
  self.cache_dir = pathlib.Path(dir_)
133
133
  self.cache_ttl = cache_ttl
134
134
 
@@ -46,14 +46,14 @@ def _get_default_backend() -> HttpBackend:
46
46
 
47
47
  def get_backend(
48
48
  backend_type: BackendType | None = None,
49
- cache_path: str | os.PathLike[str] | None = None,
49
+ cache_dir: str | os.PathLike[str] | None = None,
50
50
  cache_ttl: int | None = None,
51
51
  ) -> HttpBackend:
52
52
  """Get a specific HTTP backend or the best available one.
53
53
 
54
54
  Args:
55
55
  backend_type: Optional backend type to use. If None, uses the best available.
56
- cache_path: Optional path to use for caching. If None, uses a default path.
56
+ cache_dir: Optional path to use for caching. If None, uses a default path.
57
57
  cache_ttl: Optional TTL for cached responses. If None, uses a default TTL.
58
58
 
59
59
  Returns:
@@ -69,7 +69,7 @@ def get_backend(
69
69
  if importlib.util.find_spec("httpx") and importlib.util.find_spec("hishel"):
70
70
  from anyenv.download.httpx_backend import HttpxBackend
71
71
 
72
- return HttpxBackend(cache_dir=cache_path, cache_ttl=cache_ttl)
72
+ return HttpxBackend(cache_dir=cache_dir, cache_ttl=cache_ttl)
73
73
  msg = "httpx backend requested but httpx or hishel not installed"
74
74
  raise ImportError(msg)
75
75
 
@@ -79,7 +79,7 @@ def get_backend(
79
79
  ):
80
80
  from anyenv.download.aiohttp_backend import AiohttpBackend
81
81
 
82
- return AiohttpBackend(cache_dir=cache_path, cache_ttl=cache_ttl)
82
+ return AiohttpBackend(cache_dir=cache_dir, cache_ttl=cache_ttl)
83
83
  msg = (
84
84
  "aiohttp backend requested but aiohttp or aiohttp_client_cache not installed"
85
85
  )
@@ -111,6 +111,8 @@ async def request(
111
111
  timeout: float | None = None,
112
112
  cache: bool = False,
113
113
  backend: BackendType | None = None,
114
+ cache_dir: str | os.PathLike[str] | None = None,
115
+ cache_ttl: int | None = None,
114
116
  ) -> HttpResponse:
115
117
  """Make an HTTP request.
116
118
 
@@ -124,11 +126,13 @@ async def request(
124
126
  timeout: Optional request timeout in seconds
125
127
  cache: Whether to use cached responses
126
128
  backend: Optional specific backend to use
129
+ cache_dir: Optional directory to store cached responses
130
+ cache_ttl: Optional time-to-live for cached responses in seconds
127
131
 
128
132
  Returns:
129
133
  An HttpResponse object
130
134
  """
131
- http_backend = get_backend(backend)
135
+ http_backend = get_backend(backend, cache_dir=cache_dir, cache_ttl=cache_ttl)
132
136
  return await http_backend.request(
133
137
  method,
134
138
  url,
@@ -149,6 +153,8 @@ async def get(
149
153
  timeout: float | None = None,
150
154
  cache: bool = False,
151
155
  backend: BackendType | None = None,
156
+ cache_dir: str | os.PathLike[str] | None = None,
157
+ cache_ttl: int | None = None,
152
158
  ) -> HttpResponse:
153
159
  """Make a GET request.
154
160
 
@@ -159,6 +165,8 @@ async def get(
159
165
  timeout: Optional request timeout in seconds
160
166
  cache: Whether to use cached responses
161
167
  backend: Optional specific backend to use
168
+ cache_dir: Optional directory to store cached responses
169
+ cache_ttl: Optional time-to-live for cached responses in seconds
162
170
 
163
171
  Returns:
164
172
  An HttpResponse object
@@ -171,6 +179,8 @@ async def get(
171
179
  timeout=timeout,
172
180
  cache=cache,
173
181
  backend=backend,
182
+ cache_dir=cache_dir,
183
+ cache_ttl=cache_ttl,
174
184
  )
175
185
 
176
186
 
@@ -184,6 +194,8 @@ async def post(
184
194
  timeout: float | None = None,
185
195
  cache: bool = False,
186
196
  backend: BackendType | None = None,
197
+ cache_dir: str | os.PathLike[str] | None = None,
198
+ cache_ttl: int | None = None,
187
199
  ) -> HttpResponse:
188
200
  """Make a POST request.
189
201
 
@@ -196,6 +208,8 @@ async def post(
196
208
  timeout: Optional request timeout in seconds
197
209
  cache: Whether to use cached responses
198
210
  backend: Optional specific backend to use
211
+ cache_dir: Optional path to use for caching
212
+ cache_ttl: Optional time-to-live for cached responses
199
213
 
200
214
  Returns:
201
215
  An HttpResponse object
@@ -210,6 +224,8 @@ async def post(
210
224
  timeout=timeout,
211
225
  cache=cache,
212
226
  backend=backend,
227
+ cache_dir=cache_dir,
228
+ cache_ttl=cache_ttl,
213
229
  )
214
230
 
215
231
 
@@ -221,6 +237,8 @@ async def download(
221
237
  progress_callback: ProgressCallback | None = None,
222
238
  cache: bool = False,
223
239
  backend: BackendType | None = None,
240
+ cache_dir: str | os.PathLike[str] | None = None,
241
+ cache_ttl: int | None = None,
224
242
  ) -> None:
225
243
  """Download a file with optional progress reporting.
226
244
 
@@ -231,8 +249,10 @@ async def download(
231
249
  progress_callback: Optional callback for progress reporting
232
250
  cache: Whether to use cached responses
233
251
  backend: Optional specific backend to use
252
+ cache_dir: Optional directory to use for caching
253
+ cache_ttl: Optional time-to-live for cached responses
234
254
  """
235
- http_backend = get_backend(backend)
255
+ http_backend = get_backend(backend, cache_dir=cache_dir, cache_ttl=cache_ttl)
236
256
  await http_backend.download(
237
257
  url,
238
258
  path,
@@ -253,6 +273,8 @@ async def get_text(
253
273
  timeout: float | None = None,
254
274
  cache: bool = False,
255
275
  backend: BackendType | None = None,
276
+ cache_dir: str | os.PathLike[str] | None = None,
277
+ cache_ttl: int | None = None,
256
278
  ) -> str:
257
279
  """Make a GET request and return the response text.
258
280
 
@@ -263,12 +285,21 @@ async def get_text(
263
285
  timeout: Optional request timeout in seconds
264
286
  cache: Whether to use cached responses
265
287
  backend: Optional specific backend to use
288
+ cache_dir: Optional directory to store cached responses
289
+ cache_ttl: Optional time-to-live for cached responses
266
290
 
267
291
  Returns:
268
292
  The response body as text
269
293
  """
270
294
  response = await get(
271
- url, params=params, headers=headers, timeout=timeout, cache=cache, backend=backend
295
+ url,
296
+ params=params,
297
+ headers=headers,
298
+ timeout=timeout,
299
+ cache=cache,
300
+ backend=backend,
301
+ cache_dir=cache_dir,
302
+ cache_ttl=cache_ttl,
272
303
  )
273
304
  return await response.text()
274
305
 
@@ -281,6 +312,8 @@ async def get_json(
281
312
  timeout: float | None = None,
282
313
  cache: bool = False,
283
314
  backend: BackendType | None = None,
315
+ cache_dir: str | os.PathLike[str] | None = None,
316
+ cache_ttl: int | None = None,
284
317
  ) -> Any:
285
318
  """Make a GET request and return the response as JSON.
286
319
 
@@ -291,12 +324,21 @@ async def get_json(
291
324
  timeout: Optional request timeout in seconds
292
325
  cache: Whether to use cached responses
293
326
  backend: Optional specific backend to use
327
+ cache_dir: Optional directory to store cached responses
328
+ cache_ttl: Optional time-to-live for cached responses
294
329
 
295
330
  Returns:
296
331
  The response body parsed as JSON
297
332
  """
298
333
  response = await get(
299
- url, params=params, headers=headers, timeout=timeout, cache=cache, backend=backend
334
+ url,
335
+ params=params,
336
+ headers=headers,
337
+ timeout=timeout,
338
+ cache=cache,
339
+ backend=backend,
340
+ cache_dir=cache_dir,
341
+ cache_ttl=cache_ttl,
300
342
  )
301
343
  return await response.json()
302
344
 
@@ -309,6 +351,8 @@ async def get_bytes(
309
351
  timeout: float | None = None,
310
352
  cache: bool = False,
311
353
  backend: BackendType | None = None,
354
+ cache_dir: str | os.PathLike[str] | None = None,
355
+ cache_ttl: int | None = None,
312
356
  ) -> bytes:
313
357
  """Make a GET request and return the response as bytes.
314
358
 
@@ -319,12 +363,21 @@ async def get_bytes(
319
363
  timeout: Optional request timeout in seconds
320
364
  cache: Whether to use cached responses
321
365
  backend: Optional specific backend to use
366
+ cache_dir: Optional directory to store cached responses
367
+ cache_ttl: Optional time-to-live for cached responses
322
368
 
323
369
  Returns:
324
370
  The response body as bytes
325
371
  """
326
372
  response = await get(
327
- url, params=params, headers=headers, timeout=timeout, cache=cache, backend=backend
373
+ url,
374
+ params=params,
375
+ headers=headers,
376
+ timeout=timeout,
377
+ cache=cache,
378
+ backend=backend,
379
+ cache_dir=cache_dir,
380
+ cache_ttl=cache_ttl,
328
381
  )
329
382
  return await response.bytes()
330
383
 
@@ -343,9 +396,11 @@ def request_sync(
343
396
  timeout: float | None = None,
344
397
  cache: bool = False,
345
398
  backend: BackendType | None = None,
399
+ cache_dir: str | os.PathLike[str] | None = None,
400
+ cache_ttl: int | None = None,
346
401
  ) -> HttpResponse:
347
402
  """Synchronous version of request."""
348
- http_backend = get_backend(backend)
403
+ http_backend = get_backend(backend, cache_dir=cache_dir, cache_ttl=cache_ttl)
349
404
  return http_backend.request_sync(
350
405
  method,
351
406
  url,
@@ -366,6 +421,8 @@ def get_sync(
366
421
  timeout: float | None = None,
367
422
  cache: bool = False,
368
423
  backend: BackendType | None = None,
424
+ cache_dir: str | os.PathLike[str] | None = None,
425
+ cache_ttl: int | None = None,
369
426
  ) -> HttpResponse:
370
427
  """Synchronous version of get."""
371
428
  return request_sync(
@@ -376,6 +433,8 @@ def get_sync(
376
433
  timeout=timeout,
377
434
  cache=cache,
378
435
  backend=backend,
436
+ cache_dir=cache_dir,
437
+ cache_ttl=cache_ttl,
379
438
  )
380
439
 
381
440
 
@@ -389,6 +448,8 @@ def post_sync(
389
448
  timeout: float | None = None,
390
449
  cache: bool = False,
391
450
  backend: BackendType | None = None,
451
+ cache_dir: str | os.PathLike[str] | None = None,
452
+ cache_ttl: int | None = None,
392
453
  ) -> HttpResponse:
393
454
  """Synchronous version of post."""
394
455
  return request_sync(
@@ -401,6 +462,8 @@ def post_sync(
401
462
  timeout=timeout,
402
463
  cache=cache,
403
464
  backend=backend,
465
+ cache_dir=cache_dir,
466
+ cache_ttl=cache_ttl,
404
467
  )
405
468
 
406
469
 
@@ -412,9 +475,11 @@ def download_sync(
412
475
  progress_callback: ProgressCallback | None = None,
413
476
  cache: bool = False,
414
477
  backend: BackendType | None = None,
478
+ cache_dir: str | os.PathLike[str] | None = None,
479
+ cache_ttl: int | None = None,
415
480
  ) -> None:
416
481
  """Synchronous version of download."""
417
- http_backend = get_backend(backend)
482
+ http_backend = get_backend(backend, cache_dir=cache_dir, cache_ttl=cache_ttl)
418
483
  http_backend.download_sync(
419
484
  url,
420
485
  path,
@@ -432,6 +497,8 @@ def get_text_sync(
432
497
  timeout: float | None = None,
433
498
  cache: bool = False,
434
499
  backend: BackendType | None = None,
500
+ cache_dir: str | os.PathLike[str] | None = None,
501
+ cache_ttl: int | None = None,
435
502
  ) -> str:
436
503
  """Synchronous version of get_text."""
437
504
  from anyenv.async_run import run_sync
@@ -444,6 +511,8 @@ def get_text_sync(
444
511
  timeout=timeout,
445
512
  cache=cache,
446
513
  backend=backend,
514
+ cache_dir=cache_dir,
515
+ cache_ttl=cache_ttl,
447
516
  )
448
517
  )
449
518
 
@@ -456,6 +525,8 @@ def get_json_sync(
456
525
  timeout: float | None = None,
457
526
  cache: bool = False,
458
527
  backend: BackendType | None = None,
528
+ cache_dir: str | os.PathLike[str] | None = None,
529
+ cache_ttl: int | None = None,
459
530
  ) -> Any:
460
531
  """Synchronous version of get_json."""
461
532
  from anyenv.async_run import run_sync
@@ -468,6 +539,8 @@ def get_json_sync(
468
539
  timeout=timeout,
469
540
  cache=cache,
470
541
  backend=backend,
542
+ cache_dir=cache_dir,
543
+ cache_ttl=cache_ttl,
471
544
  )
472
545
  )
473
546
 
@@ -480,6 +553,8 @@ def get_bytes_sync(
480
553
  timeout: float | None = None,
481
554
  cache: bool = False,
482
555
  backend: BackendType | None = None,
556
+ cache_dir: str | os.PathLike[str] | None = None,
557
+ cache_ttl: int | None = None,
483
558
  ) -> bytes:
484
559
  """Synchronous version of get_bytes."""
485
560
  from anyenv.async_run import run_sync
@@ -492,5 +567,7 @@ def get_bytes_sync(
492
567
  timeout=timeout,
493
568
  cache=cache,
494
569
  backend=backend,
570
+ cache_dir=cache_dir,
571
+ cache_ttl=cache_ttl,
495
572
  )
496
573
  )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes