subprocess for pyinstaller
Project description
subprocess for pyinstaller
pip install pyinstallersubprocess
Based on https://github.com/pyinstaller/pyinstaller/issues/6362#issuecomment-968156787
Read the post before using this module.
Here is the most important part:
"Make all your entry points available as python -m invokable submodules and change all your subprocess.run(["entry_point_foo"]) usages to subprocess.run([sys.executable, "-m", "hello_word.entry_point_foo"]).
Extend those subprocess.run() calls to:
if getattr(sys, 'frozen', False):
subprocess.run([os.path.join(sys._MEIPASS, "entry_point_foo")])
else:
subprocess.run([sys.executable, "-m", "hello_word.entry_point_foo"])
Run PyInstaller on each entry point submodule (e.g. hello_world/hello_world/run_hello_world.py) and make use of Merge() to put them together in one bundle."
import subprocess
from pyinstallersubprocess import (
convert_py_file_to_module,
subprocess_console,
subprocess_console_devnull,
subprocess_console_popen,
subprocess_console_stdout_read,
subprocess_no_console_devnull,
subprocess_no_console_popen,
subprocess_no_console_stdout_read)
# The function convert_py_file_to_module turns the py file into an "python -m invokable submodule"
modulename, entry = convert_py_file_to_module(
modulename="mysubprocess", # choose what anything you want, but make sure that the folder "mysubprocess" doesn't exist in your base folder
pythonfile=r"C:\Users\Gamer\anaconda3\envs\dfdir\pytfi.py",
rename_pyfile=False, # renames r"C:\Users\Gamer\anaconda3\envs\dfdir\pytfi.py" -> r"C:\Users\Gamer\anaconda3\envs\dfdir\pytfi.old"
overwrite_existing=True, # if the folder exists
add_main_entry=True, # if there is no entry, 'if __name__ == "__main__" ... will be added
)
print((modulename, entry))
('mysubprocess', 'pytfi')
# Here are some functions that take care of: "Execute the "extended" subprocess (if getattr(sys, 'frozen', False) ...)"
p = subprocess_console(
module=modulename,
entry=entry,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE,
)
print(p)
# CompletedProcess(args=['C:\\Users\\Gamer\\anaconda3\\envs\\dfdir\\python.exe', '-m', 'mysubprocess.pytfi'], returncode=0, stdout=b'oioou\r\n', stderr=b'')
# All functions:
subprocess_console(module, entry, *args, **kwargs)
subprocess_console_devnull(module, entry, *args, **kwargs)
subprocess_console_popen(module, entry, *args, **kwargs)
subprocess_console_stdout_read(module, entry, *args, **kwargs)
subprocess_no_console_devnull(module, entry, *args, **kwargs)
subprocess_no_console_popen(module, entry, *args, **kwargs)
subprocess_no_console_stdout_read(module, entry, *args, **kwargs)
# This module:
# https://github.com/hansalemaos/env2installer
# can help you with "Run PyInstaller on each entry point submodule (e.g. hello_world/hello_world/run_hello_world.py)..."
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for pyinstallersubprocess-0.10.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a8f9cb3ebbc35e73eb7ad08fde47e386c0b62f174b4c6900ac27461e2c111fe |
|
MD5 | fc080eb60abac7f98d6f40c368d2dbd7 |
|
BLAKE2b-256 | 08549c812c84176fe156fd2737e44b05ae2f7ff30c560f4f6454f91c105e166c |
Close
Hashes for pyinstallersubprocess-0.10-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ed5a8233f5403fb4e26b494adf0ec1f558bef23251c8003e6d002b2d810d0cc |
|
MD5 | 23c3406a438eeb79e6efb72dd4f6d11c |
|
BLAKE2b-256 | 15b9f12710c5a08233cb968a98babd9d81e0581ff80c7a4d5931d284ee48aacb |