cherrypy + ssl + pyinstaller

267 views
Skip to first unread message

harsh savla

unread,
Jun 23, 2016, 3:09:57 AM6/23/16
to cherrypy-users
I am trying to get cherrypy to work with ssl support.

Env:

build: debian wheezy 64-bit chroot
run:   debian wheezy 64-bit chroot
cherrypy: 4.0.0
python: 2.7.10 (has ssl support, can import ssl)
pyinstaller: 2.1


Here is the code:

sss.py


import cherrypy


config = {
'global' : {
'server.socket_host' : '0.0.0.0',
'server.socket_port' : 8888,
'server.thread_pool' : 8,
'server.ssl_module' : 'builtin',
'server.ssl_certificate' : '/certs/cert.pem',
#'server.ssl_certificate_chain' : '/path/to/certs/ssl123_ca_bundle.pem',
'server.ssl_private_key' : '/certs/key.pem'
}
}

class App:

    @cherrypy.expose
    def index(self):
        return 'Is this secure?'


if name == 'main':
    cherrypy.quickstart(App(), '/', config)



I compile the above code with: pyinstaller sss.py and run the resultant binary on a 64-bit chroot environment (which is same as build env)

I see the following traceback.

[22/Jun/2016:17:11:29] ENGINE Listening for SIGHUP.
[22/Jun/2016:17:11:29] ENGINE Listening for SIGTERM.
[22/Jun/2016:17:11:29] ENGINE Listening for SIGUSR1.
[22/Jun/2016:17:11:29] ENGINE Bus STARTING
[22/Jun/2016:17:11:29] ENGINE Started monitor thread 'Autoreloader'.
[22/Jun/2016:17:11:29] ENGINE Started monitor thread 'TimeoutMonitor'.
[22/Jun/2016:17:11:29] ENGINE Error in 'start' listener >
Traceback (most recent call last):
File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy.process.wspbus", line 203, in publish
File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy.cpserver", line 167, in start
File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy._cpserver", line 158, in httpserver_from_self
File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy._cpwsgi_server", line 60, in __init

File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy.wsgiserver.wsgiserver2", line 2208, in get_ssl_adapter_class
ImportError: No module named ssl_builtin

[22/Jun/2016:17:11:29] ENGINE Shutting down due to error in start listener:
Traceback (most recent call last):
File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy.process.wspbus", line 241, in start
File "/home/run_pyinstaller/pyins/build/sss/out00-PYZ.pyz/cherrypy.process.wspbus", line 221, in publish
ChannelFailures: ImportError('No module named ssl_builtin',)



Has anyone encountered issues with pyinstaller + cherrypy + ssl?

PS: Filed an issue on the cherrypy project https://github.com/cherrypy/cherrypy/issues/1448
 

Joseph S. Tate

unread,
Jun 23, 2016, 3:37:23 PM6/23/16
to cherrypy-users
Start removing stuff until it works: chroot, chroot's custom python, pyinstaller, etc. This is not likely a problem with cherrypy. I've never used pyinstaller, but have used py2exe, and haven't had import errors within cherrypy. That said, I had ssl turned off at the time.

ssl_builtin is in cherrypy.wsgiserver, so I'd double check that 1) your pythonpath is set correctly for the chroot, 2) that you're importing the correct cherrypy (and not an old system package version) and 3) that you're using the python executable you're intending to. It sounds like you're importing the wrong cherrypy, or using the wrong python executable.

Joseph

--
You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cherrypy-user...@googlegroups.com.
To post to this group, send email to cherryp...@googlegroups.com.
Visit this group at https://groups.google.com/group/cherrypy-users.
For more options, visit https://groups.google.com/d/optout.

harsh savla

unread,
Jun 24, 2016, 5:53:44 PM6/24/16
to cherrypy-users
Hi Joseph,

Thanks for your reply. You are right, it was not a cherrypy issue.

Jason Coombds, one of the lead members of the project pointed me to the solution. Here is the link: https://github.com/cherrypy/cherrypy/issues/1448

tl;dr

pyinstaller did not recognize the module 'cherrypy.wsgiserver.ssl_builtin' since it was being loaded programatically. I had to pass --hidden-import=cherrypy.wsgiserver.ssl_builtin and it worked after that.
Reply all
Reply to author
Forward
0 new messages