Include folders in --onefile

2,565 views
Skip to first unread message

alexandernst

unread,
Sep 5, 2010, 10:10:08 AM9/5/10
to PyInstaller
Hi,

I have been searching in this mailing list and in google but I haven't
found anything about including entire folders to a single executable.
Is there any way of doing that?

PS: I found something related in a threat. The guy suggested to zip
the entire folder, include it as PKG and then unzip it. I wouldn't
like to do that.

Regards

Martin Zibricky

unread,
Sep 5, 2010, 2:39:55 PM9/5/10
to pyins...@googlegroups.com
alexandernst píše v Ne 05. 09. 2010 v 07:10 -0700:

> I have been searching in this mailing list and in google but I haven't
> found anything about including entire folders to a single executable.
> Is there any way of doing that?

What do you mean by that? Including additional stuff like images, text
files into your one binary?

alexandernst

unread,
Sep 5, 2010, 7:01:26 PM9/5/10
to PyInstaller

> What do you mean by that? Including additional stuff like images, text
> files into your one binary?

I have a "libs" folder that has my own libraries. Those are detected
tweaking the spec file.
But I also have a "plugins" directory. In that one I have scripts that
are imported with __import__ at runtime, and they
aren't detected by pyinstaller. Or maybe I'm doing something wrong :/

Anyways, there is a third folder called "skins". That one includes a
lot of folders and each folder is a skin. How can I include the
entire "skins" folder in my executable file?

Martin Zibricky

unread,
Sep 6, 2010, 3:00:37 PM9/6/10
to pyins...@googlegroups.com
alexandernst píše v Ne 05. 09. 2010 v 16:01 -0700:

> I have a "libs" folder that has my own libraries. Those are detected
> tweaking the spec file.
> But I also have a "plugins" directory. In that one I have scripts that
> are imported with __import__ at runtime, and they
> aren't detected by pyinstaller. Or maybe I'm doing something wrong :/

the solution could be like with 'skins' folder:

[('plugins', '/my/project/plugins', 'DATA')] - your plugin files should
be packaged with your binary.

and at runtime add it to your Python path:

sys.path.append(
os.path.join(os.environ["_MEIPASS2], 'plugins'))
)

> Anyways, there is a third folder called "skins". That one includes a
> lot of folders and each folder is a skin. How can I include the
> entire "skins" folder in my executable file?

Pyinstaller should support that. However I didn't use that yet. But:

In your spec file you should tweak the collect section.

coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
name=os.path.join('dist', __testname__))

like:

coll = COLLECT(exe,
a.binaries +
[('skins', '/my/project/skins', 'DATA')],
a.zipfiles,
a.datas,
strip=False,
upx=False,
name=os.path.join('dist', __testname__))

the skins folder should be accessible at runtime like:

os.path.join(os.environ["_MEIPASS2], 'skins'))

in pyinstaller doc see:

http://www.pyinstaller.org/export/latest/tags/1.4/doc/Manual.html?format=raw#toc-class-table-of-contents
http://www.pyinstaller.org/export/latest/tags/1.4/doc/Manual.html?format=raw#accessing-data-files


Hope it will work for you.

Regards Martin


Reply all
Reply to author
Forward
0 new messages