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

Python CAN support #34473

Merged
merged 3 commits into from Feb 4, 2018
Merged

Python CAN support #34473

merged 3 commits into from Feb 4, 2018

Conversation

sorki
Copy link
Member

@sorki sorki commented Jan 31, 2018

Motivation for this change

CAN/CANOpen python stack

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.

@sorki sorki requested a review from FRidh as a code owner January 31, 2018 22:13
@grahamc
Copy link
Member

grahamc commented Jan 31, 2018

@GrahamcOfBorg eval

(a commit broke master, and it is now fixed.)

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 put the derivations into spererate files inside pkgs/development/python-modules and use callPackage.

@@ -2012,6 +2012,83 @@ in {
doCheck = false;
});

can = buildPythonPackage rec {
rev = "2.0.0";
name = "can-${rev}";
Copy link
Member

Choose a reason for hiding this comment

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

No name. Specify pname and version please.


canopen = buildPythonPackage rec {
rev = "v0.5.1";
name = "canopen-${rev}";
Copy link
Member

Choose a reason for hiding this comment

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

See above.


canmatrix = buildPythonPackage rec {
rev = "0.6";
name = "canmatrix-${rev}";
Copy link
Member

Choose a reason for hiding this comment

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

See above.

rev = "2.0.0";
name = "can-${rev}";

src = pkgs.fetchFromGitHub {
Copy link
Member

Choose a reason for hiding this comment

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

Please use fetchPypi if possible. This makes it easier to override the src.

@@ -2012,6 +2012,83 @@ in {
doCheck = false;
});

can = 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> { };.

@sorki
Copy link
Member Author

sorki commented Feb 2, 2018

Should be ok now.

doCheck = false;

propagatedBuildInputs =
[ nose
Copy link
Member

Choose a reason for hiding this comment

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

checkInputs


propagatedBuildInputs =
[ nose
mock
Copy link
Member

Choose a reason for hiding this comment

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

checkInputs

buildPythonPackage rec {
pname = "python-can";
version = "2.0.0";
name = "${pname}-${version}";
Copy link
Member

Choose a reason for hiding this comment

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

no name

buildPythonPackage rec {
pname = "canmatrix";
version = "0.6";
name = "${pname}-${version}";
Copy link
Member

Choose a reason for hiding this comment

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

no name

buildPythonPackage rec {
pname = "canopen";
version = "0.5.1";
name = "${pname}-${version}";
Copy link
Member

Choose a reason for hiding this comment

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

no name


# due to missing test/sample.eds
# https://github.com/christiansandberg/canopen/pull/57
doCheck = false;
Copy link
Member

Choose a reason for hiding this comment

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

Thanks a lot for opening the PR! As long as no new version is published on PyPI, you could also rely on fetchFromGitHub.

@dotlambda
Copy link
Member

@GrahamcOfBorg build python2.pkgs.canopen python3.pkgs.canopen

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)

Successfully installed canopen-0.5.1
/tmp/nix-build-python3.6-canopen-0.5.1.drv-0/canopen-0.5.1
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/sg6mvlqi6g5j3z9kmlbrv1hrhyn6laq3-python3.6-canopen-0.5.1
strip is /nix/store/mdyy001q67hiks0g24ra53z7ckm4jfr4-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/sg6mvlqi6g5j3z9kmlbrv1hrhyn6laq3-python3.6-canopen-0.5.1/lib 
patching script interpreter paths in /nix/store/sg6mvlqi6g5j3z9kmlbrv1hrhyn6laq3-python3.6-canopen-0.5.1
checking for references to /tmp/nix-build-python3.6-canopen-0.5.1.drv-0 in /nix/store/sg6mvlqi6g5j3z9kmlbrv1hrhyn6laq3-python3.6-canopen-0.5.1...
/nix/store/vl0s2prrnqdnardxq3jx092k5nkmcmsi-python2.7-canopen-0.5.1
/nix/store/sg6mvlqi6g5j3z9kmlbrv1hrhyn6laq3-python3.6-canopen-0.5.1

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Partial log (click to expand)

Successfully installed canopen-0.5.1
/build/canopen-0.5.1
post-installation fixup
shrinking RPATHs of ELF executables and libraries in /nix/store/4hcpabbng74g0qdd4aw8gm2d79sqsabb-python3.6-canopen-0.5.1
strip is /nix/store/jwz859pxqj7sl2dbwvmxkx68jp774izb-binutils-2.28.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/4hcpabbng74g0qdd4aw8gm2d79sqsabb-python3.6-canopen-0.5.1/lib
patching script interpreter paths in /nix/store/4hcpabbng74g0qdd4aw8gm2d79sqsabb-python3.6-canopen-0.5.1
checking for references to /build in /nix/store/4hcpabbng74g0qdd4aw8gm2d79sqsabb-python3.6-canopen-0.5.1...
/nix/store/7wxnh9nhq84icajdn25d5v0xgdb4a15v-python2.7-canopen-0.5.1
/nix/store/4hcpabbng74g0qdd4aw8gm2d79sqsabb-python3.6-canopen-0.5.1

@dotlambda
Copy link
Member

dotlambda commented Feb 2, 2018

The following enables canmatrix tests. Because PyPI doesn't ship the test/ directory, fetchFromGitHub is used.

diff --git a/pkgs/development/python-modules/canmatrix/default.nix b/pkgs/development/python-modules/canmatrix/default.nix
index c62c43dc2df..6409010aa3e 100644
--- a/pkgs/development/python-modules/canmatrix/default.nix
+++ b/pkgs/development/python-modules/canmatrix/default.nix
@@ -1,7 +1,7 @@
 { lib
 , stdenv
 , buildPythonPackage
-, fetchPypi
+, fetchFromGitHub
 , lxml
 , xlwt
 , xlrd
@@ -14,9 +14,11 @@ buildPythonPackage rec {
   version = "0.6";
   name = "${pname}-${version}";
 
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "1jv0ry3qrrkjc32a0lwznf7ix8wl2s5lccqsqcyxnr89qbkjapqb";
+  src = fetchFromGitHub {
+    owner = "ebroecker";
+    repo = pname;
+    rev = version;
+    sha256 = "1lb0krhchja2jqfsh5lsfgmqcchs1pd38akvc407jfmll96f4yqz";
   };
 
   propagatedBuildInputs =
@@ -28,6 +30,11 @@ buildPythonPackage rec {
       future
     ];
 
+  checkPhase = ''
+    cd test
+    python ./test.py
+  '';
+
   meta = with lib; {
     homepage = https://github.com/ebroecker/canmatrix;
     description = "Support and convert several CAN (Controller Area Network) database formats .arxml .dbc .dbf .kcd .sym fibex xls(x)";

However, I don't know what the expected outcome is. Their travis build more or less show the same output as this does.

@sorki
Copy link
Member Author

sorki commented Feb 3, 2018

Had to disable doCheck in canopen now, rest looks fine, I would let canmatrix run its test even if they only ouput diffs if they ever decide to return exit code according to that.

@FRidh
Copy link
Member

FRidh commented Feb 3, 2018

@GrahamcOfBorg build python2.pkgs.can python2.pkgs.canmatrix python3.pkgs.can python3.pkgs.canmatrix


checkPhase = ''
cd test
python ./test.py
Copy link
Member

Choose a reason for hiding this comment

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

${python.interpreter. This is needed e.g. for pypy

@GrahamcOfBorg
Copy link

Success on x86_64-linux (full log)

Partial log (click to expand)

Variable type 'string' found and skipped
Variable type 'string' found and skipped
Variable type 'string' found and skipped
Variable type 'string' found and skipped
xls -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xlsx', 'xml', 'yaml']
xlsx -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xml', 'yaml']
yaml -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xlsx', 'xml']


    Testing completed: difference found

@GrahamcOfBorg
Copy link

Success on aarch64-linux (full log)

Partial log (click to expand)

Variable type 'string' found and skipped
Variable type 'string' found and skipped
Variable type 'string' found and skipped
Variable type 'string' found and skipped
xls -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xlsx', 'xml', 'yaml']
xlsx -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xml', 'yaml']
yaml -> ['arxml', 'csv', 'dbc', 'dbf', 'json', 'kcd', 'sym', 'xls', 'xlsx', 'xml']


    Testing completed: difference found

@FRidh FRidh merged commit 9ba4b16 into NixOS:master Feb 4, 2018
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

5 participants