python3Packages.cocotb: fix build (#355818)

This commit is contained in:
Weijia Wang 2024-11-15 23:42:31 +01:00 committed by GitHub
commit 4f7829a614
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 25 additions and 76 deletions

View File

@ -1,26 +0,0 @@
From 94c4768cd69b026e498d92133dd6c7d8589cf911 Mon Sep 17 00:00:00 2001
From: Jiajie Chen <c@jia.je>
Date: Sat, 25 Jun 2022 10:19:44 +0800
Subject: [PATCH] Patch LDCXXSHARED for macOS along with LDSHARED
In Nixpkgs, we patched distutils to respect LDCXXSHARED environment, so
the replacement should be taken on LDCXXSHARED as well.
---
cocotb_build_libs.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/cocotb_build_libs.py b/cocotb_build_libs.py
index 66097ec2..d5555b36 100755
--- a/cocotb_build_libs.py
+++ b/cocotb_build_libs.py
@@ -583,6 +583,7 @@ def get_ext():
if sys.platform == "darwin":
cfg_vars["LDSHARED"] = cfg_vars["LDSHARED"].replace("-bundle", "-dynamiclib")
+ cfg_vars["LDCXXSHARED"] = cfg_vars["LDCXXSHARED"].replace("-bundle", "-dynamiclib")
share_lib_dir = os.path.relpath(os.path.join(cocotb_share_dir, "lib"))
include_dir = os.path.relpath(os.path.join(cocotb_share_dir, "include"))
--
2.36.1

View File

@ -1,25 +0,0 @@
diff --git a/tests/test_cases/test_cocotb/test_deprecated.py b/tests/test_cases/test_cocotb/test_deprecated.py
index 523b93ba..b4f1701e 100644
--- a/tests/test_cases/test_cocotb/test_deprecated.py
+++ b/tests/test_cases/test_cocotb/test_deprecated.py
@@ -26,20 +26,6 @@ async def test_returnvalue_deprecated(dut):
assert val == 42
-# strings are not supported on Icarus (gh-2585) or GHDL (gh-2584)
-@cocotb.test(
- expect_error=AttributeError
- if cocotb.SIM_NAME.lower().startswith("icarus")
- else TypeError
- if cocotb.SIM_NAME.lower().startswith("ghdl")
- else ()
-)
-async def test_unicode_handle_assignment_deprecated(dut):
- with pytest.warns(DeprecationWarning, match=".*bytes.*"):
- dut.stream_in_string.value = "Bad idea"
- await cocotb.triggers.ReadWrite()
-
-
@cocotb.test()
async def test_convert_handle_to_string_deprecated(dut):
dut.stream_in_data.value = 0

View File

@ -10,11 +10,13 @@
swig,
iverilog,
ghdl,
stdenv,
fetchpatch,
}:
buildPythonPackage rec {
pname = "cocotb";
version = "1.9.1";
version = "1.9.2";
format = "setuptools";
# pypi source doesn't include tests
@ -22,7 +24,7 @@ buildPythonPackage rec {
owner = "cocotb";
repo = "cocotb";
rev = "refs/tags/v${version}";
hash = "sha256-+pS+y9rmyJ4laDK5evAtoqr5D0GuHGaX6DpK1qtumnA=";
hash = "sha256-7KCo7g2I1rfm8QDHRm3ZKloHwjDIICnJCF8KhaFdvqY=";
};
nativeBuildInputs = [ setuptools-scm ];
@ -30,29 +32,25 @@ buildPythonPackage rec {
buildInputs = [ setuptools ];
propagatedBuildInputs = [ find-libpython ];
postPatch =
''
patchShebangs bin/*.py
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
# 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
# remove circular dependency cocotb-bus from setup.py
substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
'';
# remove circular dependency cocotb-bus from setup.py
substituteInPlace setup.py --replace "'cocotb-bus<1.0'" ""
'';
patches = [
# Fix "can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file" error
./0001-Patch-LDCXXSHARED-for-macOS-along-with-LDSHARED.patch
# For the 1.8.1 release only: remove the test_unicode_handle_assignment_deprecated test
# It's more thoroughly removed upstream master with 425e1edb8e7133f4a891f2f87552aa2748cd8d2c
./0002-Patch-remove-test_unicode_handle_assignment_deprecated-test.patch
disabledTests = [
# https://github.com/cocotb/cocotb/commit/425e1edb8e7133f4a891f2f87552aa2748cd8d2c#diff-4df986cbc2b1a3f22172caea94f959d8fcb4a128105979e6e99c68139469960cL33
"test_cocotb"
"test_cocotb_parallel"
];
nativeCheckInputs = [
@ -62,6 +60,7 @@ buildPythonPackage rec {
iverilog
ghdl
];
preCheck = ''
export PATH=$out/bin:$PATH
mv cocotb cocotb.hidden
@ -69,13 +68,14 @@ buildPythonPackage rec {
pythonImportsCheck = [ "cocotb" ];
meta = with lib; {
meta = {
changelog = "https://github.com/cocotb/cocotb/releases/tag/v${version}";
description = "Coroutine based cosimulation library for writing VHDL and Verilog testbenches in Python";
mainProgram = "cocotb-config";
homepage = "https://github.com/cocotb/cocotb";
license = licenses.bsd3;
maintainers = with maintainers; [
license = lib.licenses.bsd3;
broken = stdenv.hostPlatform.isDarwin;
maintainers = with lib.maintainers; [
matthuszagh
jleightcap
];