@@ -100,31 +100,41 @@ jobs:
100100 pushd "${{ matrix.project.path }}"
101101 python3 -m twine upload --repository-url https://test.pypi.org/legacy/ --verbose dist/*
102102 popd
103- - name : Wait for packages to upload to Pypi
103+ - name : Wait for packages to appear on test PyPI
104104 shell : bash {0} # So that we do not exit if a command gives a bad exit code
105105 run : |
106106 export PACKAGES=("autoconf" "autoarray" "autofit" "autogalaxy" "autolens")
107107 export VERSION="${{ needs.version_number.outputs.version_number }}"
108+ # Wait for each package to become available on test PyPI
108109 for PACKAGE in ${PACKAGES[@]}; do
109- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra- index-url https://pypi.org/simple $PACKAGE[optional] ==$VERSION
110+ python3 -m pip download --no-deps --dest /tmp/pyauto-check --index-url https://test. pypi.org/simple/ $PACKAGE==$VERSION
110111 test_condition=$?
111112 cnt=0
112113 while [[ $test_condition != "0" ]]; do
113- echo "Failed to find package, retrying in 10 seconds.. "
114+ echo "Waiting for $PACKAGE==$VERSION on test PyPI... (attempt $cnt) "
114115 sleep 10
115116 ((cnt=cnt+1))
116117 [[ $cnt == "100" ]] && echo "Timed out, tried 100 times" && break
117- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra- index-url https://pypi.org/simple $PACKAGE[optional] ==$VERSION
118+ python3 -m pip download --no-deps --dest /tmp/pyauto-check --index-url https://test. pypi.org/simple/ $PACKAGE==$VERSION
118119 test_condition=$?
119120 done
120121 done
121- # Re-pin PyAuto packages from test PyPI to prevent production PyPI
122- # versions being pulled in during dependency resolution.
123- # Use || true because not all packages may be uploaded yet (parallel matrix).
124- for PACKAGE in ${PACKAGES[@]}; do
125- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall $PACKAGE==$VERSION || true
126- done
127122 true # ensure step exits 0
123+ - name : Install all PyAuto packages
124+ run : |
125+ export VERSION="${{ needs.version_number.outputs.version_number }}"
126+ # Install all 5 PyAuto packages in a single command with all versions
127+ # pinned. This prevents pip from substituting unrelated packages with
128+ # the same names from production PyPI (e.g. autoconf 0.7.7, autofit 0.73.1)
129+ # during dependency resolution.
130+ python3 -m pip install \
131+ --index-url https://test.pypi.org/simple/ \
132+ --extra-index-url https://pypi.org/simple \
133+ "autoconf[optional]==$VERSION" \
134+ "autoarray[optional]==$VERSION" \
135+ "autofit[optional]==$VERSION" \
136+ "autogalaxy[optional]==$VERSION" \
137+ "autolens[optional]==$VERSION"
128138 - name : Tests
129139 run : |
130140 pushd "${{ matrix.project.path }}"
@@ -133,15 +143,6 @@ jobs:
133143 pip install pynufft==2025.1.1
134144 pip install pytest
135145 pip install numba
136- # Re-pin PyAuto packages after third-party installs to ensure
137- # test PyPI versions were not replaced by production PyPI versions.
138- # Only re-pin packages that are already installed (pip show succeeds).
139- export VERSION="${{ needs.version_number.outputs.version_number }}"
140- for PACKAGE in autoconf autoarray autofit autogalaxy autolens; do
141- if pip show $PACKAGE >/dev/null 2>&1; then
142- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall $PACKAGE==$VERSION || true
143- fi
144- done
145146 python3 -m pytest
146147
147148 find_scripts :
@@ -325,11 +326,11 @@ jobs:
325326 - name : Install project
326327 if : " ${{ github.event.inputs.skip_scripts != 'true' }}"
327328 run : |
328- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "autoconf==${{ needs.version_number.outputs.version_number }}"
329- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
330- # Re-pin PyAuto packages from test PyPI to prevent production PyPI substitution
331- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall "autoconf==${{ needs.version_number.outputs.version_number }}"
332- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
329+ python3 -m pip install \
330+ --index-url https://test.pypi.org/simple/ \
331+ --extra-index-url https://pypi.org/simple \
332+ "autoconf==${{ needs.version_number.outputs.version_number }}" \
333+ "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
333334 - name : Run Python scripts
334335 if : " ${{ github.event.inputs.skip_scripts != 'true' }}"
335336 run : |
@@ -420,11 +421,11 @@ jobs:
420421 - name : Install project
421422 if : " ${{ github.event.inputs.skip_notebooks != 'true' }}"
422423 run : |
423- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "autoconf==${{ needs.version_number.outputs.version_number }}"
424- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
425- # Re-pin PyAuto packages from test PyPI to prevent production PyPI substitution
426- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall "autoconf==${{ needs.version_number.outputs.version_number }}"
427- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
424+ python3 -m pip install \
425+ --index-url https://test.pypi.org/simple/ \
426+ --extra-index-url https://pypi.org/simple \
427+ "autoconf==${{ needs.version_number.outputs.version_number }}" \
428+ "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
428429 - name : Install Jupyter dependency
429430 if : " ${{ github.event.inputs.skip_notebooks != 'true' }}"
430431 run : |
@@ -757,9 +758,10 @@ jobs:
757758 - name : Install project
758759 if : " ${{ github.event.inputs.update_notebook_visualisations == 'true' }}"
759760 run : |
760- python3 -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
761- # Re-pin from test PyPI to prevent production PyPI substitution
762- python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --force-reinstall "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
761+ python3 -m pip install \
762+ --index-url https://test.pypi.org/simple/ \
763+ --extra-index-url https://pypi.org/simple \
764+ "${{ steps.configure.outputs.project }}==${{ needs.version_number.outputs.version_number }}"
763765 - name : Install Jupyter dependency
764766 if : " ${{ github.event.inputs.update_notebook_visualisations == 'true' }}"
765767 run : |
0 commit comments