Opened 5 years ago

Closed 4 years ago

#8943 closed defect (fixed)

Use of __file__ incompatible with py2exe

Reported by: dcf Owned by: asn
Priority: Medium Milestone:
Component: Obfuscation/Obfsproxy Version:
Severity: Keywords: flashproxy
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Running a py2exe of obfsproxy:

$ /cygdrive/c/Python27/python.exe setup_py2exe.py py2exe
$ ./py2exe_bundle/dist/obfsproxy.exe
Traceback (most recent call last):
  File "obfsproxy", line 6, in <module>
NameError: name '__file__' is not defined

It works before the change in a66db465:

$ ./py2exe_bundle/dist/pyobfsproxy.exe
usage: pyobfsproxy.exe [-h] [--log-file LOG_FILE]
                       [--log-min-severity {error,warning,info,debug}]
                       [--no-log] [--no-safe-logging]
                       {managed,obfs2,dummy,obfs3,b64} ...
pyobfsproxy.exe: error: too few arguments

I don't know if this trick used in flashproxy will help:

    if getattr(sys, "frozen", False):
        script_dir = os.path.dirname(sys.executable)
    else:
        script_dir = sys.path[0]

Child Tickets

Attachments (1)

0001-Replacement-for-__file__-under-py2exe.patch (883 bytes) - added by dcf 4 years ago.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 5 years ago by dcf

Keywords: flashproxy added

comment:2 Changed 5 years ago by asn

Some workarounds here:
http://www.py2exe.org/index.cgi/WhereAmI

I'll check them out soon.

comment:3 Changed 4 years ago by dcf

Please check this patch. It works for building a bundle.

I didn't do anything to handle possible non-ASCII file names. I think it's even more complicated than the WhereAmI page indicates. We found in Zenmap that sys.getfilesystemencoding can fail.
https://svn.nmap.org/nmap/zenmap/zenmapCore/Paths.py?r=30909
https://svn.nmap.org/nmap/zenmap/zenmapCore/BasePaths.py?r=30909

comment:4 in reply to:  3 Changed 4 years ago by asn

Resolution: fixed
Status: newclosed

Replying to dcf:

Please check this patch. It works for building a bundle.

I didn't do anything to handle possible non-ASCII file names. I think it's even more complicated than the WhereAmI page indicates. We found in Zenmap that sys.getfilesystemencoding can fail.
https://svn.nmap.org/nmap/zenmap/zenmapCore/Paths.py?r=30909
https://svn.nmap.org/nmap/zenmap/zenmapCore/BasePaths.py?r=30909

Aha. Applied. Thanks!

Note: See TracTickets for help on using tickets.