1{ lib
2, stdenv
3, buildPythonPackage
4, fetchPypi
5, setuptools
6, setuptools-scm
7, cocotb-bus
8, pytest
9, swig
10, verilog
11}:
12
13buildPythonPackage rec {
14 pname = "cocotb";
15 version = "1.5.2";
16
17 # - we need to use the tarball from PyPi
18 # or the full git checkout (with .git)
19 # - using fetchFromGitHub will cause a build failure,
20 # because it does not include required metadata
21 src = fetchPypi {
22 inherit pname version;
23 sha256 = "9f4f3e6eb9caeb479e98d604770645b57469cd25b39e28df1916ffcd593efbe6";
24 };
25
26 nativeBuildInputs = [ setuptools-scm ];
27
28 buildInputs = [ setuptools ];
29
30 postPatch = ''
31 patchShebangs bin/*.py
32
33 # POSIX portability (TODO: upstream this)
34 for f in \
35 cocotb/share/makefiles/Makefile.* \
36 cocotb/share/makefiles/simulators/Makefile.*
37 do
38 substituteInPlace $f --replace 'shell which' 'shell command -v'
39 done
40
41 # remove circular dependency cocotb-bus from setup.py
42 substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
43 '';
44
45 checkInputs = [ cocotb-bus pytest swig verilog ];
46
47 checkPhase = ''
48 export PATH=$out/bin:$PATH
49 make test
50 '';
51
52 meta = with lib; {
53 description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";
54 homepage = "https://github.com/cocotb/cocotb";
55 license = licenses.bsd3;
56 maintainers = with maintainers; [ matthuszagh ];
57 broken = stdenv.isDarwin;
58 };
59}