Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W/o setuptools, "setup.py install" skips zope/interface/common/ #13

Closed
tseaver opened this issue Jan 11, 2015 · 10 comments
Closed

W/o setuptools, "setup.py install" skips zope/interface/common/ #13

tseaver opened this issue Jan 11, 2015 · 10 comments
Labels

Comments

@tseaver
Copy link
Member

tseaver commented Jan 11, 2015

In https://bugs.launchpad.net/zope.interface/+bug/611362, @exarkun reported:

After installing the 3.6.1 release from PyPI, the zope.interface.common package is not available:

exarkun@boson:~/Downloads$ tar xzf zope.interface-3.6.1.tar.gz
exarkun@boson:~/Downloads$ cd zope.interface-3.6.1/
exarkun@boson:~/Downloads/zope.interface-3.6.1$ python setup.py install --quiet --prefix /tmp/ZOPE-TEST
/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'test_suite'
....
exarkun@boson:~/Downloads/zope.interface-3.6.1$ PYTHONPATH=/tmp/ZOPE-TEST/ python -c 'from zope.interface import common'
Traceback (most recent call last):
    File "<string>", line 1, in <module>
ImportError: cannot import name common
exarkun@boson:~/Downloads/zope.interface-3.6.1$

and supplied a patch:

https://bugs.launchpad.net/zope.interface/+bug/611362/+attachment/1471651/+files/setup.patch

I followed up:

Hmm, this seems to be true only when installing without setuptools:

@glyph followed up:

I just heard about a case of this happening on Ubuntu 12.10. I suspect it's a bug in setuptools or distutils or ubuntu's patching of same, not zope.interface; can someone comment on what mechanism ZI uses to include the 'common' package? I don't see it in setup.cfg, or a manifest file... I am guessing there's some setuptools magic which is supposed to make it get included.
Also of note; setuptools was installed on the system where this happened. It was zope.interface 4.0.3 in this case.

@tseaver tseaver added the bug label Jan 11, 2015
@glyph
Copy link

glyph commented Jan 12, 2015

ZI 3.6.0 and Ubuntu 12.10 were both quite a while ago. I haven't seen this in some time; all my virtualenvs wth ZI 4+ and Ubuntu 14+ have been working flawlessly and I make new ones just about every day. Someone else will have to attempt to verify that this is still an issue.

@glyph
Copy link

glyph commented Jan 12, 2015

Thank you for remembering though @tseaver !

@tseaver
Copy link
Member Author

tseaver commented Jan 12, 2015

I think the issue only occurs now when you don't have setuptools installed. So, to reproduce::

$ /opt/Python-2.7.9/bin/virtualenv --no-setuptools /tmp/bare
$ cd /tmp/bare
$ wget https://pypi.python.org/packages/source/z/zope.interface/zope.interface-4.1.2.tar.gz
$ tar xf zope.interface-4.1.2.tar.gz
$ cd zope.interface-4.1.2
$ ../bin/python setup.py install

If you just create a virtualenv normally and the pip install zope.interface, everything works as expected.

@mgedmin
Copy link
Member

mgedmin commented Jan 12, 2015

Do we want to support setuptools-less installs?

You need setuptools for zope.* namespace packages on Python < 3.3 anyway.

@mgedmin
Copy link
Member

mgedmin commented Jan 12, 2015

BTW #14 is a duplicate of this, and has a patch.

@tseaver
Copy link
Member Author

tseaver commented Jan 12, 2015

@mgedmin we do the pkgutil dance to allow namespace packages w/o setuptools:

$ cat projects/Zope/Z3/zope.interface/src/zope/__init__.py
# this is a namespace package
try:
    import pkg_resources
    pkg_resources.declare_namespace(__name__)
except ImportError:
    import pkgutil
    __path__ = pkgutil.extend_path(__path__, __name__)

@fgregg
Copy link
Contributor

fgregg commented Aug 21, 2015

I think some of my users are running into this: dedupeio/dedupe#268

But I do have setuptools. https://github.com/datamade/dedupe/blob/master/setup.py#L5-L24

@jamadden
Copy link
Member

jamadden commented Aug 2, 2016

To the question @mgedmin raised: is it still worth supporting setuptools-less installs? Is there anyone still trying to install with just distutils?

  • pip always installs with setuptools
  • buildout always installs with setuptools
  • virtualenv creates environments with setuptools
  • Starting with Python 3.4 the stdlib venv installs pip, and thus setuptools, by default.

@mgedmin
Copy link
Member

mgedmin commented Aug 3, 2016

Huh, from the patch mentioned in #14:

@@ -121,7 +122,13 @@
         "Topic :: Software Development :: Libraries :: Python Modules",
       ],

-      packages = ['zope', 'zope.interface', 'zope.interface.tests'],
+      packages = [
+        'zope',
+        'zope.interface',
+        'zope.interface.tests',
+        'zope.interface.common',
+        'zope.interface.common.tests',
+      ],
       package_dir = {'': 'src'},
       cmdclass = {'build_ext': optional_build_ext,
                   },

I see no reason to explicitly enumerate half of zope.interface subpackages in the setup.py. Let's either apply that or use setuptools.find_packages().

@jamadden
Copy link
Member

jamadden commented Aug 3, 2016

Good point. There's also now this lovely block where if importing setuptools fails, the C optimizations don't get built:

try:
    from setuptools import setup, Extension, Feature
except ImportError:
    # do we need to support plain distutils for building when even
    # the package itself requires setuptools for installing?
    from distutils.core import setup, Extension
    extra = {}
else:
  # Define the C extension...
  extra = dict(...

So I'm +1 to going all-in on setuptools. I can make a new PR if desired.

jamadden added a commit that referenced this issue Aug 4, 2016
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Sep 1, 2016
Add missing dependency.

4.3.1 (2016-08-31)
------------------

- Support Components subclasses that are not hashable.
  (zopefoundation/zope.interface#53)


4.3.0 (2016-08-31)
------------------

- Add the ability to sort the objects returned by ``implementedBy``.
  This is compatible with the way interface classes sort so they can
  be used together in ordered containers like BTrees.
  (zopefoundation/zope.interface#42)

- Make ``setuptools`` a hard dependency of ``setup.py``.
  (zopefoundation/zope.interface#13)

- Change a linear algorithm (O(n)) in ``Components.registerUtility`` and
  ``Components.unregisterUtility`` into a dictionary lookup (O(1)) for
  hashable components. This substantially improves the time taken to
  manipulate utilities in large registries at the cost of some
  additional memory usage. (zopefoundation/zope.interface#46)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants