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

pythonPackages.ncclient: enable Python 3 support #68226

Merged
merged 1 commit into from Sep 21, 2019

Conversation

simonchatts
Copy link
Contributor

Motivation for this change

The actual code in the currently-packaged ncclient Python package, along with all its dependencies, support Python 3. But currently the way they're packaged breaks this:

$ nix-shell -p python3Packages.ncclient
error: libxslt not supported for interpreter python3.7

The problem is a broken dependency. The (interesting subset of the) actual code dependencies is like this (where P.foo means pythonPackages.foo):

                         +--> libxml2
                         |
P.ncclient --> P.lxml ---+
                         |
                         +--> libxslt

so the ultimate dependency is on the plain old C libraries for libxml2 and libxslt.

Unfortunately, the Python lxml derivation fails to propagate the dependency on these two C libraries, and so ncclient tries to add them back. But it actually depends on the Python package wrappers, like this:

       +--> P.libxml2 -->+-> libxml2
       |                 |
P.ncclient --> P.lxml ---+
       |                 |
       +--> P.libxslt -->+-> libxslt
                 ^
                 |
 Doesn't currently support Python 3

and since P.libxslt doesn't support Python 3, unnecessarily breaks the chain.

There is an issue to enable Python 3 support for P.libxslt. But simply fixing the dependencies seems a quick and correct fix for this case.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • 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 nix-review --run "nix-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.
Test reproduction

If anyone wants to reproduce a test, then there is a simple standalone netconf server here. If you run that, and use this client.py code:

from ncclient import manager
with manager.connect(host='127.0.0.1', port=8300, username='admin', password='admin', hostkey_verify=False) as m:
  print(m.get_config(source='running').data_xml)

then before this fix, python3 fails as above. With the fix, both

nix-shell --pure -p python2 -p python2Packages.ncclient --command 'python2 client.py'
nix-shell --pure -p python3 -p python3Packages.ncclient --command 'python3 client.py'

give the correct output:

<?xml version="1.0" encoding="UTF-8"?><nc:data xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
    <sys:system xmlns:sys="urn:ietf:params:xml:ns:yang:ietf-system">
      <sys:hostname>ibex</sys:hostname>
      <sys:clock>
        <sys:timezone-utc-offset>0</sys:timezone-utc-offset>
      </sys:clock>
    </sys:system>
  </nc:data>
Notify maintainers

cc @sjourdois @xnaveira

@zimbatm
Copy link
Member

zimbatm commented Sep 19, 2019

excellent reporting, thanks!

Do you mind rebasing the PR to the latest master? Something is throwing off nix-review which seems unreated to the PR.

@simonchatts
Copy link
Contributor Author

Thanks @zimbatm - rebased.

@zimbatm zimbatm merged commit 7406bd2 into NixOS:master Sep 21, 2019
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