invernizzi / scapy-http

Support for HTTP in Scapy
Other
301 stars 77 forks source link

Installation for Scapy-python3 (Scapy3k) #19

Closed irvinhomem closed 8 years ago

irvinhomem commented 8 years ago

I tried to install scapy-http for scapy-python3 using: pip3 install scapy-http

But it fails with some sort of python2 to 3 conversion issue related to how octals are represented:

Downloading scapy-2.3.2.tar.gz (1.1MB): 1.1MB downloaded
  Running setup.py (path:/tmp/pip_build_root/scapy/setup.py) egg_info for package scapy
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/pip_build_root/scapy/setup.py", line 35
        os.chmod(fname,0755)
                          ^
    SyntaxError: invalid token
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/pip_build_root/scapy/setup.py", line 35

    os.chmod(fname,0755)
                      ^
SyntaxError: invalid token

Not sure where exactly this happens. NB: I have both Python2.7 and 3.4 installed and both scapy(2)and scapy3k installed respectively, with both working so far without a problem

yarko commented 8 years ago

This isn't octal conversion: it is a type failure (maybe it was tolerant in Python-2, but isn't in Python-3) -- see https://docs.python.org/3/library/os.html?highlight=os.chmod#os.chmod

The problem is this has a built-in dependency on scapy even if installing in Python-3 (which scapy won't work with anyway); if you clone and set the line:

install_requires=['scapy-python3'],

you should have a successful installation.

A solution to this may be to read the python version in setup.py, and set the appropriate package name (the import package is "scapy" in either case), e.g. something like:

import sys

scapy_name = "scapy-python3" if sys.version_info.major==3 else "scapy"
...
install_requires=[scapy_name],
...

I think that would do it.

alaa-aqeel commented 6 years ago

sudo pip3 install scapy-python3