Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/1.3.0 #109

Merged
merged 6 commits into from
Sep 12, 2022
Merged

Release/1.3.0 #109

merged 6 commits into from
Sep 12, 2022

Conversation

hellais
Copy link
Member

@hellais hellais commented Sep 5, 2022

Branch for the upcoming 1.3.0 release.

Fixes:

  • Support Python 3.9

Adds:

  • Support for pcap_set_buffer_size via buffer_size option

@slhck
Copy link

slhck commented Sep 5, 2022

Thanks for taking the time to make a new release!

Given that now Python 3.10 is the most recent release, it would make sense to already include it when doing a new release. Maybe it's enough to just add the respective metadata, and it will work.

@hellais
Copy link
Member Author

hellais commented Sep 5, 2022

Given that now Python 3.10 is the most recent release, it would make sense to already include it when doing a new release. Maybe it's enough to just add the respective metadata, and it will work.

The version bumps in the tox.ini and .travis.yml files don't really have an impact on wether or not it will work on a certain version of python or not (they are only relevant WRT the CI which currently doesn't work).

What does impact it, is the version of cython used to build the pcap.c file from pcap.pyx. For this branch I have used the latest version of cython, so it should in theory work also in python 3.10.

That said, if you have that version of python available to do some testing that would be fantastic.

@slhck
Copy link

slhck commented Sep 5, 2022

I would love to try but I am on macOS Big Sur and I'm getting hit by #104. Will report back once I have access to a Linux machine.

@mwfong-csl
Copy link

@slhck: here's a version of setup.py that uses ctypes to address #104. If it works, I can create a merge request.

setup_py.zip

@tulay
Copy link

tulay commented Sep 6, 2022

  • py38
  • py39
  • py310
tox -e py38
GLOB sdist-make: /home/tly/PYPCAP/pypcap/setup.py
py38 inst-nodeps: /home/tly/PYPCAP/pypcap/.tox/.tmp/package/1/pypcap-1.3.0.zip
py38 installed: attrs==22.1.0,coverage==6.4.4,Cython==0.29.32,dpkt==1.9.8,iniconfig==1.1.1,packaging==21.3,pluggy==1.0.0,py==1.11.0,pyparsing==3.0.9,pypcap @ file:///home/tly/PYPCAP/pypcap/.tox/.tmp/package/1/pypcap-1.3.0.zip,pytest==7.1.3,pytest-cov==3.0.0,tomli==2.0.1
py38 run-test-pre: PYTHONHASHSEED='859669529'
py38 run-test: commands[0] | pip install -e .
Obtaining file:///home/tly/PYPCAP/pypcap
  Preparing metadata (setup.py) ... done
Installing collected packages: pypcap
  Attempting uninstall: pypcap
    Found existing installation: pypcap 1.3.0
    Uninstalling pypcap-1.3.0:
      Successfully uninstalled pypcap-1.3.0
  Running setup.py develop for pypcap
Successfully installed pypcap-1.3.0
py38 run-test: commands[1] | pytest tests --cov=tests
============================================================ test session starts ============================================================
platform linux -- Python 3.8.13, pytest-7.1.3, pluggy-1.0.0 -- /home/tly/PYPCAP/pypcap/.tox/py38/bin/python
cachedir: .tox/py38/.pytest_cache
rootdir: /home/tly/PYPCAP/pypcap, configfile: setup.cfg
plugins: cov-3.0.0
collected 11 items                                                                                                                          

tests/test.py::test_pcap_iter PASSED                                                                                                  [  9%]
tests/test.py::test_pcap_iter_ns PASSED                                                                                               [ 18%]
tests/test.py::test_pcap_properties PASSED                                                                                            [ 27%]
tests/test.py::test_pcap_errors PASSED                                                                                                [ 36%]
tests/test.py::test_pcap_dispatch PASSED                                                                                              [ 45%]
tests/test.py::test_pcap_dispatch_ns PASSED                                                                                           [ 54%]
tests/test.py::test_pcap_dispatch_exception PASSED                                                                                    [ 63%]
tests/test.py::test_pcap_readpkts PASSED                                                                                              [ 72%]
tests/test.py::test_pcap_overwritten PASSED                                                                                           [ 81%]
tests/test.py::test_pcap_loop_overwritten PASSED                                                                                      [ 90%]
tests/test.py::test_unicode PASSED                                                                                                    [100%]

---------- coverage: platform linux, python 3.8.13-final-0 -----------
Name                 Stmts   Miss  Cover   Missing
--------------------------------------------------
tests/test.py          137     17    88%   156-157, 177, 179, 196-198, 202-212
tests/testsniff.py      48     38    21%   11-21, 25-29, 33-34, 38-40, 44-75, 78
--------------------------------------------------
TOTAL                  185     55    70%


============================================================ 11 passed in 0.74s =============================================================
__________________________________________________________________ summary __________________________________________________________________
  py38: commands succeeded
  congratulations :)

tox -e py39
GLOB sdist-make: /home/tly/PYPCAP/pypcap/setup.py
py39 create: /home/tly/PYPCAP/pypcap/.tox/py39
py39 installdeps: coverage, -rrequirements-devel.txt
py39 inst: /home/tly/PYPCAP/pypcap/.tox/.tmp/package/1/pypcap-1.3.0.zip
py39 installed: attrs==22.1.0,coverage==6.4.4,Cython==0.29.32,dpkt==1.9.8,iniconfig==1.1.1,packaging==21.3,pluggy==1.0.0,py==1.11.0,pyparsing==3.0.9,pypcap @ file:///home/tly/PYPCAP/pypcap/.tox/.tmp/package/1/pypcap-1.3.0.zip,pytest==7.1.3,pytest-cov==3.0.0,tomli==2.0.1
py39 run-test-pre: PYTHONHASHSEED='1047467731'
py39 run-test: commands[0] | pip install -e .
Obtaining file:///home/tly/PYPCAP/pypcap
  Preparing metadata (setup.py) ... done
Installing collected packages: pypcap
  Attempting uninstall: pypcap
    Found existing installation: pypcap 1.3.0
    Uninstalling pypcap-1.3.0:
      Successfully uninstalled pypcap-1.3.0
  Running setup.py develop for pypcap
Successfully installed pypcap-1.3.0
py39 run-test: commands[1] | pytest tests --cov=tests
=================================================== test session starts ====================================================
platform linux -- Python 3.9.13, pytest-7.1.3, pluggy-1.0.0 -- /home/tly/PYPCAP/pypcap/.tox/py39/bin/python
cachedir: .tox/py39/.pytest_cache
rootdir: /home/tly/PYPCAP/pypcap, configfile: setup.cfg
plugins: cov-3.0.0
collected 11 items                                                                                                         

tests/test.py::test_pcap_iter PASSED                                                                                 [  9%]
tests/test.py::test_pcap_iter_ns PASSED                                                                              [ 18%]
tests/test.py::test_pcap_properties PASSED                                                                           [ 27%]
tests/test.py::test_pcap_errors PASSED                                                                               [ 36%]
tests/test.py::test_pcap_dispatch PASSED                                                                             [ 45%]
tests/test.py::test_pcap_dispatch_ns PASSED                                                                          [ 54%]
tests/test.py::test_pcap_dispatch_exception PASSED                                                                   [ 63%]
tests/test.py::test_pcap_readpkts PASSED                                                                             [ 72%]
tests/test.py::test_pcap_overwritten PASSED                                                                          [ 81%]
tests/test.py::test_pcap_loop_overwritten PASSED                                                                     [ 90%]
tests/test.py::test_unicode PASSED                                                                                   [100%]

---------- coverage: platform linux, python 3.9.13-final-0 -----------
Name                 Stmts   Miss  Cover   Missing
--------------------------------------------------
tests/test.py          137     17    88%   156-157, 177, 179, 196-198, 202-212
tests/testsniff.py      48     38    21%   11-21, 25-29, 33-34, 38-40, 44-75, 78
--------------------------------------------------
TOTAL                  185     55    70%


==================================================== 11 passed in 2.63s ====================================================
_________________________________________________________ summary __________________________________________________________
  py39: commands succeeded
  congratulations :)
  
  tox -e py310
GLOB sdist-make: /home/tly/PYPCAP/pypcap/setup.py
py310 create: /home/tly/PYPCAP/pypcap/.tox/py310
py310 installdeps: coverage, -rrequirements-devel.txt
py310 inst: /home/tly/PYPCAP/pypcap/.tox/.tmp/package/1/pypcap-1.3.0.zip
py310 installed: attrs==22.1.0,coverage==6.4.4,Cython==0.29.32,dpkt==1.9.8,iniconfig==1.1.1,packaging==21.3,pluggy==1.0.0,py==1.11.0,pyparsing==3.0.9,pypcap @ file:///home/tly/PYPCAP/pypcap/.tox/.tmp/package/1/pypcap-1.3.0.zip,pytest==7.1.3,pytest-cov==3.0.0,tomli==2.0.1
py310 run-test-pre: PYTHONHASHSEED='3859892302'
py310 run-test: commands[0] | pip install -e .
Obtaining file:///home/tly/PYPCAP/pypcap
  Preparing metadata (setup.py) ... done
Installing collected packages: pypcap
  Attempting uninstall: pypcap
    Found existing installation: pypcap 1.3.0
    Uninstalling pypcap-1.3.0:
      Successfully uninstalled pypcap-1.3.0
  Running setup.py develop for pypcap
Successfully installed pypcap-1.3.0
py310 run-test: commands[1] | pytest tests --cov=tests
============================================================ test session starts ============================================================
platform linux -- Python 3.10.6, pytest-7.1.3, pluggy-1.0.0 -- /home/tly/PYPCAP/pypcap/.tox/py310/bin/python
cachedir: .tox/py310/.pytest_cache
rootdir: /home/tly/PYPCAP/pypcap, configfile: setup.cfg
plugins: cov-3.0.0
collected 11 items                                                                                                                          

tests/test.py::test_pcap_iter PASSED                                                                                                  [  9%]
tests/test.py::test_pcap_iter_ns PASSED                                                                                               [ 18%]
tests/test.py::test_pcap_properties PASSED                                                                                            [ 27%]
tests/test.py::test_pcap_errors PASSED                                                                                                [ 36%]
tests/test.py::test_pcap_dispatch PASSED                                                                                              [ 45%]
tests/test.py::test_pcap_dispatch_ns PASSED                                                                                           [ 54%]
tests/test.py::test_pcap_dispatch_exception PASSED                                                                                    [ 63%]
tests/test.py::test_pcap_readpkts PASSED                                                                                              [ 72%]
tests/test.py::test_pcap_overwritten PASSED                                                                                           [ 81%]
tests/test.py::test_pcap_loop_overwritten PASSED                                                                                      [ 90%]
tests/test.py::test_unicode PASSED                                                                                                    [100%]

---------- coverage: platform linux, python 3.10.6-final-0 -----------
Name                 Stmts   Miss  Cover   Missing
--------------------------------------------------
tests/test.py          137     17    88%   156-157, 177, 179, 196-198, 202-212
tests/testsniff.py      48     38    21%   11-21, 25-29, 33-34, 38-40, 44-75, 78
--------------------------------------------------
TOTAL                  185     55    70%


============================================================ 11 passed in 2.52s =============================================================
__________________________________________________________________ summary __________________________________________________________________
  py310: commands succeeded
  congratulations :)


@hellais
Copy link
Member Author

hellais commented Sep 7, 2022

Thanks to everyone who tested this release.

here's a version of setup.py that uses ctypes to address #104. If it works, I can create a merge request.

I took a look at the diff and it seems good to me. We might even want to do use ctypes find_library before our recursive library finder and this is likely to be much faster since it's using OS specific strategies.

From inspecting the find_library, though, it seems like you don't need to pass the full filename of the library, but only the library name, since it appends to it the prefixes (see:
https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L65 &
https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L73 & https://github.com/python/cpython/blob/main/Lib/ctypes/util.py#L107).

If you could file a PR with this improvement we can include it in the 1.3.0 release.

mwfong-csl pushed a commit to mwfong-csl/pypcap that referenced this pull request Sep 7, 2022
mwfong-csl pushed a commit to mwfong-csl/pypcap that referenced this pull request Sep 7, 2022
@mwfong-csl
Copy link

I've created a fork, https://github.com/mwfong-csl/pypcap/tree/issue-104, that incorporates @hellais's suggestions. However, because my Mac isn't running Big Sur, could someone please test? Once that's done, I'll issue a PR.

@slhck
Copy link

slhck commented Sep 8, 2022

This is what I get when installing your fork under macOS 12.5.1 with libpcap installed from Homebrew:

$ pip3 install .            
Processing /Users/werner/Documents/Software/pypcap-fork
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [2 lines of output]
      Found pcap headers in /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include/pcap.h
      None of the following found: ['libpcap.a', 'libpcap.so', 'libpcap.dylib', 'wpcap.lib']
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have also tried this with the following suggestions from Homebrew:

For compilers to find libpcap you may need to set:
  export LDFLAGS="-L/opt/homebrew/opt/libpcap/lib"
  export CPPFLAGS="-I/opt/homebrew/opt/libpcap/include"

For pkg-config to find libpcap you may need to set:
  export PKG_CONFIG_PATH="/opt/homebrew/opt/libpcap/lib/pkgconfig"

@hellais
Copy link
Member Author

hellais commented Sep 12, 2022

I suspect we are going to have to change the logic in how we lookup the headers too in the setup.py to get it work as expected since it's assuming that the path prefix for where it found the header matches the location of the library (which is important because we should not be using a different header compared to the library we link to).

I think fixing it to work with macOS 12.x is going to require a bit more debugging and unfortunately I don't at the moment have a macOS 12.x machine at hand to look into it.

I think what I'm going to do is cut the next release and as soon as we have something working for macOS 12 we can make a follow up release which includes a fix for that too.

@hellais hellais merged commit 968859f into master Sep 12, 2022
@hellais hellais deleted the release/1.3.0 branch September 12, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants