Merge pull request #307098 from r-ryantm/auto-update/cilium-cli
[NixPkgs.git] / pkgs / development / python-modules / cocotb / default.nix
blob8d996a4ebb0436149fcef26ccb6c063a9e476a6c
1 { lib
2 , stdenv
3 , buildPythonPackage
4 , fetchFromGitHub
5 , setuptools
6 , setuptools-scm
7 , cocotb-bus
8 , find-libpython
9 , pytestCheckHook
10 , swig
11 , verilog
12 , ghdl
15 buildPythonPackage rec {
16   pname = "cocotb";
17   version = "1.8.1";
18   format = "setuptools";
20   # pypi source doesn't include tests
21   src = fetchFromGitHub {
22     owner = "cocotb";
23     repo = "cocotb";
24     rev = "refs/tags/v${version}";
25     hash = "sha256-B7SePM8muEL3KFVOY7+OAgQVIRvTs6k29xASK9lgCB4=";
26   };
28   nativeBuildInputs = [ setuptools-scm ];
30   buildInputs = [ setuptools ];
31   propagatedBuildInputs = [ find-libpython ];
33   postPatch = ''
34     patchShebangs bin/*.py
36     # POSIX portability (TODO: upstream this)
37     for f in \
38       cocotb/share/makefiles/Makefile.* \
39       cocotb/share/makefiles/simulators/Makefile.*
40     do
41       substituteInPlace $f --replace 'shell which' 'shell command -v'
42     done
44     # remove circular dependency cocotb-bus from setup.py
45     substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
46   '' + lib.optionalString stdenv.isDarwin ''
47     # disable lto on darwin
48     # https://github.com/NixOS/nixpkgs/issues/19098
49     substituteInPlace cocotb_build_libs.py --replace "-flto" ""
50   '';
52   patches = [
53     # Fix "can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file" error
54     ./0001-Patch-LDCXXSHARED-for-macOS-along-with-LDSHARED.patch
56     # For the 1.8.1 release only: remove the test_unicode_handle_assignment_deprecated test
57     # It's more thoroughly removed upstream master with 425e1edb8e7133f4a891f2f87552aa2748cd8d2c
58     ./0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch
59   ];
61   nativeCheckInputs = [ cocotb-bus pytestCheckHook swig verilog ghdl ];
62   preCheck = ''
63     export PATH=$out/bin:$PATH
64     mv cocotb cocotb.hidden
65   '';
67   pythonImportsCheck = [ "cocotb" ];
69   meta = with lib; {
70     changelog = "https://github.com/cocotb/cocotb/releases/tag/v${version}";
71     description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";
72     mainProgram = "cocotb-config";
73     homepage = "https://github.com/cocotb/cocotb";
74     license = licenses.bsd3;
75     maintainers = with maintainers; [ matthuszagh jleightcap ];
76   };