Skip to content

Commit 101769a

Browse files
committed
Fix Update GHC workflow
The workflow failed for a few weeks because of an error: ``` Traceback (most recent call last): File "/home/runner/work/rules_haskell/rules_haskell/haskell/gen_ghc_bindist.py", line 11, in <module> from distutils.version import StrictVersion ModuleNotFoundError: No module named 'distutils' ``` The `distutils` module is deprecated since Python 3.10 and has been removed in Python 3.12 now. Apparently, this workflow is using Python 3.12 since the `nixpkgs` registry entry by default refers to "github:NixOS/nixpkgs/nixpkgs-unstable". This change uses the `packaging.version` module instead, switching to `nix-shell` to make use of the nixpkgs revision that is configured in `nixpkgs/default.nix` and to provide the `packaging` pip package.
1 parent 069fc77 commit 101769a

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Diff for: .github/workflows/update-ghc.yaml

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ name: Update GHC
22
on:
33
schedule:
44
# run weekly on Thursday
5-
- cron: '0 15 * * THU'
5+
- cron: '0 15 * * THU'
66
workflow_dispatch: # allows manual triggering
7-
87
jobs:
98
update_ghc:
109
name: GHC ${{ matrix.ghc }} Update
@@ -27,7 +26,9 @@ jobs:
2726
nix_path: nixpkgs=nixpkgs/default.nix
2827
- name: Fetch updates
2928
id: ghc_update
30-
run: nix shell 'nixpkgs#bazel-buildtools' 'nixpkgs#python3' --command python .github/update-ghc.py ${{ matrix.ghc }}
29+
run: |-
30+
nix-shell -p 'bazel-buildtools' 'python3.withPackages (ps: [ps.packaging])' --run \
31+
'python .github/update-ghc.py ${{ matrix.ghc }}'
3132
- name: Create Pull Request
3233
if: steps.ghc_update.outputs.latest != ''
3334
uses: peter-evans/create-pull-request@v7

Diff for: haskell/gen_ghc_bindist.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import json
99
import sys
1010
from urllib.request import urlopen
11-
from distutils.version import StrictVersion
11+
from packaging.version import Version
1212

1313
# Sometimes bindists have errors and are updated by new bindists.
1414
# This dict is used to keep a version -> corrected_version mapping.
@@ -158,7 +158,7 @@ def fetch_bindists(grab):
158158

159159
ghc_versions = {
160160
version: ghc_bindists[version]
161-
for version in sorted(ghc_bindists.keys(), key=StrictVersion)
161+
for version in sorted(ghc_bindists.keys(), key=Version)
162162
}
163163

164164
json_file.truncate(0)

0 commit comments

Comments
 (0)