Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

criu: Switch to Python 3 #105360

Merged
merged 1 commit into from Dec 5, 2020
Merged

criu: Switch to Python 3 #105360

merged 1 commit into from Dec 5, 2020

Conversation

primeos
Copy link
Member

@primeos primeos commented Nov 29, 2020

Motivation for this change

I'm currently trying to rid my system of Python 2. I verified that the build still works but unfortunately I cannot test this properly.

crit --version or importing pycriu in an interactive Python shell fails but that also failed before.
cc @FRidh @jonringer: Any ideas how to package this correctly? It's basically a C program/library that also ships with a Python library (pycriu in lib/python3.8/site-packages/pycriu/).

I've also tried the following changes:

  nativeBuildInputs = [ python3 python3.pkgs.wrapPython ];
  propagatedBuildInputs = with python3.pkgs; [ python protobuf ];
  postFixup = ''
    wrapPythonPrograms # Need something like wrapPythonLibraries
  '';

But I'm not getting $out/nix-support/propagated-build-inputs and it still fails with:

$ crit --version
Traceback (most recent call last):
  File "/nix/store/dif0rqr5vhspiwyz3i2mlddvrczrn97q-criu-3.15/bin/.crit-wrapped", line 4, in <module>
    from pycriu import cli
  File "/nix/store/dif0rqr5vhspiwyz3i2mlddvrczrn97q-criu-3.15/lib/python3.8/site-packages/pycriu/__init__.py", line 1, in <module>
    from . import rpc_pb2 as rpc
  File "/nix/store/dif0rqr5vhspiwyz3i2mlddvrczrn97q-criu-3.15/lib/python3.8/site-packages/pycriu/rpc_pb2.py", line 5, in <module>
    from google.protobuf.internal import enum_type_wrapper
ModuleNotFoundError: No module named 'google'
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@FRidh
Copy link
Member

FRidh commented Nov 29, 2020

You can add wrapPython to nativeBuildInputs, and then in the postFixup invoke wrapPythonPrograms. The existing wrapping code can be replaced with makeWrapperArgs = [ "--prefix PATH : ..." ].

This also fixes "crit -h" and "import pycriu" from within an interactive
Python shell.
@primeos
Copy link
Member Author

primeos commented Nov 29, 2020

@FRidh thanks! :) Seems like I've messed my testing up (I somehow couldn't get it to work before but it works now).

$ crit -h
usage: crit [-h] {decode,encode,info,x,show} ...

CRiu Image Tool

positional arguments:
  {decode,encode,info,x,show}
                        Use crit CMD --help for command-specific help
    decode              convert criu image from binary type to json
    encode              convert criu image from json type to binary
    info                show info about image
    x                   explore image dir
    show                convert criu image from binary to human-readable json

optional arguments:
  -h, --help            show this help message and exit

$ python
Python 3.8.6 (default, Sep 23 2020, 13:54:27)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pycriu
>>> pycriu.images.TTY
11

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 105360 run on x86_64-linux 1

2 packages built:
  • criu
  • lxd

@thoughtpolice
Copy link
Member

@ofborg build criu

@primeos primeos merged commit 0061744 into NixOS:master Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants