Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions bin/UTscapy

This file was deleted.

4 changes: 0 additions & 4 deletions bin/UTscapy.bat

This file was deleted.

25 changes: 0 additions & 25 deletions bin/scapy

This file was deleted.

4 changes: 0 additions & 4 deletions bin/scapy.bat

This file was deleted.

3 changes: 1 addition & 2 deletions run_scapy
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#! /bin/sh
DIR=$(dirname $0)
PYTHONDONTWRITEBYTECODE=True
PYTHON=${PYTHON:-python}
PYTHON=${PYTHON:-python3}
PYTHONPATH=$DIR exec $PYTHON -m scapy $@
14 changes: 7 additions & 7 deletions run_scapy.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@echo off
call run_scapy_py2.bat --nopause
if errorlevel 1 (
call run_scapy_py3.bat --nopause
)
if errorlevel 1 (
PAUSE
)
set PYTHONPATH=%~dp0
IF "%PYTHON%" == "" set PYTHON=python3
WHERE %PYTHON% >nul 2>&1
IF %ERRORLEVEL% NEQ 0 set PYTHON=python
%PYTHON% -m scapy %*
title Scapy - dead
PAUSE
13 changes: 2 additions & 11 deletions run_scapy_py2.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
@echo off
set PYTHONPATH=%~dp0
set PYTHONDONTWRITEBYTECODE=True
if "%1"=="--nopause" (
set nopause="True"
python -m scapy
) else (
set nopause="False"
python -m scapy %*
)
if %errorlevel%==1 if NOT "%nopause%"=="True" (
PAUSE
)
set PYTHON=python
call run_scapy.bat
13 changes: 2 additions & 11 deletions run_scapy_py3.bat
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
@echo off
set PYTHONPATH=%~dp0
set PYTHONDONTWRITEBYTECODE=True
if "%1"=="--nopause" (
set nopause="True"
python3 -m scapy
) else (
set nopause="False"
python3 -m scapy %*
)
if %errorlevel%==1 if NOT "%nopause%"=="True" (
PAUSE
)
set PYTHON=python3
call run_scapy.bat
7 changes: 4 additions & 3 deletions scapy/tools/UTscapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,8 @@ def resolve_testfiles(TESTFILES):
return TESTFILES


def main(argv):
def main():
argv = sys.argv[1:]
ignore_globals = list(six.moves.builtins.__dict__.keys())

# Parse arguments
Expand Down Expand Up @@ -984,9 +985,9 @@ def main(argv):
# Let's discover the garbage waste
warnings.simplefilter('error')
print("### Warning mode enabled ###")
res = main(sys.argv[1:])
res = main()
if cw:
res = 1
sys.exit(res)
else:
sys.exit(main(sys.argv[1:]))
sys.exit(main())
90 changes: 27 additions & 63 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,19 @@
Distutils setup file for Scapy.
"""


from distutils import archive_util
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from setuptools import setup, find_packages
except:
raise ImportError("setuptools is required to install scapy !")
import io
import os


EZIP_HEADER = """#! /bin/sh
PYTHONPATH=$0/%s exec python -m scapy
"""


def make_ezipfile(base_name, base_dir, verbose=0, dry_run=0, **kwargs):
fname = archive_util.make_zipfile(base_name, base_dir, verbose, dry_run)
ofname = fname + ".old"
os.rename(fname, ofname)
of = open(ofname)
f = open(fname, "w")
f.write(EZIP_HEADER % base_dir)
while True:
data = of.read(8192)
if not data:
break
f.write(data)
f.close()
os.system("zip -A '%s'" % fname)
of.close()
os.unlink(ofname)
os.chmod(fname, 0o755)
return fname


archive_util.ARCHIVE_FORMATS["ezip"] = (
make_ezipfile, [], 'Executable ZIP file')


def get_long_description():
"""Extract description from README.md, for PyPI's usage"""
try:
with io.open(os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8") as f:
fpath = os.path.join(os.path.dirname(__file__), "README.md")
with io.open(fpath, encoding="utf-8") as f:
readme = f.read()
desc = readme.partition("<!-- start_ppi_description -->")[2]
desc = desc.partition("<!-- stop_ppi_description -->")[0]
Expand All @@ -54,41 +25,34 @@ def get_long_description():
return None


SCRIPTS = ['bin/scapy', 'bin/UTscapy']
# On Windows we also need additional batch files to run the above scripts
if os.name == "nt":
SCRIPTS += ['bin/scapy.bat', 'bin/UTscapy.bat']

# https://packaging.python.org/guides/distributing-packages-using-setuptools/
setup(
name='scapy',
version=__import__('scapy').VERSION,
packages=[
'scapy',
'scapy/arch',
'scapy/arch/bpf',
'scapy/arch/windows',
'scapy/contrib',
'scapy/contrib/automotive',
'scapy/contrib/automotive/bmw',
'scapy/contrib/automotive/gm',
'scapy/contrib/automotive/obd',
'scapy/contrib/automotive/obd/pid',
'scapy/contrib/automotive/obd/iid',
'scapy/contrib/automotive/obd/tid',
'scapy/contrib/automotive/obd/mid',
'scapy/layers',
'scapy/layers/tls',
'scapy/layers/tls/crypto',
'scapy/modules',
'scapy/modules/krack',
'scapy/asn1',
'scapy/tools',
],
scripts=SCRIPTS,
packages=find_packages(),
data_files=[('share/man/man1', ["doc/scapy.1"])],
package_data={
'scapy': ['VERSION'],
},
# Build starting scripts automatically
entry_points={
'console_scripts': [
'scapy = scapy.main:interact',
'UTscapy = scapy.tools.UTscapy:main'
]
},
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',
extras_require={
'basic': ["ipython"],
'complete': [
'ipython>=7; python_version>="3"',
'ipython<6; python_version<"3"',
'pyx>=0.14; python_version>="3"',
'pyx==0.12.1; python_version<"3"',
'cryptography',
'matplotlib'
]
},

# Metadata
author='Philippe BIONDI',
Expand Down