python3Packages.pypcap: fix build on Python 3.9
This commit is contained in:
parent
a964d7094a
commit
90cca97297
@ -1,34 +1,50 @@
|
|||||||
{ lib, writeText, buildPythonPackage, fetchPypi, libpcap, dpkt }:
|
{ lib
|
||||||
|
, buildPythonPackage
|
||||||
|
, dpkt
|
||||||
|
, fetchFromGitHub
|
||||||
|
, fetchpatch
|
||||||
|
, libpcap
|
||||||
|
, pytestCheckHook
|
||||||
|
}:
|
||||||
|
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "pypcap";
|
pname = "pypcap";
|
||||||
version = "1.2.3";
|
version = "1.2.3";
|
||||||
|
|
||||||
src = fetchPypi {
|
|
||||||
inherit pname version;
|
src = fetchFromGitHub {
|
||||||
sha256 = "1w5i79gh7cswvznr8rhilcmzhnh2y5c4jwh2qrfnpx05zqigm1xd";
|
owner = "pynetwork";
|
||||||
|
repo = pname;
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "1zscfk10jpqwxgc8d84y8bffiwr92qrg2b24afhjwiyr352l67cf";
|
||||||
};
|
};
|
||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
# The default setup.py searchs for pcap.h in a static list of default
|
# Support for Python 3.9, https://github.com/pynetwork/pypcap/pull/102
|
||||||
# folders. So we have to add the path to libpcap in the nix-store.
|
(fetchpatch {
|
||||||
(writeText "libpcap-path.patch"
|
name = "support-python-3.9.patch";
|
||||||
''
|
url = "https://github.com/pynetwork/pypcap/pull/102/commits/e22f5d25f0d581d19ef337493434e72cd3a6ae71.patch";
|
||||||
--- a/setup.py
|
sha256 = "0n1syh1vcplgsf6njincpqphd2w030s3b2jyg86d7kbqv1w5wk0l";
|
||||||
+++ b/setup.py
|
})
|
||||||
@@ -28,6 +28,7 @@ def recursive_search(path, target_files):
|
|
||||||
|
|
||||||
def find_prefix_and_pcap_h():
|
|
||||||
prefixes = chain.from_iterable((
|
|
||||||
+ '${libpcap}',
|
|
||||||
('/usr', sys.prefix),
|
|
||||||
glob.glob('/opt/libpcap*'),
|
|
||||||
glob.glob('../libpcap*'),
|
|
||||||
'')
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
# Add the path to libpcap in the nix-store
|
||||||
|
substituteInPlace setup.py --replace "('/usr', sys.prefix)" "'${libpcap}'"
|
||||||
|
# Remove coverage from test run
|
||||||
|
sed -i "/--cov/d" setup.cfg
|
||||||
|
'';
|
||||||
|
|
||||||
buildInputs = [ libpcap ];
|
buildInputs = [ libpcap ];
|
||||||
checkInputs = [ dpkt ];
|
|
||||||
|
checkInputs = [
|
||||||
|
dpkt
|
||||||
|
pytestCheckHook
|
||||||
|
];
|
||||||
|
|
||||||
|
pytestFlagsArray = [ "tests" ];
|
||||||
|
|
||||||
|
pythonImportsCheck = [ "pcap" ];
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
homepage = "https://github.com/pynetwork/pypcap";
|
homepage = "https://github.com/pynetwork/pypcap";
|
||||||
|
Loading…
Reference in New Issue
Block a user