Windows package .spec + PyCrypto

487 views
Skip to first unread message

NumesSanguis

unread,
Feb 8, 2016, 3:16:31 PM2/8/16
to Kivy users support
I'm trying to package my app for Windows, but I would like to use PyInstallers PyCrypto function.
This is my .spec file:

from kivy.deps import sdl2, glew
# -*- mode: python -*-

block_cipher
= pyi_crypto.PyiBlockCipher(key='test')


a
= Analysis(['..\\foo\\main.py'],
             pathex
=['D:\\path\\KO-exe'],
             binaries
=None,
             datas
=None,
             hiddenimports
=['six','packaging','packaging.version','webbrowser'],
             hookspath
=[],
             runtime_hooks
=[],
             excludes
=[],
             win_no_prefer_redirects
=False,
             win_private_assemblies
=False,
             cipher
=block_cipher)
             
# exclusion list
from os.path import join
from fnmatch import fnmatch
exclusion_patterns
= (
    join
("kivy_install", "data", "images", "testpattern.png"),
    join
("kivy_install", "data", "images", "image-loading.gif"),
    join
("kivy_install", "data", "keyboards*"),
    join
("kivy_install", "data", "settings_kivy.json"),
    join
("kivy_install", "data", "logo*"),
    join
("kivy_install", "data", "fonts", "DejaVuSans*"),
    join
("kivy_install", "modules*"),
    join
("Include*"),
    join
("sdl2-config"),
   
# Filter app directory
    join
("personal*"),
    join
("sign-apk*"),
    join
(".idea*"),
    join
("*.pyc")
)

def can_exclude(fn):
   
for pat in exclusion_patterns:
       
if fnmatch(fn, pat):
           
return True
           
a
.datas = [x for x in a.datas if not can_exclude(x[0])]
a
.binaries = [x for x in a.binaries if not can_exclude(x[0])]
# Filter app directory
appfolder
= [x for x in Tree('..\\foo\\') if not can_exclude(x[0])]        
         
 
pyz
= PYZ(a.pure, a.zipped_data,
             cipher
=block_cipher)

exe
= EXE(pyz,
          a
.scripts,
          exclude_binaries
=True,
          name
='foo',
          debug
=False,
          strip
=False,
          upx
=True,
          console
=False , icon='..\\foo\\ko.ico')
coll
= COLLECT(exe, appfolder,
               a
.binaries,
               a
.zipfiles,
               a
.datas,
               
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins )],
               strip
=False,
               upx
=True,
               name
='foo')

From the documentation of PyInstaller I see that it uses a special container for .pyc and .pyo files, which are all in `a.pure`. http://pythonhosted.org/PyInstaller/#inspecting-archives
However all my project files are in the `Tree()`.

Can I somehow get all my .py files compressed and in a.pure, so I can use PyCrypt on it?
Message has been deleted

NumesSanguis

unread,
Feb 16, 2016, 3:07:35 PM2/16/16
to Kivy users support
So by analyzing a.scripts I get the following output:
(Pdb) print(a.scripts)
[('pyi_rth_kivy', 'C:\\Python27\\lib\\site-packages\\PyInstaller\\loader\\rthooks\\pyi_rth_kivy.py', 'PYSOURCE'),
('pyi_rth_pkgres', 'C:\\Python27\\lib\\site-packages\\PyInstaller\\loader\\rthooks\\pyi_rth_pkgres.py', 'PYSOURCE'),
('pyi_rth_gstreamer', 'C:\\Python27\\lib\\site-packages\\PyInstaller\\loader\\rthooks\\pyi_rth_gstreamer.py', 'PYSOURCE'),
('main', 'D:\\SurafuSoft\\app_KanjiOrigin\\BitBucket\\KanjiOrigin\\main.py', 'PYSOURCE')]

From this it seems that only main.py is included.
When I delete main.py from my dist\ folder, indeed the app still works (it was included because of the Tree() command).
I think this is because PyInstaller cannot read the import statements in a .kv file?
So my thought was to include my other scripts manually, however this doesn't work when my script is called through an import in a .kv file
Because that import still searches for the actual .py file and not the compiled one by PyInstaller.

Would it be possible to write an additional script for PyInstaller that helps reading import statements in Kivy? (if my thoughts are correct)

NumesSanguis

unread,
Feb 22, 2016, 7:15:22 AM2/22/16
to Kivy users support
Reply all
Reply to author
Forward
0 new messages