From fadd5dd5ae53ee5b9b185a71a665edcdcda3d63a Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Wed, 14 Apr 2021 15:57:58 +0200 Subject: [PATCH 1/2] python3Packages.cocotb-bus: init at 0.1.1 (cherry picked from commit ff555e8f887dd0097dbddcac0915618c673b2b51) --- .../python-modules/cocotb-bus/default.nix | 35 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 pkgs/development/python-modules/cocotb-bus/default.nix diff --git a/pkgs/development/python-modules/cocotb-bus/default.nix b/pkgs/development/python-modules/cocotb-bus/default.nix new file mode 100644 index 00000000000..af740e8d298 --- /dev/null +++ b/pkgs/development/python-modules/cocotb-bus/default.nix @@ -0,0 +1,35 @@ +{ lib +, stdenv +, buildPythonPackage +, fetchPypi +}: + +buildPythonPackage rec { + pname = "cocotb-bus"; + version = "0.1.1"; + + src = fetchPypi { + inherit pname version; + sha256 = "cc9b0bb00c95061a67f650caf96e3a294bb74ef437124dea456dd9e2a9431854"; + }; + + postPatch = '' + # remove circular dependency cocotb from setup.py + substituteInPlace setup.py --replace '"cocotb>=1.5.0.dev,<2.0"' "" + ''; + + # tests require cocotb, disable for now to avoid circular dependency + doCheck = false; + + # checkPhase = '' + # export PATH=$out/bin:$PATH + # make test + # ''; + + meta = with lib; { + description = "Pre-packaged testbenching tools and reusable bus interfaces for cocotb"; + homepage = "https://github.com/cocotb/cocotb-bus"; + license = licenses.bsd3; + maintainers = with maintainers; [ prusnak ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 2661bef8ed5..44b336da316 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1481,6 +1481,8 @@ in { cocotb = callPackage ../development/python-modules/cocotb { }; + cocotb-bus = callPackage ../development/python-modules/cocotb-bus { }; + codecov = callPackage ../development/python-modules/codecov { }; codespell = callPackage ../development/python-modules/codespell { }; From 1de0b0e5eb86b9ed8b6a28dd7ed65c74d9a58142 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sat, 13 Mar 2021 10:43:59 +0100 Subject: [PATCH 2/2] python3Packages.cocotb: 1.5.1 -> 1.5.2 this switches from GitHub to PyPi, because the build requires a proper release tarball also PyPi release does contain tests, so we don't strictly require GitHub checkout (cherry picked from commit 0f2201119b414aaf306dc8461a4095a4eb7399e5) --- .../python-modules/cocotb/default.nix | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/pkgs/development/python-modules/cocotb/default.nix b/pkgs/development/python-modules/cocotb/default.nix index b6343238383..17fe45f1cf4 100644 --- a/pkgs/development/python-modules/cocotb/default.nix +++ b/pkgs/development/python-modules/cocotb/default.nix @@ -1,19 +1,31 @@ -{ lib, stdenv, buildPythonPackage, fetchFromGitHub, setuptools, swig, verilog }: +{ lib +, stdenv +, buildPythonPackage +, fetchPypi +, setuptools +, setuptools-scm +, cocotb-bus +, pytest +, swig +, verilog +}: buildPythonPackage rec { pname = "cocotb"; - version = "1.5.1"; + version = "1.5.2"; - src = fetchFromGitHub { - owner = pname; - repo = pname; - rev = "v${version}"; - sha256 = "02bw2i03vd4rcvdk10qdjl2lbvvy81cn9qpr8vzq8cm9h45689mv"; + # - we need to use the tarball from PyPi + # or the full git checkout (with .git) + # - using fetchFromGitHub will cause a build failure, + # because it does not include required metadata + src = fetchPypi { + inherit pname version; + sha256 = "9f4f3e6eb9caeb479e98d604770645b57469cd25b39e28df1916ffcd593efbe6"; }; - propagatedBuildInputs = [ - setuptools - ]; + nativeBuildInputs = [ setuptools-scm ]; + + buildInputs = [ setuptools ]; postPatch = '' patchShebangs bin/*.py @@ -25,16 +37,14 @@ buildPythonPackage rec { do substituteInPlace $f --replace 'shell which' 'shell command -v' done + + # remove circular dependency cocotb-bus from setup.py + substituteInPlace setup.py --replace "'cocotb-bus<1.0'" "" ''; - checkInputs = [ swig verilog ]; + checkInputs = [ cocotb-bus pytest swig verilog ]; checkPhase = '' - # test expected failures actually pass because of a fix in our icarus version - # https://github.com/cocotb/cocotb/issues/1952 - substituteInPlace tests/test_cases/test_discovery/test_discovery.py \ - --replace 'def access_single_bit' $'def foo(x): pass\ndef foo' - export PATH=$out/bin:$PATH make test '';