Created
December 11, 2012 04:59
-
-
Save Shadow6363/4255985 to your computer and use it in GitHub Desktop.
PyInstaller Dynamic Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PluginTest/ | |
dist/ | |
plugin_test/ | |
plugin_test | |
* | |
src/ | |
plugin_test.py | |
plugins/ | |
platform_printer.py | |
pyinstaller src/plugin_test.py | |
cp -R src/plugins dist/plugin_test/ | |
dist/plugin_test/plugin_test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def print_platform(): | |
print sys.platform |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import imp, os, sys | |
if __name__ == '__main__': | |
plugins_folder = os.path.dirname(sys.executable) + os.sep + 'plugins' | |
if not plugins_folder in sys.path: | |
sys.path.append(plugins_folder) | |
for root, dirs, files in os.walk(plugins_folder): | |
for module_file in files: | |
module_name, module_extension = os.path.splitext(module_file) | |
if module_name != '__init__' and module_extension == os.extsep + "py": | |
try: | |
module_hdl, path_name, description = imp.find_module(module_name) | |
plugin_module = imp.load_module(module_name, module_hdl, path_name, | |
description) | |
plugin_module.print_platform() | |
finally: | |
if module_hdl: | |
module_hdl.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment