1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 setuptools,
6 setuptools-scm,
7 cocotb-bus,
8 find-libpython,
9 pytestCheckHook,
10 swig,
11 iverilog,
12 ghdl,
13 stdenv,
14}:
15
16buildPythonPackage rec {
17 pname = "cocotb";
18 version = "1.9.2";
19 format = "setuptools";
20
21 # pypi source doesn't include tests
22 src = fetchFromGitHub {
23 owner = "cocotb";
24 repo = "cocotb";
25 tag = "v${version}";
26 hash = "sha256-7KCo7g2I1rfm8QDHRm3ZKloHwjDIICnJCF8KhaFdvqY=";
27 };
28
29 nativeBuildInputs = [ setuptools-scm ];
30
31 buildInputs = [ setuptools ];
32 propagatedBuildInputs = [ find-libpython ];
33
34 postPatch = ''
35 patchShebangs bin/*.py
36
37 # POSIX portability (TODO: upstream this)
38 for f in \
39 cocotb/share/makefiles/Makefile.* \
40 cocotb/share/makefiles/simulators/Makefile.*
41 do
42 substituteInPlace $f --replace 'shell which' 'shell command -v'
43 done
44
45 # remove circular dependency cocotb-bus from setup.py
46 substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
47 '';
48
49 disabledTests = [
50 # https://github.com/cocotb/cocotb/commit/425e1edb8e7133f4a891f2f87552aa2748cd8d2c#diff-4df986cbc2b1a3f22172caea94f959d8fcb4a128105979e6e99c68139469960cL33
51 "test_cocotb"
52 "test_cocotb_parallel"
53 ];
54
55 nativeCheckInputs = [
56 cocotb-bus
57 pytestCheckHook
58 swig
59 iverilog
60 ghdl
61 ];
62
63 preCheck = ''
64 export PATH=$out/bin:$PATH
65 mv cocotb cocotb.hidden
66 '';
67
68 pythonImportsCheck = [ "cocotb" ];
69
70 meta = {
71 changelog = "https://github.com/cocotb/cocotb/releases/tag/v${version}";
72 description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";
73 mainProgram = "cocotb-config";
74 homepage = "https://github.com/cocotb/cocotb";
75 license = lib.licenses.bsd3;
76 broken = stdenv.hostPlatform.isDarwin;
77 maintainers = with lib.maintainers; [
78 matthuszagh
79 jleightcap
80 ];
81 };
82}