Skip to content

Commit d85e76d

Browse files
authored
Switch Python index pages to relative links (#1812)
`manage.py` creates an index.html file for every package which is placed in a subdirectory named after the package. Packages are located one level above whereas links where abolsute. This refactors to use relative links instead as this allows to move the index to a different directory without rewriting. This is compliant with PEP 503 [1]: URLs may be either absolute or relative as long as they point to the correct location. [1] https://peps.python.org/pep-0503/
1 parent d66b7da commit d85e76d

File tree

5 files changed

+2
-10
lines changed

5 files changed

+2
-10
lines changed

.github/workflows/build_portable_linux_pytorch_wheels.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ jobs:
205205
env:
206206
# Environment variables to be set for `manage.py`
207207
CUSTOM_PREFIX: "${{ inputs.s3_staging_subdir }}/${{ inputs.amdgpu_family }}"
208-
STRIP_PREFIX: "v3/"
209208
run: |
210209
pip install boto3 packaging
211210
python ./build_tools/third_party/s3_management/manage.py ${{ env.CUSTOM_PREFIX }}
@@ -299,7 +298,6 @@ jobs:
299298
env:
300299
# Environment variables to be set for `manage.py`
301300
CUSTOM_PREFIX: "${{ inputs.s3_subdir }}/${{ inputs.amdgpu_family }}"
302-
STRIP_PREFIX: "v3/"
303301
run: |
304302
pip install boto3 packaging
305303
python ./build_tools/third_party/s3_management/manage.py ${{ env.CUSTOM_PREFIX }}

.github/workflows/build_windows_pytorch_wheels.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ jobs:
240240
env:
241241
# Environment variables to be set for `manage.py`
242242
CUSTOM_PREFIX: "${{ inputs.s3_staging_subdir }}/${{ inputs.amdgpu_family }}"
243-
STRIP_PREFIX: "v3/"
244243
shell: cmd
245244
run: |
246245
pip install boto3 packaging
@@ -332,7 +331,6 @@ jobs:
332331
env:
333332
# Environment variables to be set for `manage.py`
334333
CUSTOM_PREFIX: "${{ inputs.s3_subdir }}/${{ inputs.amdgpu_family }}"
335-
STRIP_PREFIX: "v3/"
336334
run: |
337335
pip install boto3 packaging
338336
python ./build_tools/third_party/s3_management/manage.py ${{ env.CUSTOM_PREFIX }}

.github/workflows/release_portable_linux_packages.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ jobs:
154154
S3_BUCKET_PY: "therock-${{ needs.setup_metadata.outputs.release_type }}-python"
155155
S3_SUBDIR: ${{ inputs.s3_subdir || 'v2' }}
156156
S3_STAGING_SUBDIR: ${{ inputs.s3_staging_subdir || 'v2-staging' }}
157-
STRIP_PREFIX: "v3/" # Environment variable to be set for `manage.py`
158157

159158
steps:
160159
- name: "Checking out repository"

.github/workflows/release_windows_packages.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ jobs:
162162
S3_BUCKET_PY: "therock-${{ needs.setup_metadata.outputs.release_type }}-python"
163163
S3_SUBDIR: ${{ inputs.s3_subdir || 'v2' }}
164164
S3_STAGING_SUBDIR: ${{ inputs.s3_staging_subdir || 'v2-staging' }}
165-
STRIP_PREFIX: "v3/" # Environment variable to be set for `manage.py`
166165

167166
steps:
168167
- name: "Checking out repository"

build_tools/third_party/s3_management/manage.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,6 @@
5454
if CUSTOM_PREFIX:
5555
PREFIXES.append(CUSTOM_PREFIX)
5656

57-
STRIP_PREFIX = getenv('STRIP_PREFIX', '')
58-
5957
# NOTE: This refers to the name on the wheels themselves and not the name of
6058
# package as specified by setuptools, for packages with "-" (hyphens) in their
6159
# names you need to convert them to "_" (underscores) in order for them to be
@@ -289,10 +287,10 @@ def to_simple_package_html(
289287
if any(obj.key.endswith(x) for x in ("networkx-3.3-py3-none-any.whl", "networkx-3.4.2-py3-none-any.whl")):
290288
attributes += ' data-requires-python=">=3.10"'
291289

292-
stripped_key = obj.key.removeprefix(STRIP_PREFIX) if STRIP_PREFIX else obj.key
290+
stripped_key = obj.key.split("/")[-1]
293291

294292
out.append(
295-
f' <a href="/{stripped_key}{maybe_fragment}"{attributes}>{path.basename(obj.key).replace("%2B","+")}</a><br/>'
293+
f' <a href="../{stripped_key}{maybe_fragment}"{attributes}>{path.basename(obj.key).replace("%2B","+")}</a><br/>'
296294
)
297295
# Adding html footer
298296
out.append(' </body>')

0 commit comments

Comments
 (0)