setup.py revision b7d3d93544f98711b2c5de7748c7bb143d9385ff
11123fedadc0259c24e0ee81d05ab2496780d4297Phil#! /usr/bin/env python
21123fedadc0259c24e0ee81d05ab2496780d4297Phil
30ce149b41a10223c75f33a135d0a7ddc6bd2e022Dirk Loss"""
40ce149b41a10223c75f33a135d0a7ddc6bd2e022Dirk LossDistutils setup file for Scapy.
50ce149b41a10223c75f33a135d0a7ddc6bd2e022Dirk Loss"""
60ce149b41a10223c75f33a135d0a7ddc6bd2e022Dirk Loss
71123fedadc0259c24e0ee81d05ab2496780d4297Phil
81123fedadc0259c24e0ee81d05ab2496780d4297Philfrom distutils import archive_util
91123fedadc0259c24e0ee81d05ab2496780d4297Philfrom distutils import sysconfig
101123fedadc0259c24e0ee81d05ab2496780d4297Philfrom distutils.core import setup
111123fedadc0259c24e0ee81d05ab2496780d4297Philfrom distutils.command.sdist import sdist
121123fedadc0259c24e0ee81d05ab2496780d4297Philimport os
131123fedadc0259c24e0ee81d05ab2496780d4297Phil
141123fedadc0259c24e0ee81d05ab2496780d4297Phil
151123fedadc0259c24e0ee81d05ab2496780d4297PhilEZIP_HEADER="""#! /bin/sh
1671ad2b6422bb7119319b971d348cd4aca434ce91PhilPYTHONPATH=$0/%s exec python -m scapy.__init__
171123fedadc0259c24e0ee81d05ab2496780d4297Phil"""
181123fedadc0259c24e0ee81d05ab2496780d4297Phil
19b7d3d93544f98711b2c5de7748c7bb143d9385ffPhildef make_ezipfile(base_name, base_dir, verbose=0, dry_run=0, **kwargs):
201123fedadc0259c24e0ee81d05ab2496780d4297Phil    fname = archive_util.make_zipfile(base_name, base_dir, verbose, dry_run)
211123fedadc0259c24e0ee81d05ab2496780d4297Phil    ofname = fname+".old"
221123fedadc0259c24e0ee81d05ab2496780d4297Phil    os.rename(fname,ofname)
231123fedadc0259c24e0ee81d05ab2496780d4297Phil    of=open(ofname)
241123fedadc0259c24e0ee81d05ab2496780d4297Phil    f=open(fname,"w")
251123fedadc0259c24e0ee81d05ab2496780d4297Phil    f.write(EZIP_HEADER % base_dir)
261123fedadc0259c24e0ee81d05ab2496780d4297Phil    while True:
271123fedadc0259c24e0ee81d05ab2496780d4297Phil        data = of.read(8192)
281123fedadc0259c24e0ee81d05ab2496780d4297Phil        if not data:
291123fedadc0259c24e0ee81d05ab2496780d4297Phil            break
301123fedadc0259c24e0ee81d05ab2496780d4297Phil        f.write(data)
311123fedadc0259c24e0ee81d05ab2496780d4297Phil    f.close()
32e31a851ca76754595a20192b2a4c6674397e7f44Phil    os.system("zip -A '%s'" % fname)
331123fedadc0259c24e0ee81d05ab2496780d4297Phil    of.close()
341123fedadc0259c24e0ee81d05ab2496780d4297Phil    os.unlink(ofname)
351123fedadc0259c24e0ee81d05ab2496780d4297Phil    os.chmod(fname,0755)
361123fedadc0259c24e0ee81d05ab2496780d4297Phil    return fname
371123fedadc0259c24e0ee81d05ab2496780d4297Phil
381123fedadc0259c24e0ee81d05ab2496780d4297Phil
391123fedadc0259c24e0ee81d05ab2496780d4297Phil
401123fedadc0259c24e0ee81d05ab2496780d4297Philarchive_util.ARCHIVE_FORMATS["ezip"] = (make_ezipfile,[],'Executable ZIP file')
411123fedadc0259c24e0ee81d05ab2496780d4297Phil
4229146dda448ed02f1457fb4ee883e9dba8ec3991Dirk LossSCRIPTS = ['bin/scapy','bin/UTscapy']
4329146dda448ed02f1457fb4ee883e9dba8ec3991Dirk Loss# On Windows we also need additional batch files to run the above scripts
4429146dda448ed02f1457fb4ee883e9dba8ec3991Dirk Lossif os.name == "nt":
4529146dda448ed02f1457fb4ee883e9dba8ec3991Dirk Loss  SCRIPTS += ['bin/scapy.bat','bin/UTscapy.bat']
461123fedadc0259c24e0ee81d05ab2496780d4297Phil
471123fedadc0259c24e0ee81d05ab2496780d4297Philsetup(
48a6b4992bb4a722db3287d8914dcbbd4f05ce5ee1Phil    name = 'scapy',
499811db3005957c968f5fa3a5ebadba5628d5d8bfGuillaume Valadon    version = '2.3.0-dev',
506bfb92a2552ef4838340dcd2c2b6f314b66d5b64Phil    packages=['scapy','scapy/arch', 'scapy/arch/windows', 'scapy/layers','scapy/asn1','scapy/tools','scapy/modules', 'scapy/crypto', 'scapy/contrib'],
5129146dda448ed02f1457fb4ee883e9dba8ec3991Dirk Loss    scripts = SCRIPTS,
52d4d86e9cbf6620b63571942250c6bf135c8aa24bPhil    data_files = [('share/man/man1', ["doc/scapy.1.gz"])],
53d4d86e9cbf6620b63571942250c6bf135c8aa24bPhil
541123fedadc0259c24e0ee81d05ab2496780d4297Phil    # Metadata
551123fedadc0259c24e0ee81d05ab2496780d4297Phil    author = 'Philippe BIONDI',
561123fedadc0259c24e0ee81d05ab2496780d4297Phil    author_email = 'phil(at)secdev.org',
571123fedadc0259c24e0ee81d05ab2496780d4297Phil    description = 'Scapy: interactive packet manipulation tool',
581123fedadc0259c24e0ee81d05ab2496780d4297Phil    license = 'GPLv2',
591123fedadc0259c24e0ee81d05ab2496780d4297Phil    url = 'http://www.secdev.org/projects/scapy'
601123fedadc0259c24e0ee81d05ab2496780d4297Phil    # keywords = '',
611123fedadc0259c24e0ee81d05ab2496780d4297Phil    # url = '',
621123fedadc0259c24e0ee81d05ab2496780d4297Phil)
63