@@ -0,0 +1,46 @@
1+{ stdenv, buildPythonPackage, fetchFromGitHub, setuptools, swig, verilog }:
2+
3+buildPythonPackage rec {
4+ pname = "cocotb";
5+ version = "1.2.0";
6+
7+ src = fetchFromGitHub {
8+ owner = pname;
9+ repo = pname;
10+ rev = "v${version}";
11+ sha256 = "091q63jcm87xggqgqi44lw2vjxhl1v4yl0mv2c76hgavb29w4w5y";
12+ };
13+
14+ propagatedBuildInputs = [
15+ setuptools
16+ ];
17+
18+ postPatch = ''
19+ patchShebangs bin/*.py
20+
21+ # POSIX portability (TODO: upstream this)
22+ for f in \
23+ cocotb/share/makefiles/Makefile.* \
24+ cocotb/share/makefiles/simulators/Makefile.*
25+ do
26+ substituteInPlace $f --replace 'shell which' 'shell command -v'
27+ # replace hardcoded gcc. Remove once https://github.com/cocotb/cocotb/pull/1137 gets merged
28+ substituteInPlace $f --replace 'gcc' '$(CC)'
29+ substituteInPlace $f --replace 'g++' '$(CXX)'
30+ done
31+ '';
32+
33+ checkInputs = [ swig verilog ];
34+
35+ checkPhase = ''
36+ export PATH=$out/bin:$PATH
37+ make test
38+ '';
39+
40+ meta = with stdenv.lib; {
41+ description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";
42+ homepage = https://github.com/cocotb/cocotb;
43+ license = licenses.bsd3;
44+ maintainers = with maintainers; [ matthuszagh ];
45+ };
46+}