hi
i’ve got this code and i wanted to make it a standalone executable, problem is
Pyinstaller creates a huge file (5.5MB) for this little code… so then i tried
to exclude few things in case it gets smaller but it keeps staying at 5.5MB.
also i’ve noticed that some antivirus detect my file as trojan, i guess it should be
a false alarm though i’m uncertain because i can read elsewere that some complilers
in C for example do contain virus payload.
this is my code:
import sys
def main():
# Check that a filename and search string were provided as command-line arguments
if len(sys.argv) < 3:
print("Usage: search <filename> <string>")
return 1
# Open the file for reading
try:
with open(sys.argv[1], 'r') as fp:
# Search the file for the specified string
search_string = sys.argv[2]
for line in fp:
if search_string in line:
return
except:
print(f"Error: Could not open file {sys.argv[1]}")
return 1
# Make a beep sound if the string was not found
print("\a")
return 0
if __name__ == "__main__":
main()
and this is the way i tried to make it smaller:
pyinstaller --onefile python_search.py --exclude-module Pyinstaller --exclude-module _pyinstaller_hooks_constrib --exclude-module altgraph --exclude-module easy_install --exclude-module future --exclude-module importlib_metadata --exclude-module libfutursize --exclude-module libpasteurize --exclude-module ordlookup --exclude-module past --exclude-module pefile --exclude-module peutils --exclude-module pip --exclude-module pkg_resources --exclude-module setuptools --exclude-module typing_extensions --exclude-module win32ctypes --exclude-module zipp --exclude matplotlib --exclude scipy --exclude pandas