diff options
author | Zac Medico <zmedico@gentoo.org> | 2024-02-05 21:56:57 -0800 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2024-02-06 00:05:01 -0800 |
commit | b419577c2e5219af9d10c9856449e23fa4d87b24 (patch) | |
tree | ec2f52d33858897d5543412fd78b6063de6d0d30 /.github | |
parent | ForkProcess: Prevent redundant pipe and set_term_size recursion (diff) | |
download | portage-b419577c2e5219af9d10c9856449e23fa4d87b24.tar.gz portage-b419577c2e5219af9d10c9856449e23fa4d87b24.tar.bz2 portage-b419577c2e5219af9d10c9856449e23fa4d87b24.zip |
actions: Add muliprocessing start-method to matrix
Add multiprocessing start-method to matrix so that we are prepared
for when python changes to default to spawn. Exclude all python
versions except 3.12-dev for now.
This adds a conditional ci step that patches the sources just for
the spawn start-method. It patches all bin/* scripts with python
shebangs, and also patches the test command in meson.build.
Bug: https://bugs.gentoo.org/914876
Signed-off-by: Zac Medico <zmedico@gentoo.org>
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/ci.yml | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a897dbee..15da50723 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,9 @@ jobs: runs-on: ubuntu-22.04 strategy: matrix: + start-method: + - 'fork' + - 'spawn' python-version: - '3.9' - '3.10' @@ -18,6 +21,17 @@ jobs: - '3.12-dev' - '3.13-dev' - 'pypy-3.10' + exclude: + - python-version: '3.9' + start-method: 'spawn' + - python-version: '3.10' + start-method: 'spawn' + - python-version: '3.11' + start-method: 'spawn' + - python-version: '3.13-dev' + start-method: 'spawn' + - python-version: 'pypy-3.10' + start-method: 'spawn' fail-fast: false steps: - uses: actions/checkout@v3 @@ -43,6 +57,32 @@ jobs: # symlink /bin/true to /usr/bin/getuto (or do we want to grab the script from github?) sudo ln -s /bin/true /usr/bin/getuto + - name: Patch python scripts to set spawn start method + if: ${{ matrix.start-method == 'spawn' }} + run: | + IFS='' + while read -r bin_file; do + if [[ $(head -n1 "${bin_file}") == '#!/usr/bin/env python' ]]; then + mode=top + while read -r line; do + if [[ ${mode} == top ]]; then + if [[ ${line} == \#* ]]; then + echo "${line}" + else + echo "import multiprocessing" + echo 'multiprocessing.set_start_method("spawn", force=True)' + echo "${line}" + mode=bottom + fi + else + echo "${line}" + fi + done < "${bin_file}" > "${bin_file}.new" + chmod +x "${bin_file}.new" + mv "${bin_file}"{.new,} + fi + done < <(find bin -maxdepth 1 -type f) + sed -i meson.build -e "s|'-m', 'pytest'|'-c', 'import multiprocessing, sys, pytest; multiprocessing.set_start_method(\"spawn\", force=True); sys.exit(pytest.console_main())'|" - name: Test meson install --destdir /tmp/install-root run: | echo -e "[binaries]\npython = '$(command -v python)'" > /tmp/native.ini |