New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get compiled script directory via sys.executable returns 8.3 filenames (DOS SFN) #1282
Comments
I fixed the problem myself by the use of win32api:
|
Could this be added to the doc? Where? |
Yes, this should be documented as a difference between running in normal Python and running under PyInstaller. PYI explicitly uses GetShortPathName to set the value of In normal Python, However, there is a bug(?) in I want to be able to change (On Python 3.3, It looks like the current behavior of using an MS-DOS 8.3 ShortFileName is the best we can do for now. It has one shortcoming though. The path to the .exe's folder is encoded as an SFN, but the filename of the .exe itself is not - it's codepage-encoded as it comes from argv. |
I kind of want to go through all of the bootloader code and add hungarian-notation to all of the string variables to specify the encoding - |
I'd prefer to have this fixed in |
Yes. PyI's workaround of using a ShortFileName instead of encoding with |
Besides, shouldn't you be using I wonder what the encoding for |
That's what my code looks like. (still clumsy but working)
|
As codewarrior wrote, you must use |
Doesn't work for me. I build my file in one file mode (-F). Using _MAIPASS I get the path of the extracted archive contents but not the path where the executable resides.
|
Oh, you're actually using the app by putting it in a folder where it is going to work. Then what you're doing with GetLongPathName will do what you want, but with the caveat that it won't work on filesystems that don't support 8.3 filenames - you'd have to go directly to GetCommandLineW (as I noted a few comments ago, or perhaps GetModuleFileNameW?) if you need that to work. |
I try to get the current directory name of the compiled script by the use of the following statement:
application_path = os.path.dirname(os.path.realpath(sys.executable))
When I run the python script it returns:
_C:\Users\neo\Downloads\loki-master_
When I run the compiled executable, it returns:
_C:\Users\neo\DOWNLO
1\LOKI-M1_This is the old MS DOS 8.3 filename style called SFN. I use the application path to exclude it from a directory walk later on but the path returned by os.walk() is obviously different than the one returned by sys.executable.
Is this a bug? Is there a way to retrieve the executable's full path?
I want to allow users to run the executable from other working directories.
The text was updated successfully, but these errors were encountered: