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

pip doesn't install PyObjC #11

Closed
vbabiy opened this issue Mar 15, 2011 · 21 comments
Closed

pip doesn't install PyObjC #11

vbabiy opened this issue Mar 15, 2011 · 21 comments
Labels
auto-locked Outdated issues that have been locked by automation type: bug A confirmed bug or unintended behavior

Comments

@vbabiy
Copy link
Contributor

vbabiy commented Mar 15, 2011

Hi,

I'm trying to install PyObjC with pip, it give following error message and it terminates.

#!bash

$ sudo pip install PyObjC                                                                
Downloading/unpacking PyObjC
  Running setup.py egg_info for package PyObjC

Downloading/unpacking pyobjc-core==2.3 (from PyObjC)
  Running setup.py egg_info for package pyobjc-core
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'use_2to3'
      warnings.warn(msg)
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trashcli/build/pyobjc-core/setup.py", line 452, in <module>
        **extra_args
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup
        dist.run_commands()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trashcli/build/pyobjc-core/setup.py", line 110, in run
        orig_egg_info.egg_info.run(self)
      File "<string>", line 7, in replacement_run
    AttributeError: class egg_info has no attribute 'iter_entry_points'
    Complete output from command python setup.py egg_info:
    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: 'use_2to3'

  warnings.warn(msg)

running egg_info

Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trashcli/build/pyobjc-core/setup.py", line 452, in <module>

    **extra_args

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup

    dist.run_commands()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands

    self.run_command(cmd)

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command

    cmd_obj.run()

  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/trashcli/build/pyobjc-core/setup.py", line 110, in run

    orig_egg_info.egg_info.run(self)

  File "<string>", line 7, in replacement_run

AttributeError: class egg_info has no attribute 'iter_entry_points'

----------------------------------------
Command python setup.py egg_info failed with error code 1
Storing complete log in /Users/abhinay/.pip/pip.log

Any suggestions please?


@vbabiy
Copy link
Contributor Author

vbabiy commented Mar 15, 2011

For what I see, these packages rely on distribute. The use_2to3 is a
distribute thing. Anyway, pyobjc-core has a workaround for a bug, I believe,
in distribute.

You should try installing distribute, and them installing PyObjC again.

I don't have a Mac here, so I cant try anything :(

By the way, it does not look like a pip bug.

Good luck!


Original Comment By: Hugo Lopes Tavares

@vbabiy
Copy link
Contributor Author

vbabiy commented Mar 15, 2011

I think the use_2to3 thing is a red herring here -- it's just a UserWarning,
and does not seem to have any bearing on the traceback itself.

I have just run across this unhappy error on my Mac. I've tried poking at the
setup.py file for pyobjc-core, and it is confusing -- they do some importing
of egg_info from setuptools, and then subclass egg_info, or something like
that. I've filed a bug with the PyObjC SourceForge tracker for future
developments:

https://sourceforge.net/tracker/?func=detail&aid=3195876&group_id=14534&atid=
114534

4&atid=114534


Original Comment By: https://sourceforge.net/tracker/?func=detail&amp;aid=3195876&amp;group_id=14534&amp;atid=114534

@MatthewMaker
Copy link
Contributor

If I remember the code rightly, this is probably two pip bugs. 1) pip uses an extreme hack to subclass egg_info itself, which will break other people trying to do that, and 2) pip runs each setup.py separately, reimporting setuptools each time, so the monkeypatches that were in the "first" setup.py unfortunately are not still in effect for the dependencies' setup.py files. This is a major difference between pip install and setup.py install.

@madprog
Copy link

madprog commented Sep 17, 2011

Hello,

I tried to patch pyobjc's setup.py so that it can be installable with pip. I am NOT sure it is OK, this patch is just a clue:

diff -ru pyobjc-core-2.3/setup.py pyobjc-core-2.3_pip/setup.py
--- pyobjc-core-2.3/setup.py    2010-07-24 16:38:17.000000000 +0200
+++ pyobjc-core-2.3_pip/setup.py    2011-09-17 10:47:50.000000000 +0200
@@ -38,7 +38,7 @@


 extra_args=dict(
-    use_2to3 = True,
+    #use_2to3 = True,
 )

 from setuptools.command import build_py
@@ -436,7 +436,7 @@
     namespace_packages = ['PyObjCTools'],
     package_dir = { '': 'Lib', 'PyObjCTest': 'PyObjCTest' },
     extra_path = "PyObjC",
-    cmdclass = {'build_ext': pyobjc_build_ext, 'install_lib': pyobjc_install_lib, 'build_py': oc_build_py, 'test': oc_test, 'egg_info':egg_info },
+    cmdclass = {'build_ext': pyobjc_build_ext, 'install_lib': pyobjc_install_lib, 'build_py': oc_build_py, 'test': oc_test, 'egg_info':orig_egg_info.egg_info },
     options = {'egg_info': {'egg_base': 'Lib'}},
     classifiers = CLASSIFIERS,
     license = 'MIT License',

I mean, this patch removes an action on some header files (I haven't understood what it does yet), but pip install doesn't fail any more. Now I'll try to use it :)

@jergason
Copy link

Modifying setup.py seemed to work. but I am still not sure. Here is the sequence of commands I ran.

cd ~
pip install pyobjc
# lots of errors
cd ~/build/pyobjc-core
vim setup.py
#edit to match the patched setup.py file posted by madprog
cd ~
pip install --no-download pyobjc

@madprog
Copy link

madprog commented Sep 20, 2011

Actually I updated the patch to use the egg_info.run() override, and I think it is better:

diff --git a/pyobjc/pyobjc-core/setup.py b/pyobjc/pyobjc-core/setup.py
index a68ca97..54d7bdb 100644
--- a/pyobjc/pyobjc-core/setup.py
+++ b/pyobjc/pyobjc-core/setup.py
@@ -39,7 +39,7 @@ except ImportError:


 extra_args=dict(
-    use_2to3 = True,
+    #use_2to3 = True,
 )

 def get_os_level():
@@ -100,7 +100,7 @@ class oc_test (test.test):

         unittest.main(None, None, [unittest.__file__]+self.test_args)

-from setuptools.command import egg_info as orig_egg_info
+from setuptools.command import egg_info

 def write_header(cmd, basename, filename):
     data = open(os.path.join('Modules/objc/', os.path.basename(basename)), 'rU').read()
@@ -116,9 +116,9 @@ def write_header(cmd, basename, filename):
 # call, but those don't work when also using a package_base
 # argument as we do.
 # (issue 123 in the distribute tracker)
-class egg_info (orig_egg_info.egg_info):
+class my_egg_info (egg_info.egg_info):
     def run(self):
-        orig_egg_info.egg_info.run(self)
+        egg_info.egg_info.run(self)

         for hdr in ("pyobjc-compat.h", "pyobjc-api.h"):
             fn = os.path.join("include", hdr)
@@ -448,7 +448,7 @@ dist = setup(
     namespace_packages = ['PyObjCTools'],
     package_dir = { '': 'Lib', 'PyObjCTest': 'PyObjCTest' },
     extra_path = "PyObjC",
-    cmdclass = {'build_ext': pyobjc_build_ext, 'install_lib': pyobjc_install_lib, 'build_py': oc_build_py, 'test': oc_test, 'egg_info':egg_info },
+    cmdclass = {'build_ext': pyobjc_build_ext, 'install_lib': pyobjc_install_lib, 'build_py': oc_build_py, 'test': oc_test, 'egg_info': my_egg_info },
     options = {'egg_info': {'egg_base': 'Lib'}},
     classifiers = CLASSIFIERS,
     license = 'MIT License',

Then you just run pip install $PWD, being in the pyobjc directory, and it works.
Then I had to pip install path/to/pyobjc-framework-Cocoa too as I was interested in accessing the Foundation framework.

Hope that it works for you too!

@tiliv
Copy link

tiliv commented Oct 9, 2011

madprog's patch worked great for making the process actually get started. Thank you so much for posting that. It seems to lead me to a later error after the dependencies are downloaded, stating vaguely "running build_ext; error: Permission denied". No obvious tricks are resolving the issue. I can't even find the silly line that is responsible, because the command being executed is just a string, with temp files as build scripts and pip install records.

I hesitate to get too far off the original problem, but here's what I end up with during the build phase:

running install
running build
running build_py
Overriding build_packages to copy PyObjCTest
running build_ext
error: Permission denied
------
Complete output from command /Users/Miyako/Etc/virtualenv/bin/python -c "import setuptools;__file__='/var/folders/rx/hvchmjtx027dy05fs5mqkyk80000gn/T/pip-7wz5am-build/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /var/folders/rx/hvchmjtx027dy05fs5mqkyk80000gn/T/pip-bzfebf-record/install-record.txt --install-headers /Users/Miyako/Etc/virtualenv/include/site/python3.2

These temp files do not exist after the installation aborts, but the temp files it chooses are obviously different every execution. I can't even begin to guess what part of that command is causing permission errors. Prefixing my initial command with sudo apparently doesn't go through deep enough to this string execution.

@superdave
Copy link

I found where the problem is in build_ext.

  • The "permission denied" is from the libxml2 config part. For whatever reason, the config script isn't executable, but sticking a '/bin/sh' in front will resolve that.
  • Once that's actually executing, the major problem I face is that Python is not built with XCode 4.2, which got rid of the gcc-4.2 alias (the only GCC XCode 4.2 supports is a GCC wrapper on top of Clang). They got rid of the gcc-4.2 alias as well, which is what setuptools is passing as the CC environment variable to the configure script. I can hack that out temporarily, but I'm trying to remember what I did to force this fix when I built pyopencl.

I'll post more if I find a nice solution.

@willperkins
Copy link

superdave, were you able to find a nice solution to this?

@sneak
Copy link

sneak commented Jun 16, 2012

+1 bitten by this

@msabramo
Copy link
Contributor

Is this really a bug in pip or is it because the setup.py in PyObjC is doing crazy stuff? I tried the patch above and it got me past the iter_entry_points error and got me to the RuntimeError: libxml install failed error.

@msabramo
Copy link
Contributor

@superdave Did you try CC=gcc-4.0 -- maybe that's what you were trying to think of?

@superdave
Copy link

It's not a bug in pip; as the Python maintainers explained, it's because Python attempts to build its extension modules with the GCC it was compiled with. Since the current version of Python was built with XCode 4.1, and XCode 4.2 and beyond get rid of the gcc-4.2 alias, it breaks.

If CC=gcc-4.0 fixed the problem, I would have fixed it a lot faster. :-) When I managed to build PyOpenCL in a similar fashion, I had to adjust a whole bunch of environment variables (related to dynamic linking) that also had the compiler string built in; I eventually just gave up on PyObjC, but one of these days when I have more time, I'll take up the torch again.

@willperkins
Copy link

I was able to workaround by doing this:

virtualenv env # setup the virtual env
source env/bin/activate
pip install pyobjc
#now it fails with pyobjc-core
# 1: update some permissions
chmod a+x env/build/pyobjc-core/libxml2-src/configure
chmod a+x env/build/pyobjc-core/libxml2-src/install-sh
# 2: do some find/replace
sed -i.bak 's/use_2to3 = True/use_2to3 = False/g' env/build/pyobjc-core/setup.py
# 3: install with the setup.py
pushd env/build/pyobjc-core/
python setup.py install
popd
# 4: retry the pyobjc install
pip install pyobjc

then it worked.

@msabramo
Copy link
Contributor

If folks could try the change in PR 584 (commit ea109a0) and report on whether it worked here, that might help with getting this old issue fixed.

@madprog
Copy link

madprog commented Jun 22, 2012

Great job, msabramo!

msabramo added a commit to msabramo/pip that referenced this issue Jul 2, 2012
@pnasrat pnasrat closed this as completed in ea109a0 Jul 2, 2012
ptone added a commit to ptone/pip that referenced this issue Jul 2, 2012
* 'develop' of git://github.com/pypa/pip:
  Add HackedEggInfo test for the the fix for pypaGH-11.
  generate error in test same way as pip.req
  Fix incorrect mocking.
  Fix missing import in test.
  Fix failing windows test.
  Skip submodule testing on windows.
  Prevent assertion error from scripttest on windows.
  Fix failng windows tests.
  Fix failing bzr vcs test
  use nose.tools.assert_raises
  raise InstallationError when UninstallPathSet has no paths
  don't --user install in --system-site-packages virtualenvs with conflict
  Make magic use pkg_resources.iter_entry_points instead of relying on egg_info.iter_entry_points, which might not be there if someone redefines egg_info (like the setup.py for pyobjc-core does)
  non_hierarchical was dropped at the same time as uses_fragment (pypa#552)
  fix compatability w/3.3 & 2.7.4 & bazaar (pypa#552)
@rattrayalex
Copy link

How does one go about fixing RuntimeError: libxml configure failed? I copied the script @willperkins drew up, but still hit that and don't know what to do. Thanks

@willperkins
Copy link

@mouseplatterman if you can, you should try what @msabramo mentioned above - it looks to be the best solution.

@rattrayalex
Copy link

Did that too -- got me to the build_ext error, which was corrected by running chmod as you suggested (top of the libxml2-src/configure also reads #! /bin/sh), and when I re-ran pip install pyobjc, the libxml error still popped up. I did install libxml2 for python and can successfully import libxml2 (although not in the virtualenv -- could that be the problem?) Thanks again for the help, I know the pip issues comments aren't quite the right place for this but not sure where else to turn.

@rattrayalex
Copy link

(for posterity:)
solved this by editing build/pyobjc-core/setup.py at line 209:
replaced: 'CC=%s'%(get_config_var('CC')),
with: '--with-gcc=clang',
thanks to http://stackoverflow.com/questions/8032824/cant-install-ruby-under-lion-with-rvm-gcc-issues

@msabramo
Copy link
Contributor

@mouseplatterman Thanks for sharing your workaround; I posted it at https://sourceforge.net/tracker/?func=detail&aid=3195876&group_id=14534&atid=114534 so that the PyObjC folks can know about it.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests