2021-05-28 09:39:13 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, buildPythonPackage
|
2022-09-22 12:36:57 +00:00
|
|
|
, fetchFromGitHub
|
2021-05-28 09:39:13 +00:00
|
|
|
, setuptools
|
|
|
|
, setuptools-scm
|
|
|
|
, cocotb-bus
|
2023-05-24 13:37:59 +00:00
|
|
|
, find-libpython
|
2022-01-13 20:06:32 +00:00
|
|
|
, pytestCheckHook
|
2021-05-28 09:39:13 +00:00
|
|
|
, swig
|
|
|
|
, verilog
|
2023-08-10 07:59:29 +00:00
|
|
|
, ghdl
|
2021-05-28 09:39:13 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "cocotb";
|
2023-08-10 07:59:29 +00:00
|
|
|
version = "1.8.0";
|
2021-05-28 09:39:13 +00:00
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
# pypi source doesn't include tests
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "cocotb";
|
|
|
|
repo = "cocotb";
|
2023-01-20 10:41:00 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
2023-08-10 07:59:29 +00:00
|
|
|
hash = "sha256-k3VizQ9iyDawfDCeE3Zup/KkyD54tFBLdQvRKsbKDLY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-05-28 09:39:13 +00:00
|
|
|
nativeBuildInputs = [ setuptools-scm ];
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
buildInputs = [ setuptools ];
|
|
|
|
propagatedBuildInputs = [ find-libpython ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
patchShebangs bin/*.py
|
|
|
|
|
|
|
|
# POSIX portability (TODO: upstream this)
|
|
|
|
for f in \
|
|
|
|
cocotb/share/makefiles/Makefile.* \
|
|
|
|
cocotb/share/makefiles/simulators/Makefile.*
|
|
|
|
do
|
|
|
|
substituteInPlace $f --replace 'shell which' 'shell command -v'
|
|
|
|
done
|
2021-05-28 09:39:13 +00:00
|
|
|
|
|
|
|
# remove circular dependency cocotb-bus from setup.py
|
|
|
|
substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
|
2022-06-26 10:26:21 +00:00
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
|
|
|
# disable lto on darwin
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/19098
|
|
|
|
substituteInPlace cocotb_build_libs.py --replace "-flto" ""
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-06-26 10:26:21 +00:00
|
|
|
patches = [
|
|
|
|
# Fix "can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file" error
|
|
|
|
./0001-Patch-LDCXXSHARED-for-macOS-along-with-LDSHARED.patch
|
|
|
|
];
|
|
|
|
|
2023-08-10 07:59:29 +00:00
|
|
|
nativeCheckInputs = [ cocotb-bus pytestCheckHook swig verilog ghdl ];
|
2022-09-22 12:36:57 +00:00
|
|
|
preCheck = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
export PATH=$out/bin:$PATH
|
2022-09-22 12:36:57 +00:00
|
|
|
mv cocotb cocotb.hidden
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
pythonImportsCheck = [ "cocotb" ];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2023-08-10 07:59:29 +00:00
|
|
|
changelog = "https://github.com/cocotb/cocotb/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";
|
|
|
|
homepage = "https://github.com/cocotb/cocotb";
|
|
|
|
license = licenses.bsd3;
|
2023-08-10 07:59:29 +00:00
|
|
|
maintainers = with maintainers; [ matthuszagh jleightcap ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|