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

cocotb: init at 1.2.0 #71288

Merged
merged 3 commits into from Oct 25, 2019
Merged

cocotb: init at 1.2.0 #71288

merged 3 commits into from Oct 25, 2019

Conversation

matthuszagh
Copy link
Contributor

@matthuszagh matthuszagh commented Oct 17, 2019

Motivation for this change
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.
Notify maintainers

cc @

@emilazy
Copy link
Member

emilazy commented Oct 17, 2019

Thanks for packaging this!

You'll need to add yourself to maintainers/maintainer-list.nix too.

The following changes get the tests running and passing:

diff --git a/pkgs/development/python-modules/cocotb/default.nix b/pkgs/development/python-modules/cocotb/default.nix
index 2da667b77c6..2728da9a3aa 100644
--- a/pkgs/development/python-modules/cocotb/default.nix
+++ b/pkgs/development/python-modules/cocotb/default.nix
@@ -1,19 +1,38 @@
-{ stdenv, buildPythonPackage, fetchPypi, setuptools }:
+{ stdenv, buildPythonPackage, fetchFromGitHub, setuptools, swig, verilog }:
 
 buildPythonPackage rec {
   pname = "cocotb";
   version = "1.2.0";
 
-  src = fetchPypi {
-    inherit pname version;
-    sha256 = "0855gs1wi7k9fwk832czri21wr83gzp0lp2jkaxccyjgbr1d8a8z";
+  src = fetchFromGitHub {
+    owner = pname;
+    repo = pname;
+    rev = "v${version}";
+    sha256 = "091q63jcm87xggqgqi44lw2vjxhl1v4yl0mv2c76hgavb29w4w5y";
   };
 
   propagatedBuildInputs = [
     setuptools
   ];
 
-  doCheck = false;
+  postPatch = ''
+    patchShebangs bin/*.py
+
+    # POSIX portability (TODO: upstream this)
+    for f in \
+      cocotb/share/makefiles/Makefile.* \
+      cocotb/share/makefiles/simulators/Makefile.*
+    do
+      substituteInPlace $f --replace 'shell which' 'shell command -v'
+    done
+  '';
+
+  checkInputs = [ swig verilog ];
+
+  installCheckPhase = ''
+    export PATH=$out/bin:$PATH
+    make test
+  '';
 
   meta = {
     description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";

@matthuszagh
Copy link
Contributor Author

@emilazy changes made. Thanks for getting the tests working!

@emilazy
Copy link
Member

emilazy commented Oct 17, 2019

I submitted the Makefile changes upstream as cocotb/cocotb#1153.

maintainers/maintainer-list.nix Show resolved Hide resolved
pkgs/development/python-modules/cocotb/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/cocotb/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/cocotb/default.nix Outdated Show resolved Hide resolved
pkgs/development/python-modules/cocotb/default.nix Outdated Show resolved Hide resolved
@jonringer jonringer changed the title Cocotb cocotb: init at 1.2.0 Oct 18, 2019
@jonringer
Copy link
Contributor

please squash all the cocotb related commits into one

git reset HEAD~4
git add pkgs/
git commit -m "pythonPackages.cocotb: init at 1.2.0"

Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

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

nix-review passes on NixOS
diff LGTM
executable seems to work

https://github.com/NixOS/nixpkgs/pull/71288
3 package were build:
python27Packages.cocotb python37Packages.cocotb python38Packages.cocotb
[nix-shell:/home/jon/.cache/nix-review/pr-71288-1]$ nix path-info -Sh ./results/python37Packages.cocotb
/nix/store/58fll0a5dwag12is7sbjhgz5wlzfh94h-python3.7-cocotb-1.2.0        98.1M

@jonringer
Copy link
Contributor

@GrahamcOfBorg build python27Packages.cocotb python37Packages.cocotb python38Packages.cocotb

@jonringer
Copy link
Contributor

It seems that cocotb support darwin https://cocotb.readthedocs.io/en/latest/quickstart.html#macos-packages , it doesn't look like it's able to resolve gcc correctly, not sure if you all want to pursue mac support, or just mark this linux only

@matthuszagh
Copy link
Contributor Author

I don't know much about osx but happy to take a look if you think it's best to get that working too.

@jonringer
Copy link
Contributor

@marsam can you take a look at the failure logs for darwin, it essentially is saying:

gcc: command cannot be found

I was under the impression that clang is aliased to gcc in most darwin environments.

@marsam
Copy link
Contributor

marsam commented Oct 19, 2019

Looks like upstream has a makefile with gcc harcoded. It works with the following:

diff --git i/pkgs/development/python-modules/cocotb/default.nix w/pkgs/development/python-modules/cocotb/default.nix
index 228ac7904ec..e10ecd8e840 100644
--- i/pkgs/development/python-modules/cocotb/default.nix
+++ w/pkgs/development/python-modules/cocotb/default.nix
@@ -24,6 +24,9 @@ buildPythonPackage rec {
       cocotb/share/makefiles/simulators/Makefile.*
     do
       substituteInPlace $f --replace 'shell which' 'shell command -v'
+      # replace hardcoded gcc. Remove once https://github.com/cocotb/cocotb/pull/1137 gets merged
+      substituteInPlace $f --replace 'gcc' '$(CC)'
+      substituteInPlace $f --replace 'g++' '$(CXX)'
     done
   '';

@cmarqu
Copy link

cmarqu commented Oct 19, 2019

There is an open PR for cocotb to fix this and maybe more related problems: cocotb/cocotb#1137

@marsam marsam merged commit 253de2c into NixOS:master Oct 25, 2019
@marsam
Copy link
Contributor

marsam commented Oct 25, 2019

Thanks for your patience. I added the fix for darwin, I hope you don't mind.

@matthuszagh matthuszagh deleted the cocotb branch October 25, 2019 19:19
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