Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Active reading [<en.wikipedia.org/wiki/HTML> <en.wikipedia.org/wiki/JavaScript> <en.wikipedia.org/wiki/Cascading_Style_Sheets> <en.wikipedia.org/wiki/EXE> <en.wikipedia.org/wiki/Windows_7> <en.wikipedia.org/wiki/Python_%28programming_language%29> <en.wikipedia.org/wiki/Microsoft_Windows>].
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

Using pyinstallerPyInstaller, I found a better method using shortcut to the .exe rather than making --onefile. Anyways there'sAnyway, there are probably some data files around and if you're running a site-based app then your program depends on htmlHTML, jsJavaScript, cssand CSS files too. NoThere isn't any point in moving all these files somewhere.. instead. Instead what if we move the working path up.?

Make a shortcut to the exeEXE file, move it at top and set the target and start-in paths as specified, to have relative paths going to dist\folderdist\folder:

Target: %windir%\system32\cmd.exe /c start dist\web_wrapper\web_wrapper.exe
Start in: "%windir%\system32\cmd.exe /c start dist\web_wrapper\"

CanWe can rename the shortcut to anything, so renaming to "GTFS-Manager"
. Now when I double-click the shortcut, it's as if I pythonpython-ran the file! I found this approach better than the --onefile one as:

  1. In onefile's case, there's a problem with a .dll missing for win7the Windows 7 OS which needs some prior installation, etc. Yawn. With the usual build with multiple files, no such issues.
  2. All the files that my pythonPython script uses (it's deploying a tornado web server and needs a whole freakin' website worth of files to be there!) don't need to be moved anywhere: I simply create the shortcut at top.
  3. I can actually use this exact same folder in ubuntuon Ubuntu (run python3 myfile.pypython3 myfile.py) and windowsWindows (double-click the shortcut).
  4. I don't need to bother with the overly complicated hacking of .spec file to include data files, etc.

Oh, remember to delete off the build folder after building,. It will save on size.

Using pyinstaller, I found a better method using shortcut to the .exe rather than making --onefile. Anyways there's probably some data files around and if you're running a site-based app then your program depends on html, js, css files too. No point in moving all these files somewhere.. instead what if we move the working path up.

Make a shortcut to the exe, move it at top and set the target and start-in paths as specified, to have relative paths going to dist\folder:

Target: %windir%\system32\cmd.exe /c start dist\web_wrapper\web_wrapper.exe
Start in: "%windir%\system32\cmd.exe /c start dist\web_wrapper\"

Can rename shortcut to anything so renaming to "GTFS-Manager"
Now when I double-click the shortcut, it's as if I python-ran the file! I found this approach better than the --onefile one as:

  1. In onefile's case, there's a problem with a .dll missing for win7 OS which needs some prior installation etc. Yawn. With the usual build with multiple files, no such issues.
  2. All the files that my python script uses (it's deploying a tornado web server and needs a whole freakin' website worth of files to be there!) don't need to be moved anywhere: I simply create the shortcut at top.
  3. I can actually use this exact same folder in ubuntu (run python3 myfile.py) and windows (double-click the shortcut).
  4. I don't need to bother with the overly complicated hacking of .spec file to include data files etc.

Oh, remember to delete off the build folder after building, will save on size.

Using PyInstaller, I found a better method using shortcut to the .exe rather than making --onefile. Anyway, there are probably some data files around and if you're running a site-based app then your program depends on HTML, JavaScript, and CSS files too. There isn't any point in moving all these files somewhere... Instead what if we move the working path up?

Make a shortcut to the EXE file, move it at top and set the target and start-in paths as specified, to have relative paths going to dist\folder:

Target: %windir%\system32\cmd.exe /c start dist\web_wrapper\web_wrapper.exe
Start in: "%windir%\system32\cmd.exe /c start dist\web_wrapper\"

We can rename the shortcut to anything, so renaming to "GTFS-Manager". Now when I double-click the shortcut, it's as if I python-ran the file! I found this approach better than the --onefile one as:

  1. In onefile's case, there's a problem with a .dll missing for the Windows 7 OS which needs some prior installation, etc. Yawn. With the usual build with multiple files, no such issues.
  2. All the files that my Python script uses (it's deploying a tornado web server and needs a whole freakin' website worth of files to be there!) don't need to be moved anywhere: I simply create the shortcut at top.
  3. I can actually use this exact same folder on Ubuntu (run python3 myfile.py) and Windows (double-click the shortcut).
  4. I don't need to bother with the overly complicated hacking of .spec file to include data files, etc.

Oh, remember to delete off the build folder after building. It will save on size.

Source Link
Nikhil VJ
  • 6.3k
  • 7
  • 39
  • 62

Using pyinstaller, I found a better method using shortcut to the .exe rather than making --onefile. Anyways there's probably some data files around and if you're running a site-based app then your program depends on html, js, css files too. No point in moving all these files somewhere.. instead what if we move the working path up.

Make a shortcut to the exe, move it at top and set the target and start-in paths as specified, to have relative paths going to dist\folder:

Target: %windir%\system32\cmd.exe /c start dist\web_wrapper\web_wrapper.exe
Start in: "%windir%\system32\cmd.exe /c start dist\web_wrapper\"

Can rename shortcut to anything so renaming to "GTFS-Manager"
Now when I double-click the shortcut, it's as if I python-ran the file! I found this approach better than the --onefile one as:

  1. In onefile's case, there's a problem with a .dll missing for win7 OS which needs some prior installation etc. Yawn. With the usual build with multiple files, no such issues.
  2. All the files that my python script uses (it's deploying a tornado web server and needs a whole freakin' website worth of files to be there!) don't need to be moved anywhere: I simply create the shortcut at top.
  3. I can actually use this exact same folder in ubuntu (run python3 myfile.py) and windows (double-click the shortcut).
  4. I don't need to bother with the overly complicated hacking of .spec file to include data files etc.

Oh, remember to delete off the build folder after building, will save on size.

lang-py

AltStyle によって変換されたページ (->オリジナル) /