asanypath 2.5.0__tar.gz → 2.6.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.
Files changed (89) hide show
  1. {asanypath-2.5.0 → asanypath-2.6.1}/.github/workflows/publish.yml +24 -10
  2. {asanypath-2.5.0 → asanypath-2.6.1}/.github/workflows/unittests.yml +3 -3
  3. {asanypath-2.5.0 → asanypath-2.6.1}/CONTRIBUTING.md +1 -1
  4. {asanypath-2.5.0 → asanypath-2.6.1}/PKG-INFO +95 -7
  5. {asanypath-2.5.0 → asanypath-2.6.1}/README.md +92 -5
  6. {asanypath-2.5.0 → asanypath-2.6.1}/pyproject.toml +6 -0
  7. asanypath-2.6.1/scripts/bench_rmtree.py +80 -0
  8. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/__init__.py +2 -0
  9. asanypath-2.6.1/src/asanypath/_backend_opts.py +115 -0
  10. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/_version.py +2 -2
  11. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/artifactory.py +71 -25
  12. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/asanypath.py +11 -15
  13. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/asanypath.pyi +4 -2
  14. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/azure.py +6 -0
  15. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/cli.py +15 -364
  16. asanypath-2.6.1/src/asanypath/click.py +317 -0
  17. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/cloud.py +33 -26
  18. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/common.py +119 -59
  19. asanypath-2.6.1/src/asanypath/exceptions.py +79 -0
  20. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/gcs.py +6 -0
  21. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/http.py +50 -12
  22. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/s3.py +6 -0
  23. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_artifactory.py +126 -4
  24. asanypath-2.6.1/tests/test_auth_errors.py +201 -0
  25. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_backend_options.py +79 -2
  26. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_cli.py +0 -177
  27. asanypath-2.6.1/tests/test_click.py +459 -0
  28. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_cloudpathmixin.py +67 -15
  29. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_commonpathmixin.py +140 -5
  30. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_http_auth.py +70 -0
  31. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_isolation.py +25 -20
  32. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_local.py +21 -0
  33. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_syncpath.py +21 -0
  34. asanypath-2.5.0/src/asanypath/_backend_opts.py +0 -61
  35. asanypath-2.5.0/src/asanypath/click.py +0 -108
  36. asanypath-2.5.0/src/asanypath/exceptions.py +0 -43
  37. asanypath-2.5.0/tests/test_click.py +0 -227
  38. {asanypath-2.5.0 → asanypath-2.6.1}/.copilot/skills/async-python-lib/SKILL.md +0 -0
  39. {asanypath-2.5.0 → asanypath-2.6.1}/.copilot/skills/gitguro/SKILL.md +0 -0
  40. {asanypath-2.5.0 → asanypath-2.6.1}/.github/CODEOWNERS +0 -0
  41. {asanypath-2.5.0 → asanypath-2.6.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  42. {asanypath-2.5.0 → asanypath-2.6.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  43. {asanypath-2.5.0 → asanypath-2.6.1}/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  44. {asanypath-2.5.0 → asanypath-2.6.1}/.github/dependabot.yml +0 -0
  45. {asanypath-2.5.0 → asanypath-2.6.1}/.gitignore +0 -0
  46. {asanypath-2.5.0 → asanypath-2.6.1}/.pre-commit-config.yaml +0 -0
  47. {asanypath-2.5.0 → asanypath-2.6.1}/CODE_OF_CONDUCT.md +0 -0
  48. {asanypath-2.5.0 → asanypath-2.6.1}/LICENSE +0 -0
  49. {asanypath-2.5.0 → asanypath-2.6.1}/asanypath.png +0 -0
  50. {asanypath-2.5.0 → asanypath-2.6.1}/compose.yml +0 -0
  51. {asanypath-2.5.0 → asanypath-2.6.1}/hatch_build.py +0 -0
  52. {asanypath-2.5.0 → asanypath-2.6.1}/scripts/bench.py +0 -0
  53. {asanypath-2.5.0 → asanypath-2.6.1}/scripts/bench_upload.py +0 -0
  54. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/__init__.pyi +0 -0
  55. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/_credstore.py +0 -0
  56. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/_prompt.py +0 -0
  57. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/_resume.py +0 -0
  58. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/_transfer.py +0 -0
  59. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/batcher.py +0 -0
  60. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/cache.py +0 -0
  61. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/ftp.py +0 -0
  62. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/local.py +0 -0
  63. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/options.py +0 -0
  64. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/py.typed +0 -0
  65. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/ssh.py +0 -0
  66. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/sync.py +0 -0
  67. {asanypath-2.5.0 → asanypath-2.6.1}/src/asanypath/unsupported.py +0 -0
  68. {asanypath-2.5.0 → asanypath-2.6.1}/tests/__init__.py +0 -0
  69. {asanypath-2.5.0 → asanypath-2.6.1}/tests/conftest.py +0 -0
  70. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_asanypath.py +0 -0
  71. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_azure.py +0 -0
  72. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_batcher.py +0 -0
  73. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_cache.py +0 -0
  74. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_credstore.py +0 -0
  75. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_endpoints.py +0 -0
  76. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_ftp.py +0 -0
  77. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_gcs.py +0 -0
  78. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_http.py +0 -0
  79. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_options.py +0 -0
  80. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_py_typed.py +0 -0
  81. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_resume.py +0 -0
  82. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_s3.py +0 -0
  83. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_scandir.py +0 -0
  84. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_ssh.py +0 -0
  85. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_ssh_hostkeys.py +0 -0
  86. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_sync.py +0 -0
  87. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_transport_hardening.py +0 -0
  88. {asanypath-2.5.0 → asanypath-2.6.1}/tests/test_unsupported_path.py +0 -0
  89. {asanypath-2.5.0 → asanypath-2.6.1}/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@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # 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@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
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@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
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,14 +172,14 @@ 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
165
179
  merge-multiple: true
166
180
 
167
181
  - name: Publish native distribution
168
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
182
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
169
183
  with:
170
184
  packages-dir: dist
171
185
 
@@ -179,12 +193,12 @@ 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
186
200
 
187
201
  - name: Publish Python distribution
188
- uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # release/v1
202
+ uses: pypa/gh-action-pypi-publish@7245906fb61fa33a13554f9d5fb856fe61758086 # release/v1
189
203
  with:
190
204
  packages-dir: 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
@@ -39,12 +39,12 @@ jobs:
39
39
  persist-credentials: false
40
40
 
41
41
  - name: Set up Python
42
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7
42
+ uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7
43
43
  with:
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@07a047e608db84b3d8c06cd9a7c7dcc9c355c18e # v10.3.2
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.5.0
3
+ Version: 2.6.1
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.5.0
23
+ Requires-Dist: asanypath-native~=2.6.1
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,34 @@ 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
+
190
+ Artifactory `exists()`, `is_file()` and `is_dir()` return `False` for missing
191
+ paths, but propagate authentication and permission errors. CLI source checks
192
+ report those errors rather than claiming the file does not exist.
193
+
165
194
  ### Copy and recursive delete
166
195
 
167
196
  ```python
@@ -175,6 +204,13 @@ await src.copy(dst, recursive=True)
175
204
  await path.rmdir(recursive=True)
176
205
  ```
177
206
 
207
+ On S3, GCS and Azure a recursive delete lists the prefix once at every depth
208
+ and deletes each key below it, directory marker objects included, in bulk: S3
209
+ with one `DeleteObjects` request per 1,000 keys, GCS with JSON batch requests
210
+ of 100 and Azure with Blob Batch requests of 256. Keys a request URL could
211
+ misaddress (`.`/`..` segments, `\`, `%`, `?`, `#`, control characters) are left
212
+ in place and logged. On Artifactory a folder is deleted with one request.
213
+
178
214
  Copies automatically use spare transfer concurrency for large ranged reads.
179
215
  The default target is 8 streams, with an 8 MiB minimum range size and at most
180
216
  8 range streams per file. Files smaller than 16 MiB stay single-stream. When
@@ -330,8 +366,9 @@ service they are not sent at all, and a warning names the missing setting:
330
366
  `HTTP_AUTH_URL`, e.g. `HTTP_AUTH_URL=https://files.example.com`. On a
331
367
  redirect to another scheme, host or port, only non-credential headers
332
368
  (`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
369
+ - **Artifactory:** `ARTIFACTORY_IDENTITY_TOKEN` is only used for the services in
370
+ `ARTIFACTORY_BASE_URL` (or `ART_BASE_URL`), a comma-separated list when one
371
+ Artifactory answers under several host names. A JFrog CLI server token is only
335
372
  used for that server's own origin.
336
373
  - **SSH:** host keys are checked like OpenSSH. `StrictHostKeyChecking`
337
374
  (`yes`, `ask`, `accept-new`, `no`) and `UserKnownHostsFile` are read from
@@ -506,6 +543,15 @@ asanypath cp /local/file.txt s3://bucket/file.txt
506
543
  # Copy cloud → local
507
544
  asanypath cp s3://bucket/file.txt /local/file.txt
508
545
 
546
+ # Add repeatable headers to HTTP requests
547
+ asanypath cat https://example.com/data \
548
+ -o 'headers=Accept: application/json' \
549
+ -o 'headers=X-View: compact'
550
+
551
+ # Scope headers to only one side of a copy
552
+ asanypath cp https://example.com/data /local/data \
553
+ --src-option 'headers=Accept: application/json'
554
+
509
555
  # Allow 32 concurrent files; fill spare capacity toward 8 streams for large files
510
556
  asanypath cp -r s3://bucket/data/ ./data/ -j 32 --concurrency-floor 8
511
557
 
@@ -535,11 +581,19 @@ asanypath auth show
535
581
  asanypath auth show s3://bucket
536
582
  ```
537
583
 
584
+ Backend options can omit the scheme prefix when it can be inferred from each
585
+ path; for example, `-o headers='X-Name: value'`. HTTP headers can be repeated
586
+ with `-o`, `--src-option`, and `--dst-option`; each value uses `NAME: VALUE`
587
+ syntax. Transport-managed headers such as `Host` and
588
+ `Content-Length` are rejected. Header values passed on the command line may be
589
+ visible in shell history or process listings, so use the HTTP auth environment
590
+ variables for secrets.
591
+
538
592
  ### Shell Completions (Beta)
539
593
 
540
594
  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
595
 
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.
596
+ 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
597
 
544
598
  **Bash Setup:**
545
599
 
@@ -619,7 +673,9 @@ def main(model, out):
619
673
 
620
674
  `ClickPath` takes the same arguments as `click.Path`; `path_type` defaults to
621
675
  `asanypath.sync.AsAnyPath`. Local paths (including `file://` URIs) behave exactly
622
- like `click.Path`. Remote paths are checked with `exists()`, `is_dir()` and
676
+ like `click.Path`. scp-style `[user@]host:path` becomes an `ssh://` path when
677
+ `host` is an alias in your ssh config (a `Host` block with its own `HostName`).
678
+ Remote paths are checked with `exists()`, `is_dir()` and
623
679
  `is_file()` while arguments are parsed:
624
680
 
625
681
  - `file_okay=False` / `dir_okay=False` reject a path only when it is exclusively
@@ -628,6 +684,13 @@ like `click.Path`. Remote paths are checked with `exists()`, `is_dir()` and
628
684
  - If the backend cannot be queried (credentials, network, unsupported protocol),
629
685
  `exists=True` reports the error and `exists=False` accepts the path unchecked.
630
686
 
687
+ Shell completion of your CLI completes remote paths the same way as the
688
+ `asanypath` CLI (see [Shell Completions](#shell-completions-beta)), with click's
689
+ usual setup, e.g. `eval "$(_MYPROG_COMPLETE=bash_source myprog)"`. Importing
690
+ `asanypath.click` registers `asanypath.click.BashComplete` for bash, which keeps
691
+ URIs one word although bash splits words at `:` and `@`, and leaves no trailing
692
+ space after a directory. With `file_okay=False` only directories are offered.
693
+
631
694
  ## Benchmarks
632
695
 
633
696
  Multi-backend benchmark suite in `scripts/bench.py` compares asanypath against
@@ -661,6 +724,17 @@ This compares asanypath and boto3 using one shared request budget per client.
661
724
  It warms up each case, reports JSON timings and MiB/s, verifies uploaded contents
662
725
  outside the timed interval, and deletes only the uniquely named benchmark
663
726
  objects it created. Both clients use normal AWS credentials (or `--profile`).
727
+
728
+ For recursive deletes, `scripts/bench_rmtree.py` uploads a generated tree under
729
+ a fresh prefix, times `rmdir(recursive=True)` and checks nothing is left, e.g.
730
+ against the MinIO emulator:
731
+
732
+ ```bash
733
+ AWS_ENDPOINT_URL=http://localhost:9000 AWS_ACCESS_KEY_ID=minioadmin \
734
+ AWS_SECRET_ACCESS_KEY=minioadmin AWS_REGION=us-east-1 \
735
+ uv run python scripts/bench_rmtree.py s3://bench-asanypath/rmtree-bench \
736
+ --dirs 10 --subdirs 10 --files 100
737
+ ```
664
738
  Run with one large shard and again with several representative shards; results
665
739
  from a local test server are not evidence of production endpoint throughput.
666
740
 
@@ -909,6 +983,20 @@ translating provider IAM or ACL models.
909
983
  - `name`, `stem`, `suffix`, `parent`, `parts`
910
984
  - `protocol` — URI scheme (`s3`, `gs`, `az`, `art`, `file`, …)
911
985
 
986
+ ### Relative paths
987
+
988
+ A relative remote path has no bucket or host, so `relative_to()` on a remote path
989
+ returns a `pathlib.PurePosixPath`. Join it onto any path with `/`, e.g. to mirror a
990
+ tree across backends:
991
+
992
+ ```python
993
+ for src in src_root.rglob("*"):
994
+ await src.copy(dst_root / src.relative_to(src_root))
995
+ ```
996
+
997
+ `walk_up=True` returns `..` segments within the same bucket/host; paths with a
998
+ different bucket/host, scheme, or a relative `other` raise `ValueError`.
999
+
912
1000
  ## Development
913
1001
 
914
1002
  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,34 @@ 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
+
133
+ Artifactory `exists()`, `is_file()` and `is_dir()` return `False` for missing
134
+ paths, but propagate authentication and permission errors. CLI source checks
135
+ report those errors rather than claiming the file does not exist.
136
+
109
137
  ### Copy and recursive delete
110
138
 
111
139
  ```python
@@ -119,6 +147,13 @@ await src.copy(dst, recursive=True)
119
147
  await path.rmdir(recursive=True)
120
148
  ```
121
149
 
150
+ On S3, GCS and Azure a recursive delete lists the prefix once at every depth
151
+ and deletes each key below it, directory marker objects included, in bulk: S3
152
+ with one `DeleteObjects` request per 1,000 keys, GCS with JSON batch requests
153
+ of 100 and Azure with Blob Batch requests of 256. Keys a request URL could
154
+ misaddress (`.`/`..` segments, `\`, `%`, `?`, `#`, control characters) are left
155
+ in place and logged. On Artifactory a folder is deleted with one request.
156
+
122
157
  Copies automatically use spare transfer concurrency for large ranged reads.
123
158
  The default target is 8 streams, with an 8 MiB minimum range size and at most
124
159
  8 range streams per file. Files smaller than 16 MiB stay single-stream. When
@@ -274,8 +309,9 @@ service they are not sent at all, and a warning names the missing setting:
274
309
  `HTTP_AUTH_URL`, e.g. `HTTP_AUTH_URL=https://files.example.com`. On a
275
310
  redirect to another scheme, host or port, only non-credential headers
276
311
  (`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
312
+ - **Artifactory:** `ARTIFACTORY_IDENTITY_TOKEN` is only used for the services in
313
+ `ARTIFACTORY_BASE_URL` (or `ART_BASE_URL`), a comma-separated list when one
314
+ Artifactory answers under several host names. A JFrog CLI server token is only
279
315
  used for that server's own origin.
280
316
  - **SSH:** host keys are checked like OpenSSH. `StrictHostKeyChecking`
281
317
  (`yes`, `ask`, `accept-new`, `no`) and `UserKnownHostsFile` are read from
@@ -450,6 +486,15 @@ asanypath cp /local/file.txt s3://bucket/file.txt
450
486
  # Copy cloud → local
451
487
  asanypath cp s3://bucket/file.txt /local/file.txt
452
488
 
489
+ # Add repeatable headers to HTTP requests
490
+ asanypath cat https://example.com/data \
491
+ -o 'headers=Accept: application/json' \
492
+ -o 'headers=X-View: compact'
493
+
494
+ # Scope headers to only one side of a copy
495
+ asanypath cp https://example.com/data /local/data \
496
+ --src-option 'headers=Accept: application/json'
497
+
453
498
  # Allow 32 concurrent files; fill spare capacity toward 8 streams for large files
454
499
  asanypath cp -r s3://bucket/data/ ./data/ -j 32 --concurrency-floor 8
455
500
 
@@ -479,11 +524,19 @@ asanypath auth show
479
524
  asanypath auth show s3://bucket
480
525
  ```
481
526
 
527
+ Backend options can omit the scheme prefix when it can be inferred from each
528
+ path; for example, `-o headers='X-Name: value'`. HTTP headers can be repeated
529
+ with `-o`, `--src-option`, and `--dst-option`; each value uses `NAME: VALUE`
530
+ syntax. Transport-managed headers such as `Host` and
531
+ `Content-Length` are rejected. Header values passed on the command line may be
532
+ visible in shell history or process listings, so use the HTTP auth environment
533
+ variables for secrets.
534
+
482
535
  ### Shell Completions (Beta)
483
536
 
484
537
  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
538
 
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.
539
+ 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
540
 
488
541
  **Bash Setup:**
489
542
 
@@ -563,7 +616,9 @@ def main(model, out):
563
616
 
564
617
  `ClickPath` takes the same arguments as `click.Path`; `path_type` defaults to
565
618
  `asanypath.sync.AsAnyPath`. Local paths (including `file://` URIs) behave exactly
566
- like `click.Path`. Remote paths are checked with `exists()`, `is_dir()` and
619
+ like `click.Path`. scp-style `[user@]host:path` becomes an `ssh://` path when
620
+ `host` is an alias in your ssh config (a `Host` block with its own `HostName`).
621
+ Remote paths are checked with `exists()`, `is_dir()` and
567
622
  `is_file()` while arguments are parsed:
568
623
 
569
624
  - `file_okay=False` / `dir_okay=False` reject a path only when it is exclusively
@@ -572,6 +627,13 @@ like `click.Path`. Remote paths are checked with `exists()`, `is_dir()` and
572
627
  - If the backend cannot be queried (credentials, network, unsupported protocol),
573
628
  `exists=True` reports the error and `exists=False` accepts the path unchecked.
574
629
 
630
+ Shell completion of your CLI completes remote paths the same way as the
631
+ `asanypath` CLI (see [Shell Completions](#shell-completions-beta)), with click's
632
+ usual setup, e.g. `eval "$(_MYPROG_COMPLETE=bash_source myprog)"`. Importing
633
+ `asanypath.click` registers `asanypath.click.BashComplete` for bash, which keeps
634
+ URIs one word although bash splits words at `:` and `@`, and leaves no trailing
635
+ space after a directory. With `file_okay=False` only directories are offered.
636
+
575
637
  ## Benchmarks
576
638
 
577
639
  Multi-backend benchmark suite in `scripts/bench.py` compares asanypath against
@@ -605,6 +667,17 @@ This compares asanypath and boto3 using one shared request budget per client.
605
667
  It warms up each case, reports JSON timings and MiB/s, verifies uploaded contents
606
668
  outside the timed interval, and deletes only the uniquely named benchmark
607
669
  objects it created. Both clients use normal AWS credentials (or `--profile`).
670
+
671
+ For recursive deletes, `scripts/bench_rmtree.py` uploads a generated tree under
672
+ a fresh prefix, times `rmdir(recursive=True)` and checks nothing is left, e.g.
673
+ against the MinIO emulator:
674
+
675
+ ```bash
676
+ AWS_ENDPOINT_URL=http://localhost:9000 AWS_ACCESS_KEY_ID=minioadmin \
677
+ AWS_SECRET_ACCESS_KEY=minioadmin AWS_REGION=us-east-1 \
678
+ uv run python scripts/bench_rmtree.py s3://bench-asanypath/rmtree-bench \
679
+ --dirs 10 --subdirs 10 --files 100
680
+ ```
608
681
  Run with one large shard and again with several representative shards; results
609
682
  from a local test server are not evidence of production endpoint throughput.
610
683
 
@@ -853,6 +926,20 @@ translating provider IAM or ACL models.
853
926
  - `name`, `stem`, `suffix`, `parent`, `parts`
854
927
  - `protocol` — URI scheme (`s3`, `gs`, `az`, `art`, `file`, …)
855
928
 
929
+ ### Relative paths
930
+
931
+ A relative remote path has no bucket or host, so `relative_to()` on a remote path
932
+ returns a `pathlib.PurePosixPath`. Join it onto any path with `/`, e.g. to mirror a
933
+ tree across backends:
934
+
935
+ ```python
936
+ for src in src_root.rglob("*"):
937
+ await src.copy(dst_root / src.relative_to(src_root))
938
+ ```
939
+
940
+ `walk_up=True` returns `..` segments within the same bucket/host; paths with a
941
+ different bucket/host, scheme, or a relative `other` raise `ValueError`.
942
+
856
943
  ## Development
857
944
 
858
945
  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",