Skip to content

python3Packages.{pyimg4,smart-meter-texas}: fix against asn1 3.x by adding asn1_2 - #26

Merged
Bad3r merged 2 commits into
nixpkgs-unstablefrom
python-pyimg4-unbreak-asn1
Aug 24, 2026
Merged

python3Packages.{pyimg4,smart-meter-texas}: fix against asn1 3.x by adding asn1_2#26
Bad3r merged 2 commits into
nixpkgs-unstablefrom
python-pyimg4-unbreak-asn1

Conversation

@Bad3r

@Bad3r Bad3r commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Description of changes

python3Packages.pyimg4 has been marked broken since ef300f4, which set broken = lib.versionAtLeast asn1.version "3". nixpkgs ships asn1 3.3.0, so the guard always fires and takes ipsw-parser and pymobiledevice3 down with it:

$ nix shell nixpkgs#python3Packages.pymobiledevice3
error: Refusing to evaluate package 'python3.14-pyimg4-0.8.8' ... because it has problems:
       - broken: This package is broken.
note: trace involved the following derivations:
       derivation 'python3.14-pymobiledevice3-7.7.0'
       derivation 'python3.14-ipsw-parser-1.5.0'

The pin is not stale metadata. With the constraint relaxed and broken dropped, 5 of 7 tests fail against asn1 3.3.0:

FAILED tests/test_im4m.py::test_im4m  - asn1.core.Error: Expecting bytes or a subclass of io.RawIOBase or BufferedI...
FAILED tests/test_im4r.py::test_read  - asn1.core.Error: Expecting bytes or a subclass of io.RawIOBase or BufferedI...
FAILED tests/test_img4.py::test_read  - pyimg4.errors.UnexpectedTagError: Expected tag of type IA5String, got Print...

python-asn1 3.0 changed Decoder.read() to recursively decode constructed elements into nested lists instead of returning their raw content octets, which is what parser.py re-parses and re-emits throughout. Upstream declined the port in m1stadev/PyIMG4#59 ("Version 3.0.0 is technically much better, but pyimg4 should be refactored around it first to support it") and has not released since v0.8.8 in April 2025.

So this adds asn1_2 at 2.8.0, the last 2.x, and builds pyimg4 against it, following the existing convention for versioned Python attributes (cython_0, chardet_5, django_5). asn1 stays at 3.3.0 as the default; pyimg4 is its only in-tree consumer (smart-meter-texas is the other, and ldap3 uses pyasn1, not asn1). No pythonRelaxDeps is needed since 2.8.0 satisfies upstream's asn1>=2.7.0,<3.0.0 directly.

I have also proposed the actual port upstream in m1stadev/PyIMG4#63. Once that lands and is released, pyimg4 can move back to asn1 and asn1_2 can go.

Verification

nix-build -A python3Packages.pyimg4           # 7 passed, 5 deselected
nix-build -A python3Packages.ipsw-parser      # ok
nix-build -A python3Packages.pymobiledevice3  # 56 passed, 113 deselected, 1 xfailed
nix-build -A python3Packages.asn1_2 -A python3Packages.asn1
nix-instantiate ./. -A python3Packages.{asn1_2,pyimg4,ipsw-parser,ldap3} \
                    -A python312Packages.pyimg4 -A python313Packages.asn1_2
nix fmt   # 0 changed

nix-store -qR on the pymobiledevice3 output contains python3.14-asn1-2.8.0 and no 3.3.0, so there is no module collision in the closure.

The affected set is closed and was built in full by hand rather than via nixpkgs-review: asn1_2 is new and only pyimg4 consumes it, pyimg4's only reverse dependency is ipsw-parser, whose only reverse dependency is pymobiledevice3, which nothing else in tree depends on. All four are built above.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in /etc/nix/nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

Bad3r added 2 commits August 24, 2026 06:58
python-asn1 3.0.0 changed Decoder.read() to recursively decode constructed elements into lists instead of returning
their raw content octets, Encoder.write() with Types.Constructed to re-encode each item of the value instead of
emitting pre-encoded octets verbatim, and Decoder.eof() to be relative to the whole input instead of the entered
container. Consumers written against the 2.x raw-octet API cannot be pointed at 3.x unchanged.

pyimg4 is the only consumer in tree: it pins asn1<3.0.0 upstream (m1stadev/PyIMG4#59) and has been marked broken since
asn1 was updated to 3.x. asn1 itself stays on 3.3.0 as the default.

Validation: nix-build -A python3Packages.asn1_2 (upstream tests/test_asn1.py pass on 3.12, 3.13, 3.14).
Marked broken in ef300f4 because asn1 is 3.3.0 and pyimg4 pins asn1<3.0.0. The pin is not stale metadata: with the
constraint relaxed, 5 of 7 tests fail with "asn1.core.Error: Expecting bytes or a subclass of io.RawIOBase or
BufferedIOBase. Get <class list> instead" and "UnexpectedTagError: Expected tag of type IA5String, got
PrintableString", because Decoder.read() no longer returns the raw content octets that parser.py re-parses and
re-emits.

Upstream declined the port in m1stadev/PyIMG4#59 ("pyimg4 should be refactored around it first") and has not released
since v0.8.8, so build against asn1_2 rather than patch. This unblocks ipsw-parser and pymobiledevice3, which fail to
evaluate through pyimg4. A port is proposed in m1stadev/PyIMG4#63; once released, this can move back to asn1.

Validation: nix-build -A python3Packages.pyimg4 (7 passed, 5 deselected), -A python3Packages.ipsw-parser,
-A python3Packages.pymobiledevice3 (56 passed, 1 xfailed); nix-store -qR on the pymobiledevice3 output shows asn1 2.8.0
only, no collision with 3.3.0.
@Bad3r
Bad3r merged commit 2e8f5c0 into nixpkgs-unstable Aug 24, 2026
@Bad3r Bad3r changed the title python3Packages.pyimg4: unbreak by building against a new asn1_2 python3Packages.{pyimg4,smart-meter-texas}: fix against asn1 3.x by adding asn1_2 Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant