qtreactor icon indicating copy to clipboard operation
qtreactor copied to clipboard

setup.py issues

Open kmike opened this issue 11 years ago • 12 comments

  • setup.py has executable bit but no #!/usr/bin/env python at the top;
  • it seems that currently installation is broken; instead of py_modules setup.py should use packages, like
from setuptools import setup, find_packages
setup(
    # ...
    packages=find_packages(),
)
  • download_url is 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_links for; it also looks unnecessary;
  • what about adding supported Python versions to classifiers explicitly, like Programming Language :: Python::2.7?

kmike avatar Sep 22 '14 15:09 kmike

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'

kmike avatar Sep 24 '14 22:09 kmike

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.

ghtdak avatar Sep 24 '14 23:09 ghtdak

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.

kmike avatar Sep 24 '14 23:09 kmike

It also seems that using package_data is wrong because pip uninstall won't work.

kmike avatar Sep 24 '14 23:09 kmike

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.

ghtdak avatar Sep 24 '14 23:09 ghtdak

looks like a sane solution - move qt4.py inside the package (and maybe rename it), then add qtreactor to pluginPackagePaths

kmike avatar Sep 24 '14 23:09 kmike

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.

ghtdak avatar Sep 25 '14 01:09 ghtdak

Yup. Appears to work fine.

ghtdak avatar Sep 25 '14 01:09 ghtdak

Was this fix ever pushed? I'm getting "twisted.application.reactors.NoSuchReactor: 'pyqt4'" after having python setup.py installed it.

estan avatar Mar 22 '15 09:03 estan

It seems to me that because of this, it's currently impossible to use the package from PyPi? Is anyone doing that?

estan avatar Mar 22 '15 10:03 estan

@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

kmike avatar Mar 22 '15 10:03 kmike

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.

estan avatar Mar 22 '15 10:03 estan