Skip to content

Commit ddbc12a

Browse files
authored
Merge pull request oremanj#76 from oremanj/release-v0.9.0
Release v0.9.0
2 parents ed4a63d + 8d3193f commit ddbc12a

9 files changed

+29
-21
lines changed

CHANGES.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
v0.9.0, unreleased
1+
v0.9.0, 12 Jan 2021
22
Improve usability when Packet objects are retained past the callback
33
Add Packet.retain() to save the packet contents in such cases
44
Eliminate warnings during build on py3
55
Add CI and basic test suite
66
Raise a warning, not an error, if we don't get the bufsize we want
7-
Don't allow bind() more than once on the same NetfilterQueue, since
8-
that would leak the old queue handle
7+
Don't allow bind() more than once on the same NetfilterQueue, since that would leak the old queue handle
8+
** This will be the last version with support for Python 2.7. **
99

1010
v0.8.1, 30 Jan 2017
1111
Fix bug #25- crashing when used in OUTPUT or POSTROUTING chains

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ include *.rst
33
include *.c
44
include *.pyx
55
include *.pxd
6+
recursive-include tests/ *.py

ci.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ set -ex -o pipefail
55
pip install -U pip setuptools wheel
66
sudo apt-get install libnetfilter-queue-dev
77

8+
# Cython is required to build the sdist...
9+
pip install cython
810
python setup.py sdist --formats=zip
11+
12+
# ... but not to install it
13+
pip uninstall -y cython
914
pip install dist/*.zip
1015

1116
if python --version 2>&1 | fgrep -q "Python 2.7"; then

netfilterqueue.pyx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ function.
55
Copyright: (c) 2011, Kerkhoff Technologies Inc.
66
License: MIT; see LICENSE.txt
77
"""
8-
VERSION = (0, 8, 1)
8+
VERSION = (0, 9, 0)
99

1010
# Constants for module users
1111
COPY_NONE = 0
@@ -24,21 +24,13 @@ DEF SockCopySize = MaxCopySize + SockOverhead
2424
# Socket queue should hold max number of packets of copysize bytes
2525
DEF SockRcvSize = DEFAULT_MAX_QUEUELEN * SockCopySize // 2
2626

27-
cdef extern from "Python.h":
28-
const char* __FILE__
29-
int __LINE__
30-
3127
cdef extern from *:
3228
"""
3329
#if PY_MAJOR_VERSION < 3
3430
#define PyBytes_FromStringAndSize PyString_FromStringAndSize
3531
#endif
3632
"""
3733

38-
import socket
39-
import warnings
40-
cimport cpython.version
41-
4234
cdef int global_callback(nfq_q_handle *qh, nfgenmsg *nfmsg,
4335
nfq_data *nfa, void *data) with gil:
4436
"""Create a Packet and pass it to appropriate callback."""
@@ -227,11 +219,11 @@ cdef class NetfilterQueue:
227219
newsiz = nfnl_rcvbufsiz(nfq_nfnlh(self.h), sock_len)
228220
if newsiz != sock_len * 2:
229221
try:
230-
warnings.warn_explicit(
222+
import warnings
223+
224+
warnings.warn(
231225
"Socket rcvbuf limit is now %d, requested %d." % (newsiz, sock_len),
232226
category=RuntimeWarning,
233-
filename=bytes(__FILE__).decode("ascii"),
234-
lineno=__LINE__,
235227
)
236228
except: # if warnings are being treated as errors
237229
self.unbind()
@@ -267,6 +259,8 @@ cdef class NetfilterQueue:
267259

268260
def run_socket(self, s):
269261
"""Accept packets using socket.recv so that, for example, gevent can monkeypatch it."""
262+
import socket
263+
270264
while True:
271265
try:
272266
buf = s.recv(BufferSize)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["setuptools >= 42", "wheel", "cython"]
2+
requires = ["setuptools", "wheel"]
33
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import os, sys
12
from setuptools import setup, Extension
23

3-
VERSION = "0.8.1" # Remember to change CHANGES.txt and netfilterqueue.pyx when version changes.
4+
VERSION = "0.9.0" # Remember to change CHANGES.txt and netfilterqueue.pyx when version changes.
45

56
try:
67
# Use Cython
@@ -14,6 +15,14 @@
1415
)
1516
except ImportError:
1617
# No Cython
18+
if not os.path.exists(os.path.join(os.path.dirname(__file__), "netfilterqueue.c")):
19+
sys.stderr.write(
20+
"You must have Cython installed (`pip install cython`) to build this "
21+
"package from source.\nIf you're receiving this error when installing from "
22+
"PyPI, please file a bug report at "
23+
"https://github.com/oremanj/python-netfilterqueue/issues/new\n"
24+
)
25+
sys.exit(1)
1726
ext_modules = [
1827
Extension("netfilterqueue", ["netfilterqueue.c"], libraries=["netfilter_queue"])
1928
]

test-requirements.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ pytest
33
trio
44
pytest-trio
55
async_generator
6-
cython
76
black
87
platformdirs <= 2.4.0 # needed by black; 2.4.1+ don't support py3.6

test-requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ black==21.12b0
1818
# via -r test-requirements.in
1919
click==8.0.3
2020
# via black
21-
cython==0.29.26
22-
# via -r test-requirements.in
2321
idna==3.3
2422
# via trio
2523
iniconfig==1.1.1

tests/test_basic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,12 @@ def set_udp_payload(p, msg):
7979

8080

8181
async def test_errors(harness):
82-
with pytest.warns(RuntimeWarning, match="rcvbuf limit is"):
82+
with pytest.warns(RuntimeWarning, match="rcvbuf limit is") as record:
8383
async with harness.capture_packets_to(2, sock_len=2 ** 30):
8484
pass
8585

86+
assert record[0].filename.endswith("conftest.py")
87+
8688
async with harness.capture_packets_to(2, queue_num=0):
8789
with pytest.raises(OSError, match="Failed to create queue"):
8890
async with harness.capture_packets_to(2, queue_num=0):

0 commit comments

Comments
 (0)