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

pythonnet: Init at 2.3.0 #34647

Merged
merged 1 commit into from Feb 9, 2018
Merged

Conversation

jraygauthier
Copy link
Member

Motivation for this change

Package for interop between CPython and mono / .NET. Was not available.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

All pytest are run in checkphase and pass using both python27 and python3.

And manually:

nix-shell -p 'python3.withPackages (pp: [pp.pythonnet pp.ipython])'
ipython
import clr
clr.AddReference("System.Runtime.InteropServices")
from System.Runtime.InteropServices import GCHandle, GCHandleType
from System import Array, Byte from System import Array, Byte
cs_array = Array.CreateInstance(Byte, 1000)
handler = GCHandle.Alloc(cs_array, GCHandleType.Pinned)

Copy link
Member

@dotlambda dotlambda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move the expression to a folder in pkgs/development/python-modules.

version = "2.3.0";


src = pkgs.fetchurl {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fetchPypi

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -14941,6 +14941,72 @@ in {
};
};

pythonnet = buildPythonPackage rec {
name = "pythonnet-${version}";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name is generated automatically. pname should be provided instead

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

description = ".Net and Mono integration for Python";
homepage = https://pythonnet.github.io;
license = licenses.mit;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you mind adding yourself as a maintainer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


# install packages using nuget
- self._install_packages()
+ #self._install_packages()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This patch is so simple that it is probably wiser to use sed or substituteInPlace.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

[ -z "$dontPlacatePaket" ] && placate-paket.sh
'';

UnmanagedExports127 = pkgs.fetchNuGet {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use let expression for these 2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -14941,6 +14941,72 @@ in {
};
};

pythonnet = buildPythonPackage rec {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are moving Python expressions out of pkgs/top-level/python-packages.nix into pkgs/development/python-modules/<module>/default.nix.

Please move the expression there, and call it from pkgs/top-level/python-packages.nix using callPackage ../development/python-modules/<package> { };.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jraygauthier
Copy link
Member Author

@FRidh & @dotlambda : thanks for the review. Changes as requested.

@dotlambda
Copy link
Member

I have no experience with fetchNuGet, so I can not judge this one. However, the python parts look fine.

Copy link
Member

@FRidh FRidh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more minor change. Indentation in Nixpkgs should be 2 spaces, not 4.

@jraygauthier
Copy link
Member Author

@FRidh : done.

@dotlambda
Copy link
Member

Please rebase on current master.

@jraygauthier
Copy link
Member Author

@dotlambda : Now rebased on latest.

@dotlambda
Copy link
Member

@GrahamcOfBorg build python2.pkgs.pythonnet python3.pkgs.pythonnet

@GrahamcOfBorg
Copy link

Failure on aarch64-linux (full log)

Partial log (click to expand)

Package ‘mono-4.6.2.16’ in /var/lib/gc-of-borg/nix-test-rs-2/repo/38dca4e3aa6bca43ea96d2fcc04e8229/builder/grahamc-aarch64-community-2/pkgs/development/compilers/mono/generic.nix:90 is not supported on ‘aarch64-linux’, refusing to evaluate.

a) For `nixos-rebuild` you can set
  { nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.

b) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
  { allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)


=========================== slowest 5 test durations ===========================
1.14s call     src/tests/test_module.py::test_assembly_load_thread_safety
1.10s call     src/tests/test_thread.py::test_python_thread_calls_to_clr
0.79s call     src/tests/test_compat.py::test_multiple_imports
0.35s call     src/tests/test_sysargv.py::test_sys_argv_state
0.23s call     src/tests/test_module.py::test_preload_var
�[32m�[1m==================== 359 passed, 7 skipped in 7.04 seconds =====================�[0m
/nix/store/x12604vz9srbypq2qfddzsmwcpa2kgn6-python2.7-pythonnet-2.3.0
/nix/store/l8pra48ssiqhy9lpzqq0y3bg7x4rbf7r-python3.6-pythonnet-2.3.0

@@ -0,0 +1,85 @@
{ lib
, stdenv
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not used

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, stdenv isn't.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

clang

NUnit360
UnmanagedExports127
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these two go into buildInputs?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NUnit360 is for unit tests run after the build. clang and pycparser are used to generate some cs interop files at build time and UnmanagedExports127 is a dependency for one of the csharp projet. pythonnet would have barked when used if any of those were missing (csharp should have been propagated binput while UnmanagedExports should have been put alongside its dependendant .net exe in the install location and there aren't any installed .net exe.

@FRidh FRidh merged commit 669e03e into NixOS:master Feb 9, 2018
@jraygauthier
Copy link
Member Author

@FRidh & @dotlambda : Thanks.

@dotlambda
Copy link
Member

@jraygauthier Thank you for contributing!

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