Skip to content

Commit 3dab0c9

Browse files
authored
Merge pull request #1869 from gpotter2/tinyfix2
Drop distutils - cleanup scapy executables
2 parents 94fb470 + 912d1bf commit 3dab0c9

File tree

10 files changed

+43
-157
lines changed

10 files changed

+43
-157
lines changed

bin/UTscapy

Lines changed: 0 additions & 27 deletions
This file was deleted.

bin/UTscapy.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

bin/scapy

Lines changed: 0 additions & 25 deletions
This file was deleted.

bin/scapy.bat

Lines changed: 0 additions & 4 deletions
This file was deleted.

run_scapy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#! /bin/sh
22
DIR=$(dirname $0)
3-
PYTHONDONTWRITEBYTECODE=True
4-
PYTHON=${PYTHON:-python}
3+
PYTHON=${PYTHON:-python3}
54
PYTHONPATH=$DIR exec $PYTHON -m scapy $@

run_scapy.bat

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
@echo off
2-
call run_scapy_py2.bat --nopause
3-
if errorlevel 1 (
4-
call run_scapy_py3.bat --nopause
5-
)
6-
if errorlevel 1 (
7-
PAUSE
8-
)
2+
set PYTHONPATH=%~dp0
3+
IF "%PYTHON%" == "" set PYTHON=python3
4+
WHERE %PYTHON% >nul 2>&1
5+
IF %ERRORLEVEL% NEQ 0 set PYTHON=python
6+
%PYTHON% -m scapy %*
7+
title Scapy - dead
8+
PAUSE

run_scapy_py2.bat

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
@echo off
22
set PYTHONPATH=%~dp0
3-
set PYTHONDONTWRITEBYTECODE=True
4-
if "%1"=="--nopause" (
5-
set nopause="True"
6-
python -m scapy
7-
) else (
8-
set nopause="False"
9-
python -m scapy %*
10-
)
11-
if %errorlevel%==1 if NOT "%nopause%"=="True" (
12-
PAUSE
13-
)
3+
set PYTHON=python
4+
call run_scapy.bat

run_scapy_py3.bat

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
@echo off
22
set PYTHONPATH=%~dp0
3-
set PYTHONDONTWRITEBYTECODE=True
4-
if "%1"=="--nopause" (
5-
set nopause="True"
6-
python3 -m scapy
7-
) else (
8-
set nopause="False"
9-
python3 -m scapy %*
10-
)
11-
if %errorlevel%==1 if NOT "%nopause%"=="True" (
12-
PAUSE
13-
)
3+
set PYTHON=python3
4+
call run_scapy.bat

scapy/tools/UTscapy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ def resolve_testfiles(TESTFILES):
775775
return TESTFILES
776776

777777

778-
def main(argv):
778+
def main():
779+
argv = sys.argv[1:]
779780
ignore_globals = list(six.moves.builtins.__dict__.keys())
780781

781782
# Parse arguments
@@ -984,9 +985,9 @@ def main(argv):
984985
# Let's discover the garbage waste
985986
warnings.simplefilter('error')
986987
print("### Warning mode enabled ###")
987-
res = main(sys.argv[1:])
988+
res = main()
988989
if cw:
989990
res = 1
990991
sys.exit(res)
991992
else:
992-
sys.exit(main(sys.argv[1:]))
993+
sys.exit(main())

setup.py

Lines changed: 27 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,19 @@
44
Distutils setup file for Scapy.
55
"""
66

7-
8-
from distutils import archive_util
97
try:
10-
from setuptools import setup
11-
except ImportError:
12-
from distutils.core import setup
8+
from setuptools import setup, find_packages
9+
except:
10+
raise ImportError("setuptools is required to install scapy !")
1311
import io
1412
import os
1513

1614

17-
EZIP_HEADER = """#! /bin/sh
18-
PYTHONPATH=$0/%s exec python -m scapy
19-
"""
20-
21-
22-
def make_ezipfile(base_name, base_dir, verbose=0, dry_run=0, **kwargs):
23-
fname = archive_util.make_zipfile(base_name, base_dir, verbose, dry_run)
24-
ofname = fname + ".old"
25-
os.rename(fname, ofname)
26-
of = open(ofname)
27-
f = open(fname, "w")
28-
f.write(EZIP_HEADER % base_dir)
29-
while True:
30-
data = of.read(8192)
31-
if not data:
32-
break
33-
f.write(data)
34-
f.close()
35-
os.system("zip -A '%s'" % fname)
36-
of.close()
37-
os.unlink(ofname)
38-
os.chmod(fname, 0o755)
39-
return fname
40-
41-
42-
archive_util.ARCHIVE_FORMATS["ezip"] = (
43-
make_ezipfile, [], 'Executable ZIP file')
44-
45-
4615
def get_long_description():
16+
"""Extract description from README.md, for PyPI's usage"""
4717
try:
48-
with io.open(os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8") as f:
18+
fpath = os.path.join(os.path.dirname(__file__), "README.md")
19+
with io.open(fpath, encoding="utf-8") as f:
4920
readme = f.read()
5021
desc = readme.partition("<!-- start_ppi_description -->")[2]
5122
desc = desc.partition("<!-- stop_ppi_description -->")[0]
@@ -54,41 +25,34 @@ def get_long_description():
5425
return None
5526

5627

57-
SCRIPTS = ['bin/scapy', 'bin/UTscapy']
58-
# On Windows we also need additional batch files to run the above scripts
59-
if os.name == "nt":
60-
SCRIPTS += ['bin/scapy.bat', 'bin/UTscapy.bat']
61-
28+
# https://packaging.python.org/guides/distributing-packages-using-setuptools/
6229
setup(
6330
name='scapy',
6431
version=__import__('scapy').VERSION,
65-
packages=[
66-
'scapy',
67-
'scapy/arch',
68-
'scapy/arch/bpf',
69-
'scapy/arch/windows',
70-
'scapy/contrib',
71-
'scapy/contrib/automotive',
72-
'scapy/contrib/automotive/bmw',
73-
'scapy/contrib/automotive/gm',
74-
'scapy/contrib/automotive/obd',
75-
'scapy/contrib/automotive/obd/pid',
76-
'scapy/contrib/automotive/obd/iid',
77-
'scapy/contrib/automotive/obd/tid',
78-
'scapy/contrib/automotive/obd/mid',
79-
'scapy/layers',
80-
'scapy/layers/tls',
81-
'scapy/layers/tls/crypto',
82-
'scapy/modules',
83-
'scapy/modules/krack',
84-
'scapy/asn1',
85-
'scapy/tools',
86-
],
87-
scripts=SCRIPTS,
32+
packages=find_packages(),
8833
data_files=[('share/man/man1', ["doc/scapy.1"])],
8934
package_data={
9035
'scapy': ['VERSION'],
9136
},
37+
# Build starting scripts automatically
38+
entry_points={
39+
'console_scripts': [
40+
'scapy = scapy.main:interact',
41+
'UTscapy = scapy.tools.UTscapy:main'
42+
]
43+
},
44+
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4',
45+
extras_require={
46+
'basic': ["ipython"],
47+
'complete': [
48+
'ipython>=7; python_version>="3"',
49+
'ipython<6; python_version<"3"',
50+
'pyx>=0.14; python_version>="3"',
51+
'pyx==0.12.1; python_version<"3"',
52+
'cryptography',
53+
'matplotlib'
54+
]
55+
},
9256

9357
# Metadata
9458
author='Philippe BIONDI',

0 commit comments

Comments
 (0)