Why does my pyinstaller created executable require admin privileges? - pyqt4

I've written a Python program which I distribute using pyinstaller. I've been using the onefile option so far to create a standalone executable. That's been great up until now, but as the application has grown the startup time is getting a bit long. I'd also like users to install the application properly to make upgrading simpler.
I've been trying to create a single directory version of the app using pyinstaller's onedir option. However, the resulting .exe file that is created requires admin privileges to run, which the onefile version did not. The program itself doesn't need any such privileges so I assume this is something that pyinstaller is doing. How do I create an application that doesn't require admin privileges?
Additional info:
Python 2.6, pyinstaller v1.4
Application uses PyQt4 and pygame modules.
Trying to create executable for Windows 7.
Using -w pyinstaller option to create a windowless executable.

admin privileges could be asked in few cases:
A. if the executable name contains relevant keywords (like setup, install, update or patch)
B. the application requests it in it's manifest.
C. the .exe file name do not match the name in the manifest file.
if you create a .spec file for your application package, you can add
exe = EXE(
...
manifest=None,
...
)
and it won't ask for password, unless you rename it to setup or install.

I have recently run into this issue, and my experience in solving it was thus:
PyInstaller with --onefile option creates a manifest file in the 'executable'. This manifest file on Windows tells the OS a few things about the application it is bundled with. One of the things it specifies, is the application name/manifest file. The format of the manifest filename is appname.exe.manifest. If your program is frozen with PyInstaller, the executable name that it stores in the manifest will be the name given to the completed EXE under the /dist folder of PyInstaller. IF you rename the EXE, the manifest file packed with it is no longer matching! Therefore, create a manifest file with the same name as the final EXE filename and run PyInstaller with the --manifest option, OR don't rename the EXE that PyInstaller creates.
When you package the PyInstaller project with the custom --manifest, the renamed program no longer requests administrator elevation.

Related

How to get the directory of the .exe for a Node.js pkg executable?

I'm compiling/building a Node.js project into an .exe using Vercel's pkg but I'm trying to find where that executable file is during the program's runtime. To clarify, I want the Node.js program to know where the .exe file it is being run from is, to confirm it is correctly installed.
Context:
I cannot guarantee where the user has the .exe stored the first time they run it, but I want it to copy itself to the AppData folder so I can setup a Windows service from it, if it's not being run from there already. This in hopes of making a self-installing program, that doesn't require me to build an installed around it.
So on it's first run, I need the location of the .exe to be able to copy where I want. I might just have not picked it up, but I can't find an answer on either the pkg documentation or on another question here.
What I've Tried: I have tried process.cwd, process.pkg, __filename, __dirname and so on, but they all lead to the wrong thing, usually the snapshot folder of files.
When it comes to the main script it's as simple as finding it:
process.argv
From the Node.js documentation
Pkg from Vercel, is not an installer, its just a packager that will package node binaries and your code in a single exe.
You can follow this tutorial that shows how to make an installer it even enables you to set a path of where you want your exe to be installed

Hide input files during the conversion of python scripts into exe

I have python scripts in folder A and some dependent input files (.xlsx,.txt) in folder B.
I am using cx_Freeze to convert them into exe.
I have the files in the folder B as a list in include_files in setup.py
During the conversion, the files fall in the build folder.
The files should not be visible to the user, or at least they should be only in read-only mode.
You can use os.chmod at the end of your setup script to make any file of the build directory read-only. For example:
import os
import stat
os.chmod(path_to_file, stat.S_IREAD)
Of course you need to know the path to the build directory. You can also tell cx_Freeze which directory to use as build directory by using the build_exe option of the build_execommand, see the cx_Freeze documentation.

SQLite3 db is not getting included in the compiled directory pyinstaller

Here are my files that i have in a folder ready for compile...
After using pyinstaller i now have my compiled folder complete...
However, as you can see codes.db file is not in the folder as expected!
That is until i click the .exe to launch...then all of a sudden the .exe spits out an empty codes.db file showing 0kb and have no tables. I am assuming at this point that because the codes.db is missing the .exe creates an empty .db with the same name.
How can i make sure that my sqlite3 db is included in the compile? It needs to still have its read/write capability.
EDIT
Im using Windows 10 and Visual Studio 2017.
I don't see your .spec file. Running
pyinstaller file.py
produces a file.spec file. This file should be edited by the user to fit his needs. One hassle free way i found is to have the db in a folder and add the folder, setting datas in analysis to
[
( './db/*', 'db' ),
]
You can view my complete answer on SO here: sqlite + PyQt5 to standalone exe - Python 3.6.3 + Pyinstaller

pyInstaller exe failed because it did not include a module

Situation: Building an EXE from a python script that encrypts things.
Problem: The EXE always fails as it cannot find modules that I have imported (Crypto).
Question: Is there a flag I need to turn on or include to make sure that pyInstaller includes Crypto when building the EXE?
Additional information: The Crypto here refers to pycryptodome
You have to edit your .spec file to include the hiddenimports. As shown here:
hiddenimports=['pycryptodome.apps'],
Run pyinstaller with the .spec command afterwards pyinstaller --name=appname appname.spec
Then you'll have to add the modules that are in your site-package to the root dist application folder. Just copy and paste the entire folder.

Compiled Golang executable extension for OS X

What extension should I use for Golang executable intended to run on OS X?
As far as I understand it is not important because there are user rights as on Linux which make some file executable, but what is the convention if it is not .dmg file, just one executable file, so user knows that it is probably executable?
I don't have OS X. Application is cross-compiled on Linux.
The convention for OSX applications is this: one DMG containing a .app executable and a shortcut to /Applications for the user to drag to. Since you can't do this, I recommend you provide a download to the .app executable directly and instruct users to move it to /Applications on your download site.
This is only true for download-it-run-it applications. For applications which are run via the terminal, simply don't use an extension and use a shebang line to tell what application should be executing the file.

Resources