asanypath 2.4.0__tar.gz → 2.6.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.
Files changed (87) hide show
  1. {asanypath-2.4.0 → asanypath-2.6.0}/.github/workflows/publish.yml +22 -8
  2. {asanypath-2.4.0 → asanypath-2.6.0}/.github/workflows/unittests.yml +2 -2
  3. {asanypath-2.4.0 → asanypath-2.6.0}/CONTRIBUTING.md +1 -1
  4. {asanypath-2.4.0 → asanypath-2.6.0}/PKG-INFO +119 -6
  5. {asanypath-2.4.0 → asanypath-2.6.0}/README.md +116 -4
  6. {asanypath-2.4.0 → asanypath-2.6.0}/pyproject.toml +6 -0
  7. asanypath-2.6.0/scripts/bench_rmtree.py +80 -0
  8. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/__init__.py +2 -0
  9. asanypath-2.6.0/src/asanypath/_backend_opts.py +115 -0
  10. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/_version.py +2 -2
  11. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/artifactory.py +69 -23
  12. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/asanypath.py +11 -15
  13. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/asanypath.pyi +4 -2
  14. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/azure.py +6 -0
  15. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/cli.py +15 -364
  16. asanypath-2.6.0/src/asanypath/click.py +317 -0
  17. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/cloud.py +33 -26
  18. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/common.py +119 -59
  19. asanypath-2.6.0/src/asanypath/exceptions.py +79 -0
  20. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/gcs.py +6 -0
  21. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/http.py +50 -12
  22. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/s3.py +6 -0
  23. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_artifactory.py +126 -4
  24. asanypath-2.6.0/tests/test_auth_errors.py +119 -0
  25. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_backend_options.py +79 -2
  26. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_cli.py +0 -177
  27. asanypath-2.6.0/tests/test_click.py +459 -0
  28. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_cloudpathmixin.py +67 -15
  29. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_commonpathmixin.py +140 -5
  30. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_http_auth.py +70 -0
  31. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_isolation.py +25 -20
  32. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_local.py +21 -0
  33. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_syncpath.py +21 -0
  34. asanypath-2.4.0/src/asanypath/_backend_opts.py +0 -61
  35. asanypath-2.4.0/src/asanypath/exceptions.py +0 -43
  36. {asanypath-2.4.0 → asanypath-2.6.0}/.copilot/skills/async-python-lib/SKILL.md +0 -0
  37. {asanypath-2.4.0 → asanypath-2.6.0}/.copilot/skills/gitguro/SKILL.md +0 -0
  38. {asanypath-2.4.0 → asanypath-2.6.0}/.github/CODEOWNERS +0 -0
  39. {asanypath-2.4.0 → asanypath-2.6.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  40. {asanypath-2.4.0 → asanypath-2.6.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  41. {asanypath-2.4.0 → asanypath-2.6.0}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  42. {asanypath-2.4.0 → asanypath-2.6.0}/.github/dependabot.yml +0 -0
  43. {asanypath-2.4.0 → asanypath-2.6.0}/.gitignore +0 -0
  44. {asanypath-2.4.0 → asanypath-2.6.0}/.pre-commit-config.yaml +0 -0
  45. {asanypath-2.4.0 → asanypath-2.6.0}/CODE_OF_CONDUCT.md +0 -0
  46. {asanypath-2.4.0 → asanypath-2.6.0}/LICENSE +0 -0
  47. {asanypath-2.4.0 → asanypath-2.6.0}/asanypath.png +0 -0
  48. {asanypath-2.4.0 → asanypath-2.6.0}/compose.yml +0 -0
  49. {asanypath-2.4.0 → asanypath-2.6.0}/hatch_build.py +0 -0
  50. {asanypath-2.4.0 → asanypath-2.6.0}/scripts/bench.py +0 -0
  51. {asanypath-2.4.0 → asanypath-2.6.0}/scripts/bench_upload.py +0 -0
  52. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/__init__.pyi +0 -0
  53. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/_credstore.py +0 -0
  54. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/_prompt.py +0 -0
  55. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/_resume.py +0 -0
  56. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/_transfer.py +0 -0
  57. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/batcher.py +0 -0
  58. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/cache.py +0 -0
  59. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/ftp.py +0 -0
  60. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/local.py +0 -0
  61. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/options.py +0 -0
  62. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/py.typed +0 -0
  63. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/ssh.py +0 -0
  64. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/sync.py +0 -0
  65. {asanypath-2.4.0 → asanypath-2.6.0}/src/asanypath/unsupported.py +0 -0
  66. {asanypath-2.4.0 → asanypath-2.6.0}/tests/__init__.py +0 -0
  67. {asanypath-2.4.0 → asanypath-2.6.0}/tests/conftest.py +0 -0
  68. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_asanypath.py +0 -0
  69. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_azure.py +0 -0
  70. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_batcher.py +0 -0
  71. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_cache.py +0 -0
  72. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_credstore.py +0 -0
  73. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_endpoints.py +0 -0
  74. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_ftp.py +0 -0
  75. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_gcs.py +0 -0
  76. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_http.py +0 -0
  77. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_options.py +0 -0
  78. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_py_typed.py +0 -0
  79. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_resume.py +0 -0
  80. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_s3.py +0 -0
  81. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_scandir.py +0 -0
  82. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_ssh.py +0 -0
  83. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_ssh_hostkeys.py +0 -0
  84. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_sync.py +0 -0
  85. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_transport_hardening.py +0 -0
  86. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_unsupported_path.py +0 -0
  87. {asanypath-2.4.0 → asanypath-2.6.0}/tests/test_upload.py +0 -0
@@ -67,16 +67,30 @@ jobs:
67
67
  sed -i.bak -E "s/^version = \".*\"$/version = \"${VERSION}\"/" rust/Cargo.toml
68
68
  rm rust/Cargo.toml.bak
69
69
 
70
+ # Linux wheels build in a manylinux container with its own interpreters;
71
+ # macOS and Windows build against the runner's.
72
+ - name: Set up Python interpreters
73
+ if: runner.os != 'Linux'
74
+ uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
75
+ with:
76
+ python-version: |
77
+ 3.10
78
+ 3.11
79
+ 3.12
80
+ 3.13
81
+ 3.14
82
+ 3.15
83
+
70
84
  - name: Build native wheels
71
85
  uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
72
86
  with:
73
87
  working-directory: rust
74
88
  target: ${{ matrix.target }}
75
89
  manylinux: ${{ matrix.manylinux }}
76
- args: --release --out dist --interpreter 3.10 3.11 3.12 3.13 3.14
90
+ args: --release --out dist --interpreter 3.10 3.11 3.12 3.13 3.14 3.15
77
91
 
78
92
  - name: Upload native wheels
79
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
93
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
80
94
  with:
81
95
  name: native-${{ matrix.os }}-${{ matrix.target }}
82
96
  path: rust/dist/*.whl
@@ -102,7 +116,7 @@ jobs:
102
116
  rm rust/Cargo.toml.bak
103
117
 
104
118
  - name: Set up uv
105
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
119
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
106
120
  with:
107
121
  enable-cache: false
108
122
 
@@ -110,7 +124,7 @@ jobs:
110
124
  run: uvx maturin sdist --manifest-path rust/Cargo.toml --out dist
111
125
 
112
126
  - name: Upload native source distribution
113
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
127
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
114
128
  with:
115
129
  name: native-sdist
116
130
  path: dist/*.tar.gz
@@ -128,7 +142,7 @@ jobs:
128
142
  persist-credentials: false
129
143
 
130
144
  - name: Set up uv
131
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
145
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
132
146
  with:
133
147
  enable-cache: false
134
148
 
@@ -142,7 +156,7 @@ jobs:
142
156
  unzip -p dist/*.whl '*/METADATA' | grep -Fx "Requires-Dist: asanypath-native~=${VERSION}"
143
157
 
144
158
  - name: Upload Python distributions
145
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
159
+ uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7
146
160
  with:
147
161
  name: python-distributions
148
162
  path: dist/*
@@ -158,7 +172,7 @@ jobs:
158
172
  id-token: write
159
173
  steps:
160
174
  - name: Download native distributions
161
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
175
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
162
176
  with:
163
177
  pattern: native-*
164
178
  path: dist
@@ -179,7 +193,7 @@ jobs:
179
193
  id-token: write
180
194
  steps:
181
195
  - name: Download Python distributions
182
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
196
+ uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8
183
197
  with:
184
198
  name: python-distributions
185
199
  path: dist
@@ -30,7 +30,7 @@ jobs:
30
30
  strategy:
31
31
  fail-fast: true
32
32
  matrix:
33
- python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
33
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
34
34
  steps:
35
35
  - name: Checkout repository
36
36
  uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
@@ -44,7 +44,7 @@ jobs:
44
44
  python-version: ${{ matrix.python-version }}
45
45
 
46
46
  - name: Set up uv
47
- uses: astral-sh/setup-uv@c18668ad3cf93ea998bef934396af7bb5c839dc7 # v10.2.0
47
+ uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0
48
48
 
49
49
  - name: Ruff checks
50
50
  run: uvx ruff check src tests && uvx ruff format --check src tests
@@ -31,7 +31,7 @@ cargo check --manifest-path rust/Cargo.toml
31
31
  ## Pull Requests
32
32
 
33
33
  Keep pull requests focused and include tests for changed behavior. Preserve
34
- compatibility with Python 3.10 through 3.14. Describe user-visible changes and
34
+ compatibility with Python 3.10 through 3.15. Describe user-visible changes and
35
35
  document new configuration, credentials, or backend behavior in the README.
36
36
 
37
37
  Do not include credentials, private endpoints, customer data, or other
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: asanypath
3
- Version: 2.4.0
3
+ Version: 2.6.0
4
4
  Summary: Async pathlib for local and cloud storage
5
5
  License-Expression: MIT
6
6
  License-File: LICENSE
@@ -16,10 +16,11 @@ Classifier: Programming Language :: Python :: 3.11
16
16
  Classifier: Programming Language :: Python :: 3.12
17
17
  Classifier: Programming Language :: Python :: 3.13
18
18
  Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Programming Language :: Python :: 3.15
19
20
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
21
  Requires-Python: >=3.10
21
22
  Requires-Dist: anyio>=4
22
- Requires-Dist: asanypath-native~=2.4.0
23
+ Requires-Dist: asanypath-native~=2.6.0
23
24
  Requires-Dist: msgspec>=0.22.0
24
25
  Requires-Dist: yarl>=1.2
25
26
  Provides-Extra: all
@@ -72,7 +73,7 @@ locally before connecting to a cloud account.
72
73
 
73
74
  ## Requirements
74
75
 
75
- - Python 3.10 through 3.14.
76
+ - Python 3.10 through 3.15.
76
77
  - Access credentials for each cloud service that your application uses.
77
78
 
78
79
  S3 authentication accepts explicit keys or uses the AWS SDK credential provider
@@ -162,6 +163,30 @@ update it. It is not necessarily the final per-request URL (for example, after
162
163
  bucket addressing or redirects). Local, HTTP, SSH and FTP paths do not expose
163
164
  this property.
164
165
 
166
+ ### Artifactory URLs
167
+
168
+ `art://host/artifactory/repo/path` addresses Artifactory directly. With
169
+ `ARTIFACTORY_BASE_URL` set, e.g. to `https://artifacts.example.com/artifactory`:
170
+
171
+ - `art://repo/path` (and `art://` for the repository list) expand to it;
172
+ - `https://` URLs under it are Artifactory paths as well, using the Artifactory
173
+ API and token;
174
+ - `ARTIFACTORY_IDENTITY_TOKEN` is sent to it and nowhere else.
175
+
176
+ An `https://` URL on a host that is not configured stays plain HTTPS and is
177
+ read without a token. When one Artifactory answers under several host names,
178
+ list them all, comma-separated; `art://` shorthand expands to the first:
179
+
180
+ ```bash
181
+ export ARTIFACTORY_BASE_URL=https://artifacts.example.com/artifactory,https://artifactory.example.com/artifactory
182
+ ```
183
+
184
+ Only listed host names count, never DNS aliases. Without a token (`token=`,
185
+ `ARTIFACTORY_IDENTITY_TOKEN`, the keyring or the JFrog CLI config) requests are
186
+ anonymous, which is enough for repositories open to anonymous reads. A
187
+ configured token is always sent: an expired one fails instead of falling back
188
+ to anonymous access.
189
+
165
190
  ### Copy and recursive delete
166
191
 
167
192
  ```python
@@ -175,6 +200,13 @@ await src.copy(dst, recursive=True)
175
200
  await path.rmdir(recursive=True)
176
201
  ```
177
202
 
203
+ On S3, GCS and Azure a recursive delete lists the prefix once at every depth
204
+ and deletes each key below it, directory marker objects included, in bulk: S3
205
+ with one `DeleteObjects` request per 1,000 keys, GCS with JSON batch requests
206
+ of 100 and Azure with Blob Batch requests of 256. Keys a request URL could
207
+ misaddress (`.`/`..` segments, `\`, `%`, `?`, `#`, control characters) are left
208
+ in place and logged. On Artifactory a folder is deleted with one request.
209
+
178
210
  Copies automatically use spare transfer concurrency for large ranged reads.
179
211
  The default target is 8 streams, with an 8 MiB minimum range size and at most
180
212
  8 range streams per file. Files smaller than 16 MiB stay single-stream. When
@@ -330,8 +362,9 @@ service they are not sent at all, and a warning names the missing setting:
330
362
  `HTTP_AUTH_URL`, e.g. `HTTP_AUTH_URL=https://files.example.com`. On a
331
363
  redirect to another scheme, host or port, only non-credential headers
332
364
  (`Range`, `Accept`, conditional headers, ...) are forwarded.
333
- - **Artifactory:** `ARTIFACTORY_IDENTITY_TOKEN` is only used for the service in
334
- `ARTIFACTORY_BASE_URL` (or `ART_BASE_URL`). A JFrog CLI server token is only
365
+ - **Artifactory:** `ARTIFACTORY_IDENTITY_TOKEN` is only used for the services in
366
+ `ARTIFACTORY_BASE_URL` (or `ART_BASE_URL`), a comma-separated list when one
367
+ Artifactory answers under several host names. A JFrog CLI server token is only
335
368
  used for that server's own origin.
336
369
  - **SSH:** host keys are checked like OpenSSH. `StrictHostKeyChecking`
337
370
  (`yes`, `ask`, `accept-new`, `no`) and `UserKnownHostsFile` are read from
@@ -506,6 +539,15 @@ asanypath cp /local/file.txt s3://bucket/file.txt
506
539
  # Copy cloud → local
507
540
  asanypath cp s3://bucket/file.txt /local/file.txt
508
541
 
542
+ # Add repeatable headers to HTTP requests
543
+ asanypath cat https://example.com/data \
544
+ -o 'headers=Accept: application/json' \
545
+ -o 'headers=X-View: compact'
546
+
547
+ # Scope headers to only one side of a copy
548
+ asanypath cp https://example.com/data /local/data \
549
+ --src-option 'headers=Accept: application/json'
550
+
509
551
  # Allow 32 concurrent files; fill spare capacity toward 8 streams for large files
510
552
  asanypath cp -r s3://bucket/data/ ./data/ -j 32 --concurrency-floor 8
511
553
 
@@ -535,11 +577,19 @@ asanypath auth show
535
577
  asanypath auth show s3://bucket
536
578
  ```
537
579
 
580
+ Backend options can omit the scheme prefix when it can be inferred from each
581
+ path; for example, `-o headers='X-Name: value'`. HTTP headers can be repeated
582
+ with `-o`, `--src-option`, and `--dst-option`; each value uses `NAME: VALUE`
583
+ syntax. Transport-managed headers such as `Host` and
584
+ `Content-Length` are rejected. Header values passed on the command line may be
585
+ visible in shell history or process listings, so use the HTTP auth environment
586
+ variables for secrets.
587
+
538
588
  ### Shell Completions (Beta)
539
589
 
540
590
  Path completions are available for all subcommands that take cloud paths: `ls`, `cp`, `mv`, `rm`, `stat`, `cat`, `exists`, `touch`, `checksums`, `mkdir`, `presign`, and `sync`.
541
591
 
542
- Completions complete cloud paths up to 50 items deep with shallow enumeration (immediate children only), and are cached for 30 seconds per prefix to avoid redundant backend requests.
592
+ Completion lists the immediate children of the typed directory (directories end in `/`; dotfiles appear once you type the `.`), gives up after 5 seconds, and offers URI schemes (`s3://`, `ssh://`, …) as you type them. scp-style `host:path` completes too, for hosts that are aliases in your ssh config. Local paths use the shell's own file completion. Set `ASANYPATH_COMPLETION_DEBUG=1` to see why a completion came back empty.
543
593
 
544
594
  **Bash Setup:**
545
595
 
@@ -599,6 +649,44 @@ asanypath rm s3://[TAB] # Lists buckets
599
649
 
600
650
  Completion respects environment variables for cloud credentials (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` for S3). Bearer token auth (for custom endpoints) is not supported in completions; only env var-based auth is used.
601
651
 
652
+ ### Path options in your own click CLI
653
+
654
+ `click.Path` validates with `os.stat()`, so with `path_type=AsAnyPath` its
655
+ `exists`, `file_okay` and `dir_okay` checks are skipped for remote URIs
656
+ (`exists=False`) or always fail (`exists=True`). Use `ClickPath` instead
657
+ (requires the `cli` extra):
658
+
659
+ ```python
660
+ import click
661
+ from asanypath.click import ClickPath
662
+
663
+ @click.command()
664
+ @click.option("--model", type=ClickPath(exists=True, dir_okay=False))
665
+ @click.option("--out", type=ClickPath(file_okay=False))
666
+ def main(model, out):
667
+ ... # model and out are sync AsAnyPath objects
668
+ ```
669
+
670
+ `ClickPath` takes the same arguments as `click.Path`; `path_type` defaults to
671
+ `asanypath.sync.AsAnyPath`. Local paths (including `file://` URIs) behave exactly
672
+ like `click.Path`. scp-style `[user@]host:path` becomes an `ssh://` path when
673
+ `host` is an alias in your ssh config (a `Host` block with its own `HostName`).
674
+ Remote paths are checked with `exists()`, `is_dir()` and
675
+ `is_file()` while arguments are parsed:
676
+
677
+ - `file_okay=False` / `dir_okay=False` reject a path only when it is exclusively
678
+ the disallowed kind; an object-store key can be both a file and a directory.
679
+ - `readable`, `writable`, `executable` and `resolve_path` apply to local paths only.
680
+ - If the backend cannot be queried (credentials, network, unsupported protocol),
681
+ `exists=True` reports the error and `exists=False` accepts the path unchecked.
682
+
683
+ Shell completion of your CLI completes remote paths the same way as the
684
+ `asanypath` CLI (see [Shell Completions](#shell-completions-beta)), with click's
685
+ usual setup, e.g. `eval "$(_MYPROG_COMPLETE=bash_source myprog)"`. Importing
686
+ `asanypath.click` registers `asanypath.click.BashComplete` for bash, which keeps
687
+ URIs one word although bash splits words at `:` and `@`, and leaves no trailing
688
+ space after a directory. With `file_okay=False` only directories are offered.
689
+
602
690
  ## Benchmarks
603
691
 
604
692
  Multi-backend benchmark suite in `scripts/bench.py` compares asanypath against
@@ -632,6 +720,17 @@ This compares asanypath and boto3 using one shared request budget per client.
632
720
  It warms up each case, reports JSON timings and MiB/s, verifies uploaded contents
633
721
  outside the timed interval, and deletes only the uniquely named benchmark
634
722
  objects it created. Both clients use normal AWS credentials (or `--profile`).
723
+
724
+ For recursive deletes, `scripts/bench_rmtree.py` uploads a generated tree under
725
+ a fresh prefix, times `rmdir(recursive=True)` and checks nothing is left, e.g.
726
+ against the MinIO emulator:
727
+
728
+ ```bash
729
+ AWS_ENDPOINT_URL=http://localhost:9000 AWS_ACCESS_KEY_ID=minioadmin \
730
+ AWS_SECRET_ACCESS_KEY=minioadmin AWS_REGION=us-east-1 \
731
+ uv run python scripts/bench_rmtree.py s3://bench-asanypath/rmtree-bench \
732
+ --dirs 10 --subdirs 10 --files 100
733
+ ```
635
734
  Run with one large shard and again with several representative shards; results
636
735
  from a local test server are not evidence of production endpoint throughput.
637
736
 
@@ -880,6 +979,20 @@ translating provider IAM or ACL models.
880
979
  - `name`, `stem`, `suffix`, `parent`, `parts`
881
980
  - `protocol` — URI scheme (`s3`, `gs`, `az`, `art`, `file`, …)
882
981
 
982
+ ### Relative paths
983
+
984
+ A relative remote path has no bucket or host, so `relative_to()` on a remote path
985
+ returns a `pathlib.PurePosixPath`. Join it onto any path with `/`, e.g. to mirror a
986
+ tree across backends:
987
+
988
+ ```python
989
+ for src in src_root.rglob("*"):
990
+ await src.copy(dst_root / src.relative_to(src_root))
991
+ ```
992
+
993
+ `walk_up=True` returns `..` segments within the same bucket/host; paths with a
994
+ different bucket/host, scheme, or a relative `other` raise `ValueError`.
995
+
883
996
  ## Development
884
997
 
885
998
  Run these commands in a POSIX-compatible shell such as Bash or Zsh:
@@ -16,7 +16,7 @@ locally before connecting to a cloud account.
16
16
 
17
17
  ## Requirements
18
18
 
19
- - Python 3.10 through 3.14.
19
+ - Python 3.10 through 3.15.
20
20
  - Access credentials for each cloud service that your application uses.
21
21
 
22
22
  S3 authentication accepts explicit keys or uses the AWS SDK credential provider
@@ -106,6 +106,30 @@ update it. It is not necessarily the final per-request URL (for example, after
106
106
  bucket addressing or redirects). Local, HTTP, SSH and FTP paths do not expose
107
107
  this property.
108
108
 
109
+ ### Artifactory URLs
110
+
111
+ `art://host/artifactory/repo/path` addresses Artifactory directly. With
112
+ `ARTIFACTORY_BASE_URL` set, e.g. to `https://artifacts.example.com/artifactory`:
113
+
114
+ - `art://repo/path` (and `art://` for the repository list) expand to it;
115
+ - `https://` URLs under it are Artifactory paths as well, using the Artifactory
116
+ API and token;
117
+ - `ARTIFACTORY_IDENTITY_TOKEN` is sent to it and nowhere else.
118
+
119
+ An `https://` URL on a host that is not configured stays plain HTTPS and is
120
+ read without a token. When one Artifactory answers under several host names,
121
+ list them all, comma-separated; `art://` shorthand expands to the first:
122
+
123
+ ```bash
124
+ export ARTIFACTORY_BASE_URL=https://artifacts.example.com/artifactory,https://artifactory.example.com/artifactory
125
+ ```
126
+
127
+ Only listed host names count, never DNS aliases. Without a token (`token=`,
128
+ `ARTIFACTORY_IDENTITY_TOKEN`, the keyring or the JFrog CLI config) requests are
129
+ anonymous, which is enough for repositories open to anonymous reads. A
130
+ configured token is always sent: an expired one fails instead of falling back
131
+ to anonymous access.
132
+
109
133
  ### Copy and recursive delete
110
134
 
111
135
  ```python
@@ -119,6 +143,13 @@ await src.copy(dst, recursive=True)
119
143
  await path.rmdir(recursive=True)
120
144
  ```
121
145
 
146
+ On S3, GCS and Azure a recursive delete lists the prefix once at every depth
147
+ and deletes each key below it, directory marker objects included, in bulk: S3
148
+ with one `DeleteObjects` request per 1,000 keys, GCS with JSON batch requests
149
+ of 100 and Azure with Blob Batch requests of 256. Keys a request URL could
150
+ misaddress (`.`/`..` segments, `\`, `%`, `?`, `#`, control characters) are left
151
+ in place and logged. On Artifactory a folder is deleted with one request.
152
+
122
153
  Copies automatically use spare transfer concurrency for large ranged reads.
123
154
  The default target is 8 streams, with an 8 MiB minimum range size and at most
124
155
  8 range streams per file. Files smaller than 16 MiB stay single-stream. When
@@ -274,8 +305,9 @@ service they are not sent at all, and a warning names the missing setting:
274
305
  `HTTP_AUTH_URL`, e.g. `HTTP_AUTH_URL=https://files.example.com`. On a
275
306
  redirect to another scheme, host or port, only non-credential headers
276
307
  (`Range`, `Accept`, conditional headers, ...) are forwarded.
277
- - **Artifactory:** `ARTIFACTORY_IDENTITY_TOKEN` is only used for the service in
278
- `ARTIFACTORY_BASE_URL` (or `ART_BASE_URL`). A JFrog CLI server token is only
308
+ - **Artifactory:** `ARTIFACTORY_IDENTITY_TOKEN` is only used for the services in
309
+ `ARTIFACTORY_BASE_URL` (or `ART_BASE_URL`), a comma-separated list when one
310
+ Artifactory answers under several host names. A JFrog CLI server token is only
279
311
  used for that server's own origin.
280
312
  - **SSH:** host keys are checked like OpenSSH. `StrictHostKeyChecking`
281
313
  (`yes`, `ask`, `accept-new`, `no`) and `UserKnownHostsFile` are read from
@@ -450,6 +482,15 @@ asanypath cp /local/file.txt s3://bucket/file.txt
450
482
  # Copy cloud → local
451
483
  asanypath cp s3://bucket/file.txt /local/file.txt
452
484
 
485
+ # Add repeatable headers to HTTP requests
486
+ asanypath cat https://example.com/data \
487
+ -o 'headers=Accept: application/json' \
488
+ -o 'headers=X-View: compact'
489
+
490
+ # Scope headers to only one side of a copy
491
+ asanypath cp https://example.com/data /local/data \
492
+ --src-option 'headers=Accept: application/json'
493
+
453
494
  # Allow 32 concurrent files; fill spare capacity toward 8 streams for large files
454
495
  asanypath cp -r s3://bucket/data/ ./data/ -j 32 --concurrency-floor 8
455
496
 
@@ -479,11 +520,19 @@ asanypath auth show
479
520
  asanypath auth show s3://bucket
480
521
  ```
481
522
 
523
+ Backend options can omit the scheme prefix when it can be inferred from each
524
+ path; for example, `-o headers='X-Name: value'`. HTTP headers can be repeated
525
+ with `-o`, `--src-option`, and `--dst-option`; each value uses `NAME: VALUE`
526
+ syntax. Transport-managed headers such as `Host` and
527
+ `Content-Length` are rejected. Header values passed on the command line may be
528
+ visible in shell history or process listings, so use the HTTP auth environment
529
+ variables for secrets.
530
+
482
531
  ### Shell Completions (Beta)
483
532
 
484
533
  Path completions are available for all subcommands that take cloud paths: `ls`, `cp`, `mv`, `rm`, `stat`, `cat`, `exists`, `touch`, `checksums`, `mkdir`, `presign`, and `sync`.
485
534
 
486
- Completions complete cloud paths up to 50 items deep with shallow enumeration (immediate children only), and are cached for 30 seconds per prefix to avoid redundant backend requests.
535
+ Completion lists the immediate children of the typed directory (directories end in `/`; dotfiles appear once you type the `.`), gives up after 5 seconds, and offers URI schemes (`s3://`, `ssh://`, …) as you type them. scp-style `host:path` completes too, for hosts that are aliases in your ssh config. Local paths use the shell's own file completion. Set `ASANYPATH_COMPLETION_DEBUG=1` to see why a completion came back empty.
487
536
 
488
537
  **Bash Setup:**
489
538
 
@@ -543,6 +592,44 @@ asanypath rm s3://[TAB] # Lists buckets
543
592
 
544
593
  Completion respects environment variables for cloud credentials (e.g., `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY` for S3). Bearer token auth (for custom endpoints) is not supported in completions; only env var-based auth is used.
545
594
 
595
+ ### Path options in your own click CLI
596
+
597
+ `click.Path` validates with `os.stat()`, so with `path_type=AsAnyPath` its
598
+ `exists`, `file_okay` and `dir_okay` checks are skipped for remote URIs
599
+ (`exists=False`) or always fail (`exists=True`). Use `ClickPath` instead
600
+ (requires the `cli` extra):
601
+
602
+ ```python
603
+ import click
604
+ from asanypath.click import ClickPath
605
+
606
+ @click.command()
607
+ @click.option("--model", type=ClickPath(exists=True, dir_okay=False))
608
+ @click.option("--out", type=ClickPath(file_okay=False))
609
+ def main(model, out):
610
+ ... # model and out are sync AsAnyPath objects
611
+ ```
612
+
613
+ `ClickPath` takes the same arguments as `click.Path`; `path_type` defaults to
614
+ `asanypath.sync.AsAnyPath`. Local paths (including `file://` URIs) behave exactly
615
+ like `click.Path`. scp-style `[user@]host:path` becomes an `ssh://` path when
616
+ `host` is an alias in your ssh config (a `Host` block with its own `HostName`).
617
+ Remote paths are checked with `exists()`, `is_dir()` and
618
+ `is_file()` while arguments are parsed:
619
+
620
+ - `file_okay=False` / `dir_okay=False` reject a path only when it is exclusively
621
+ the disallowed kind; an object-store key can be both a file and a directory.
622
+ - `readable`, `writable`, `executable` and `resolve_path` apply to local paths only.
623
+ - If the backend cannot be queried (credentials, network, unsupported protocol),
624
+ `exists=True` reports the error and `exists=False` accepts the path unchecked.
625
+
626
+ Shell completion of your CLI completes remote paths the same way as the
627
+ `asanypath` CLI (see [Shell Completions](#shell-completions-beta)), with click's
628
+ usual setup, e.g. `eval "$(_MYPROG_COMPLETE=bash_source myprog)"`. Importing
629
+ `asanypath.click` registers `asanypath.click.BashComplete` for bash, which keeps
630
+ URIs one word although bash splits words at `:` and `@`, and leaves no trailing
631
+ space after a directory. With `file_okay=False` only directories are offered.
632
+
546
633
  ## Benchmarks
547
634
 
548
635
  Multi-backend benchmark suite in `scripts/bench.py` compares asanypath against
@@ -576,6 +663,17 @@ This compares asanypath and boto3 using one shared request budget per client.
576
663
  It warms up each case, reports JSON timings and MiB/s, verifies uploaded contents
577
664
  outside the timed interval, and deletes only the uniquely named benchmark
578
665
  objects it created. Both clients use normal AWS credentials (or `--profile`).
666
+
667
+ For recursive deletes, `scripts/bench_rmtree.py` uploads a generated tree under
668
+ a fresh prefix, times `rmdir(recursive=True)` and checks nothing is left, e.g.
669
+ against the MinIO emulator:
670
+
671
+ ```bash
672
+ AWS_ENDPOINT_URL=http://localhost:9000 AWS_ACCESS_KEY_ID=minioadmin \
673
+ AWS_SECRET_ACCESS_KEY=minioadmin AWS_REGION=us-east-1 \
674
+ uv run python scripts/bench_rmtree.py s3://bench-asanypath/rmtree-bench \
675
+ --dirs 10 --subdirs 10 --files 100
676
+ ```
579
677
  Run with one large shard and again with several representative shards; results
580
678
  from a local test server are not evidence of production endpoint throughput.
581
679
 
@@ -824,6 +922,20 @@ translating provider IAM or ACL models.
824
922
  - `name`, `stem`, `suffix`, `parent`, `parts`
825
923
  - `protocol` — URI scheme (`s3`, `gs`, `az`, `art`, `file`, …)
826
924
 
925
+ ### Relative paths
926
+
927
+ A relative remote path has no bucket or host, so `relative_to()` on a remote path
928
+ returns a `pathlib.PurePosixPath`. Join it onto any path with `/`, e.g. to mirror a
929
+ tree across backends:
930
+
931
+ ```python
932
+ for src in src_root.rglob("*"):
933
+ await src.copy(dst_root / src.relative_to(src_root))
934
+ ```
935
+
936
+ `walk_up=True` returns `..` segments within the same bucket/host; paths with a
937
+ different bucket/host, scheme, or a relative `other` raise `ValueError`.
938
+
827
939
  ## Development
828
940
 
829
941
  Run these commands in a POSIX-compatible shell such as Bash or Zsh:
@@ -9,6 +9,11 @@ fallback-version = "0.0.0-dev"
9
9
  [tool.hatch.build.hooks.vcs]
10
10
  version-file = "src/asanypath/_version.py"
11
11
 
12
+ [tool.uv]
13
+ # filelock (pre-commit -> virtualenv) has security fixes only from 4.2.1, which
14
+ # needs Python 3.11; Python 3.10 keeps the newest release it supports.
15
+ constraint-dependencies = ["filelock>=4.2.1; python_version >= '3.11'"]
16
+
12
17
  [[tool.uv.index]]
13
18
  url = "https://pypi.org/simple"
14
19
  default = true
@@ -43,6 +48,7 @@ classifiers = [
43
48
  "Programming Language :: Python :: 3.12",
44
49
  "Programming Language :: Python :: 3.13",
45
50
  "Programming Language :: Python :: 3.14",
51
+ "Programming Language :: Python :: 3.15",
46
52
  "Topic :: Software Development :: Libraries :: Python Modules",
47
53
  ]
48
54
  keywords = ["async", "cloud-storage", "pathlib", "storage"]
@@ -0,0 +1,80 @@
1
+ # Copyright (C) 2026 Axis Communications AB, Lund, Sweden
2
+ #
3
+ # Use of this source code is governed by an MIT-style
4
+ # license that can be found in the LICENSE file or at
5
+ # https://opensource.org/licenses/MIT.
6
+
7
+ """Time recursive deletes (``rmdir(recursive=True)``) of a generated tree.
8
+
9
+ Each round uploads ``dirs x subdirs x files`` small objects under a fresh,
10
+ unique prefix below DESTINATION (untimed), deletes that prefix recursively
11
+ (timed), and checks that nothing is left. Uses the backend's normal
12
+ credential and endpoint resolution, e.g. for the emulators in compose.yml:
13
+
14
+ AWS_ENDPOINT_URL=http://localhost:9000 AWS_ACCESS_KEY_ID=minioadmin \\
15
+ AWS_SECRET_ACCESS_KEY=minioadmin AWS_REGION=us-east-1 \\
16
+ uv run python scripts/bench_rmtree.py s3://bench-asanypath/rmtree-bench
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import argparse
22
+ import asyncio
23
+ import statistics
24
+ import time
25
+ from uuid import uuid4
26
+
27
+ from asanypath import AsAnyPath
28
+
29
+
30
+ async def build(root, dirs: int, subdirs: int, files: int, payload: bytes, workers: int) -> int:
31
+ limit = asyncio.Semaphore(workers)
32
+
33
+ async def put(path) -> None:
34
+ async with limit:
35
+ await path.write_bytes(payload)
36
+
37
+ paths = [
38
+ root / f"d{d:03d}" / f"s{s:03d}" / f"f{f:04d}.bin"
39
+ for d in range(dirs)
40
+ for s in range(subdirs)
41
+ for f in range(files)
42
+ ]
43
+ await asyncio.gather(*(put(p) for p in paths))
44
+ return len(paths)
45
+
46
+
47
+ async def main() -> None:
48
+ parser = argparse.ArgumentParser(
49
+ description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
50
+ )
51
+ parser.add_argument("destination", help="Prefix to create test trees under")
52
+ parser.add_argument("--dirs", type=int, default=10, help="Top-level directories")
53
+ parser.add_argument("--subdirs", type=int, default=5, help="Subdirectories per directory")
54
+ parser.add_argument("--files", type=int, default=20, help="Files per subdirectory")
55
+ parser.add_argument("--size", type=int, default=16, help="Bytes per file")
56
+ parser.add_argument("--rounds", type=int, default=3)
57
+ parser.add_argument("--workers", type=int, default=64, help="Concurrent uploads in setup")
58
+ args = parser.parse_args()
59
+
60
+ base = AsAnyPath(args.destination)
61
+ payload = b"\0" * args.size
62
+ times = []
63
+ for round_no in range(1, args.rounds + 1):
64
+ root = base / f"run-{uuid4().hex[:12]}"
65
+ count = await build(root, args.dirs, args.subdirs, args.files, payload, args.workers)
66
+ started = time.perf_counter()
67
+ await root.rmdir(recursive=True)
68
+ elapsed = time.perf_counter() - started
69
+ if await root.exists():
70
+ raise SystemExit(f"{root} still exists after rmdir(recursive=True)")
71
+ times.append(elapsed)
72
+ print(f"round {round_no}: {count} objects in {elapsed:.3f}s ({count / elapsed:.0f}/s)")
73
+ print(
74
+ f"rmtree {args.dirs}x{args.subdirs}x{args.files}: median {statistics.median(times):.3f}s"
75
+ f" min {min(times):.3f}s max {max(times):.3f}s"
76
+ )
77
+
78
+
79
+ if __name__ == "__main__":
80
+ asyncio.run(main())
@@ -17,6 +17,7 @@ from asanypath.asanypath import (
17
17
  )
18
18
  from asanypath.exceptions import (
19
19
  AsAnyPathError,
20
+ AuthenticationError,
20
21
  InvalidPathError,
21
22
  PathIsADirectoryError,
22
23
  PathNotADirectoryError,
@@ -102,6 +103,7 @@ __all__ = [
102
103
  "register_protocol",
103
104
  "list_protocols",
104
105
  "AsAnyPathError",
106
+ "AuthenticationError",
105
107
  "InvalidPathError",
106
108
  "UnsupportedProtocolError",
107
109
  "UnsupportedProtocolPath",