setup.py issues
- setup.py has executable bit but no
#!/usr/bin/env pythonat the top; - it seems that currently installation is broken; instead of
py_modulessetup.py should usepackages, like
from setuptools import setup, find_packages
setup(
# ...
packages=find_packages(),
)
download_urlis not needed when sources are uploaded to pypi; it can be misleading if a version on pypi doesn't match the version available at that URL, and it is extra maintenance burden.- it seems that twisted plugin is not installed now;
- I'm not sure what is
dependency_linksfor; it also looks unnecessary; - what about adding supported Python versions to classifiers explicitly, like
Programming Language :: Python::2.7?
The issue with twisted plugin still exists - the plugin is not installed. If you install qt4reactor from pip, then change dir to something other than qtreactor source checkout and try to run an example from README it'll fail:
In [1]: from twisted.application import reactors
In [2]: reactors.installReactor('pyqt4')
---------------------------------------------------------------------------
NoSuchReactor Traceback (most recent call last)
<ipython-input-2-3c86dab0ef8a> in <module>()
----> 1 reactors.installReactor('pyqt4')
/Users/kmike/envs/splash/lib/python2.7/site-packages/twisted/application/reactors.pyc in installReactor(shortName)
82 from twisted.internet import reactor
83 return reactor
---> 84 raise NoSuchReactor(shortName)
85
NoSuchReactor: 'pyqt4'
The plug-in... hmmm. The Twisted approach to plug-ins is that the twisted directory needs to be somewhere in your path. twisted/plugins can't be a module (no init.py)... then Twisted goes hunting and puts together the list of plugins.
Basically, an install of QtReactor would have plugins in its directory at the top level. Hmmm. Thinking. This should be easy... I'll get in it.
There is a SO question: http://stackoverflow.com/questions/7275295/how-do-i-write-a-setup-py-for-a-twistd-twisted-plugin-that-works-with-setuptools
It seems that hacks from the top answer are not needed because pip issue was fixed, and that adding 'twisted.plugins' to "packages" could make it work, but I haven't tried it.
It also seems that using package_data is wrong because pip uninstall won't work.
Ah, found this: http://twistedmatrix.com/documents/current/core/howto/plugin.html#auto3 which says put the following in the main init.py
from twisted.plugin import pluginPackagePaths
__path__.extend(pluginPackagePaths(__name__))
__all__ = []
Ah so...
This was kind of an issue a while ago. Apparently, they've been worked.
looks like a sane solution - move qt4.py inside the package (and maybe rename it), then add qtreactor to pluginPackagePaths
Can't we make a qt4reactor directory with just an init.py somehow? Then the same path "should" be available. But we might run into the sibling directories thing. It all seems doable but I've been having some trouble with the whole import world lately.
Yup. Appears to work fine.
Was this fix ever pushed? I'm getting "twisted.application.reactors.NoSuchReactor: 'pyqt4'" after having python setup.py installed it.
It seems to me that because of this, it's currently impossible to use the package from PyPi? Is anyone doing that?
@estan I don't recall if this issue is fixed or not; we're using qt4reactor from pypi like this: https://github.com/scrapinghub/splash/blob/a18dbac13c8b13afe8c744d928650cbb2ce0b03f/splash/server.py#L15
Thanks a lot for the quick reply @kmike , it seems to work now. I was doing the installing the wrong way, using:
app = QApplication(sys.argv) # your code to init QtCore
from twisted.application import reactors
reactors.installReactor('pyqt4')
instead of
app = PyQt4.QtGui(sys.argv) # your code to init QtGui
from qtreactor import pyqt4reactor
pyqt4reactor.install()
Cheers.