From ea35d4f26f9a788d7504106d24f1ae228872c45c Mon Sep 17 00:00:00 2001 From: gpotter2 <10530980+gpotter2@users.noreply.github.com> Date: Tue, 24 Jan 2023 00:06:36 +0100 Subject: [PATCH 1/3] Migrate to `pyproject.toml` Co-authored-by: KOLANICH --- README.md | 3 +- pyproject.toml | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++ setup.cfg | 26 -------------- setup.py | 87 +++++++++------------------------------------ tox.ini | 5 +-- 5 files changed, 117 insertions(+), 100 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.cfg diff --git a/README.md b/README.md index c1aa4d05ea1..d71f4115759 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,7 @@ Other useful resources: - [Scapy in 20 minutes](https://github.com/secdev/scapy/blob/master/doc/notebooks/Scapy%20in%2015%20minutes.ipynb) - [Interactive tutorial](https://scapy.readthedocs.io/en/latest/usage.html#interactive-tutorial) (part of the documentation) -- [The quick demo: an interactive session](https://scapy.readthedocs.io/en/latest/introduction.html#quick-demo) -(some examples may be outdated) +- [The quick demo: an interactive session](https://scapy.readthedocs.io/en/latest/introduction.html#quick-demo) (some examples may be outdated) - [HTTP/2 notebook](https://github.com/secdev/scapy/blob/master/doc/notebooks/HTTP_2_Tuto.ipynb) - [TLS notebooks](https://github.com/secdev/scapy/blob/master/doc/notebooks/tls) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000000..acd9e731a22 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,96 @@ +[build-system] +requires = [ "setuptools>=61.1" ] +build-backend = "setuptools.build_meta" + +[project] +name = "scapy" +dynamic = [ "version", "readme" ] +authors = [ + { name="Philippe BIONDI" }, +] +maintainers = [ + { name="Pierre LALET" }, + { name="Gabriel POTTER" }, + { name="Guillaume VALADON" }, +] +license = { text="GPL-2.0-only" } +requires-python = ">=3.7, <4" +description = "Scapy: interactive packet manipulation tool" +keywords = [ "network" ] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Intended Audience :: Developers", + "Intended Audience :: Information Technology", + "Intended Audience :: Science/Research", + "Intended Audience :: System Administrators", + "Intended Audience :: Telecommunications Industry", + "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Topic :: Security", + "Topic :: System :: Networking", + "Topic :: System :: Networking :: Monitoring", +] + +[project.urls] +homepage = "https://scapy.net" +documentation = "https://scapy.readthedocs.io" +repository = "https://github.com/secdev/scapy" +changelog = "https://github.com/secdev/scapy/releases" + +[project.scripts] +scapy = "scapy.main:interact" + +[project.optional-dependencies] +basic = [ "ipython" ] +complete = [ + "ipython", + "pyx", + "cryptography>=2.0", + "matplotlib", +] +docs = [ + "sphinx>=3.0.0", + "sphinx_rtd_theme>=0.4.3", + "tox>=3.0.0", +] + +# setuptools specific + +[tool.setuptools] +zip-safe = false # We use __file__ in scapy/__init__.py, therefore Scapy isn't zip safe + +[tool.setuptools.packages.find] +include = [ + "scapy*", +] +exclude = [ + "test*", + "doc*", +] + +[tool.setuptools.dynamic] +version = { attr="scapy.VERSION" } + +# coverage + +[tool.coverage] +concurrency = "multiprocessing" +omit = [ + # Scapy specific paths + "scapy/tools/UTscapy.py", + "test/*", + # Scapy external modules + "scapy/libs/six.py", + "scapy/libs/winpcapy.py", + "scapy/libs/ethertypes.py", + # .tox specific path + ".tox/*", + # OS specific paths + "/private/*", +] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index cbb75683e6c..00000000000 --- a/setup.cfg +++ /dev/null @@ -1,26 +0,0 @@ -[bdist_wheel] -universal = 1 - -[metadata] -description-file = README.md -license_file = LICENSE - -[sdist] -formats=gztar -owner=root -group=root - -[coverage:run] -concurrency = multiprocessing -omit = - # Scapy specific paths - scapy/tools/UTscapy.py - test/* - # Scapy external modules - scapy/modules/six.py - scapy/libs/winpcapy.py - scapy/libs/ethertypes.py - # .tox specific path - .tox/* - # OS specific paths - /private/* diff --git a/setup.py b/setup.py index aec60fb6e5c..e39245572e2 100755 --- a/setup.py +++ b/setup.py @@ -1,20 +1,27 @@ #! /usr/bin/env python """ -Distutils setup file for Scapy. +Setuptools setup file for Scapy. """ +import io +import os +import sys + +if sys.version_info[0] <= 2: + raise OSError("Scapy no longer supports Python 2 ! Please use Scapy 2.5.0") + try: - from setuptools import setup, find_packages + from setuptools import setup from setuptools.command.sdist import sdist except: raise ImportError("setuptools is required to install scapy !") -import io -import os def get_long_description(): - """Extract description from README.md, for PyPI's usage""" + """ + Extract description from README.md, for PyPI's usage + """ def process_ignore_tags(buffer): return "\n".join( x for x in buffer.split("\n") if "" not in x @@ -31,78 +38,18 @@ def process_ignore_tags(buffer): class SDist(sdist): - - def make_release_tree(self, base_dir, files): - sdist.make_release_tree(self, base_dir, files) + """ + Modified sdist to create scapy/VERSION file + """ + def make_release_tree(self, base_dir, *args, **kwargs): + super(SDist, self).make_release_tree(base_dir, *args, **kwargs) # ensure there's a scapy/VERSION file fn = os.path.join(base_dir, 'scapy', 'VERSION') with open(fn, 'w') as f: f.write(__import__('scapy').VERSION) - -# https://packaging.python.org/guides/distributing-packages-using-setuptools/ setup( - name='scapy', - version=__import__('scapy').VERSION, - packages=find_packages(exclude=["test"]), - data_files=[('share/man/man1', ["doc/scapy.1"])], cmdclass={'sdist': SDist}, - # Build starting scripts automatically - entry_points={ - 'console_scripts': [ - 'scapy = scapy.main:interact' - ] - }, - python_requires='>=3.7, <4', - # pip > 9 handles all the versioning - extras_require={ - 'basic': ["ipython"], - 'complete': [ - 'ipython', - 'pyx', - 'cryptography>=2.0', - 'matplotlib' - ], - 'docs': [ - 'sphinx>=3.0.0', - 'sphinx_rtd_theme>=0.4.3', - 'tox>=3.0.0' - ] - }, - # We use __file__ in scapy/__init__.py, therefore Scapy isn't zip safe - zip_safe=False, - - # Metadata - author='Philippe BIONDI', - author_email='phil(at)secdev.org', - maintainer='Pierre LALET, Gabriel POTTER, Guillaume VALADON', - description='Scapy: interactive packet manipulation tool', long_description=get_long_description(), long_description_content_type='text/markdown', - license='GPL-2.0-only', - url='https://scapy.net', - project_urls={ - 'Documentation': 'https://scapy.readthedocs.io', - 'Source Code': 'https://github.com/secdev/scapy/', - }, - download_url='https://github.com/secdev/scapy/tarball/master', - keywords=["network"], - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: Science/Research", - "Intended Audience :: System Administrators", - "Intended Audience :: Telecommunications Industry", - "License :: OSI Approved :: GNU General Public License v2 (GPLv2)", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Topic :: Security", - "Topic :: System :: Networking", - "Topic :: System :: Networking :: Monitoring", - ] ) diff --git a/tox.ini b/tox.ini index 90957573a75..60eea282944 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ envlist = py{27,34,35,36,37,38,39,310,py27,py39}-{linux,bsd}_{non_root,root}, py{27,34,35,36,37,38,39,310,py27,py39}-windows, skip_missing_interpreters = true -minversion = 2.9 +minversion = 4.0 # Main tests @@ -14,6 +14,7 @@ minversion = 2.9 description = "Scapy unit tests" allowlist_externals = sudo parallel_show_output = true +package = wheel passenv = PATH PWD @@ -28,7 +29,7 @@ deps = mock setuptools>=18.5 ipython cryptography - coverage + coverage[toml] python-can # disabled on windows because they require c++ dependencies brotli ; sys_platform != 'win32' From 1f39182ea778bde14d1f937659d30b2007d2d49e Mon Sep 17 00:00:00 2001 From: gpotter2 <10530980+gpotter2@users.noreply.github.com> Date: Sat, 28 Jan 2023 00:39:32 +0100 Subject: [PATCH 2/3] Bump setuptools to 62.0.0 Otherwise we suffer from the bug described in pypa/setuptools, #3244 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index acd9e731a22..ef7f4453fac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = [ "setuptools>=61.1" ] +requires = [ "setuptools>=62.0.0" ] build-backend = "setuptools.build_meta" [project] From 35d9e647af810ceb0ce46c28901e7dae73472636 Mon Sep 17 00:00:00 2001 From: gpotter2 <10530980+gpotter2@users.noreply.github.com> Date: Tue, 31 Jan 2023 21:55:31 +0100 Subject: [PATCH 3/3] Codecov: xml upload --- .github/workflows/unittests.yml | 4 +--- .gitignore | 1 + tox.ini | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/unittests.yml b/.github/workflows/unittests.yml index f9f8e5cae45..ddd0961335b 100644 --- a/.github/workflows/unittests.yml +++ b/.github/workflows/unittests.yml @@ -125,9 +125,7 @@ jobs: - name: Run Tox run: UT_FLAGS="${{ matrix.flags }}" ./.config/ci/test.sh ${{ matrix.python }} ${{ matrix.mode }} - name: Codecov - uses: codecov/codecov-action@v2 - with: - file: /home/runner/work/scapy/scapy/.coverage + uses: codecov/codecov-action@v3 cryptography: name: pyca/cryptography test diff --git a/.gitignore b/.gitignore index fa3030f1bb2..87aaa035354 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ MANIFEST *.egg-info/ test/*.html .coverage* +coverage.xml .tox .ipynb_checkpoints .mypy_cache diff --git a/tox.ini b/tox.ini index 60eea282944..50466219968 100644 --- a/tox.ini +++ b/tox.ini @@ -44,7 +44,7 @@ commands = bsd_non_root: {envpython} {env:SCAPY_PY_OPTS:-m coverage run} -m scapy.tools.UTscapy -c test/configs/bsd.utsc -K manufdb -K tshark -N {posargs} bsd_root: sudo -E {envpython} {env:SCAPY_PY_OPTS:-m coverage run} -m scapy.tools.UTscapy -c test/configs/bsd.utsc -K manufdb -K tshark {posargs} windows: {envpython} {env:SCAPY_PY_OPTS:-m coverage run} -m scapy.tools.UTscapy -c test/configs/windows.utsc {posargs} - coverage combine + coverage xml -i # Variants of the main tests @@ -72,7 +72,7 @@ commands = bash -c "rm -rf /tmp/can-utils /tmp/can-isotp" lsmod sudo -E {envpython} -m coverage run -m scapy.tools.UTscapy -c ./test/configs/linux.utsc {posargs} - coverage combine + coverage xml -i # Test used by upstream pyca/cryptography [testenv:cryptography]