Menu

#5 setup.py install fails (but pip works)

wont-fix
nobody
None
bug
2020-01-23
2020-01-23
No

If I use setup.py the library ruamel.ordereddict appears to install correctly but then I cannot import it. If I install with pip it works fine. I've tried this with clean installs of Ubuntu 14 and 16.

#!bash

test@ubuntu:~/ordereddict_test$ hg clone https://bitbucket.org/ruamel/ordereddict
test@ubuntu:~/ordereddict_test$ cd ordereddict/

Setup.py thinks it worked but I can't import the library:

#!bash

test@ubuntu:~/ordereddict_test/ordereddict$ sudo python setup.py install
sudo python setup.py install
running install
running install
running bdist_egg
running egg_info
creating ruamel.ordereddict.egg-info
writing ruamel.ordereddict.egg-info/PKG-INFO
writing namespace_packages to ruamel.ordereddict.egg-info/namespace_packages.txt
writing top-level names to ruamel.ordereddict.egg-info/top_level.txt
writing dependency_links to ruamel.ordereddict.egg-info/dependency_links.txt
writing manifest file 'ruamel.ordereddict.egg-info/SOURCES.txt'
reading manifest file 'ruamel.ordereddict.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'ruamel.ordereddict.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/ruamel
creating build/lib.linux-x86_64-2.7/ruamel/ordereddict
copying ./__init__.py -> build/lib.linux-x86_64-2.7/ruamel/ordereddict
running build_ext
building '_ordereddict' extension
creating build/temp.linux-x86_64-2.7
x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I/usr/include/python2.7 -c ordereddict.c -o build/temp.linux-x86_64-2.7/ordereddict.o
ordereddict.c: In function ‘dict_setdefault’:
ordereddict.c:2562:70: warning: passing argument 4 of ‘dict_set_item_by_hash_or_entry’ from incompatible pointer type [-Wincompatible-pointer-types]
         if (dict_set_item_by_hash_or_entry((PyObject*)mp, key, hash, ep,
                                                                      ^
ordereddict.c:912:1: note: expected ‘PyDictEntry * {aka struct <anonymous> *} but argument is of type ‘PyOrderedDictEntry * {aka struct <anonymous> *} dict_set_item_by_hash_or_entry(register PyObject *op, PyObject *key,
 ^
ordereddict.c: At top level:
ordereddict.c:3146:18: warning: ‘dictkeys_new’ declared ‘static’ but never defined [-Wunused-function]
 static PyObject *dictkeys_new(PyObject *);
                  ^
ordereddict.c:3147:18: warning: ‘dictitems_new’ declared ‘static’ but never defined [-Wunused-function]
 static PyObject *dictitems_new(PyObject *);
                  ^
ordereddict.c:3148:18: warning: ‘dictvalues_new’ declared ‘static’ but never defined [-Wunused-function]
 static PyObject *dictvalues_new(PyObject *);
                  ^
In file included from ordereddict.c:22:0:
ordereddict.c:3150:14: warning: ‘viewkeys__doc__’ defined but not used [-Wunused-variable]
 PyDoc_STRVAR(viewkeys__doc__,
              ^
/usr/include/python2.7/Python.h:170:37: note: in definition of macro ‘PyDoc_VAR’
 #define PyDoc_VAR(name) static char name[]
                                     ^
ordereddict.c:3150:1: note: in expansion of macro ‘PyDoc_STRVAR’
 PyDoc_STRVAR(viewkeys__doc__,
 ^
ordereddict.c:3152:14: warning: ‘viewitems__doc__’ defined but not used [-Wunused-variable]
 PyDoc_STRVAR(viewitems__doc__,
              ^
/usr/include/python2.7/Python.h:170:37: note: in definition of macro ‘PyDoc_VAR’
 #define PyDoc_VAR(name) static char name[]
                                     ^
ordereddict.c:3152:1: note: in expansion of macro ‘PyDoc_STRVAR’
 PyDoc_STRVAR(viewitems__doc__,
 ^
ordereddict.c:3154:14: warning: ‘viewvalues__doc__’ defined but not used [-Wunused-variable]
 PyDoc_STRVAR(viewvalues__doc__,
              ^
/usr/include/python2.7/Python.h:170:37: note: in definition of macro ‘PyDoc_VAR’
 #define PyDoc_VAR(name) static char name[]
                                     ^
ordereddict.c:3154:1: note: in expansion of macro ‘PyDoc_STRVAR’
 PyDoc_STRVAR(viewvalues__doc__,
 ^
x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-Bsymbolic-functions -Wl,-z,relro -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/ordereddict.o -o build/lib.linux-x86_64-2.7/_ordereddict.so
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
copying build/lib.linux-x86_64-2.7/_ordereddict.so -> build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/ruamel
creating build/bdist.linux-x86_64/egg/ruamel/ordereddict
copying build/lib.linux-x86_64-2.7/ruamel/ordereddict/__init__.py -> build/bdist.linux-x86_64/egg/ruamel/ordereddict
byte-compiling build/bdist.linux-x86_64/egg/ruamel/ordereddict/__init__.py to __init__.pyc
creating stub loader for _ordereddict.so
byte-compiling build/bdist.linux-x86_64/egg/_ordereddict.py to _ordereddict.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying ruamel.ordereddict.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ruamel.ordereddict.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ruamel.ordereddict.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ruamel.ordereddict.egg-info/namespace_packages.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ruamel.ordereddict.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
writing build/bdist.linux-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/ruamel.ordereddict-0.4.9-py2.7-linux-x86_64.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing ruamel.ordereddict-0.4.9-py2.7-linux-x86_64.egg
Copying ruamel.ordereddict-0.4.9-py2.7-linux-x86_64.egg to /usr/local/lib/python2.7/dist-packages
Adding ruamel.ordereddict 0.4.9 to easy-install.pth file

Installed /usr/local/lib/python2.7/dist-packages/ruamel.ordereddict-0.4.9-py2.7-linux-x86_64.egg
Processing dependencies for ruamel.ordereddict==0.4.9
Finished processing dependencies for ruamel.ordereddict==0.4.9

test@ubuntu:~/ordereddict_test/ordereddict$ python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ruamel.ordereddict
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named ruamel.ordereddict
>>> quit()

test@ubuntu:~/ordereddict_test/ordereddict$ pip list
adium-theme-ubuntu (0.3.4)
mercurial (3.7.3)
pip (8.1.1)
ruamel.ordereddict (0.4.9)
setuptools (20.7.0)
unity-lens-photos (1.0)
wheel (0.29.0)

Pip works:

#!bash

test@ubuntu:~/ordereddict_test/ordereddict$ sudo pip install .
The directory '/home/test/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/test/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Processing /home/test/ordereddict_test/ordereddict
Installing collected packages: ruamel.ordereddict
  Running setup.py install for ruamel.ordereddict ... done
Successfully installed ruamel.ordereddict-0.4.9
You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
test@ubuntu:~/ordereddict_test/ordereddict$ python
Python 2.7.11+ (default, Apr 17 2016, 14:00:29) 
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ruamel.ordereddict
>>>

(originally posted on 2016-08-21 at 12:39:02 by NN <former_user@bitbucket>)

Discussion

  • Anthon van der Neut

    • status set to wontfix

    The setup.py is not up to date, it should just error and tell you to use pip. I'll incorporate that on the next update.

    (originally posted on 2016-08-21 at 13:27:06)

     
  • Anthon van der Neut

    This would break when ruamel.yaml or ruamel.ordereddict are part of the install_requires of another package in a setup.py file and a user simply runs python setup.py install - that is still a fairly standard thing to do (we're trying to do this with Ansible Container). It would be very helpful/user-friendly if you'd reconsider this issue as valid.

    (originally posted on 2017-03-24 at 00:16:46 by Joshua Ginsberg <j00bar@bitbucket>)

     
  • Anthon van der Neut

    If ruamel.yaml is part of an install_requires and not already installed in your container, you are doomed. Your container will need the C compiler installed and and the libyaml from your distribution.

    I don't know Ansible Container, but if it is like Docker, there is nothing that magically autodetects C library dependencies (like libyaml) in indirectly loaded python packages. Since you are going to have to change your container specification by hand when you are (indirectly) dependent on ruamel.yaml/ruamel.ordereddict, you might as well change that specification in such a way that you install a recent version of pip in the container and pull in the ruamel.yam/ruamel.ordereddict wheels.

    (originally posted on 2017-03-24 at 08:55:35)

     
  • Anthon van der Neut

    Howdy!

    Ansible Container is a Python project that builds/runs a special container to build/run other containers. Inside our special container, yep, we pip install inside of our container because we need it to work - and we control all of the dependencies in that container. But we also use ruamel.yaml outside of the container in the Python app that launches the various containers. A lot of folks, especially those who follow HEAD on GitHub, clone the repo and python setup.py install or python setup.py develop - it's pretty standard procedure to simply use setuptools to build/install a package.

    Unless you're suggesting that every package that uses ruamel.yaml should require the additional step of pip install -r requirements.txt to install?

    I'm happy to submit a PR if you can give me some guidance as to why it's broken using setuptools but not pip.

    Thanks!

    (originally posted on 2017-03-24 at 15:57:42 by Joshua Ginsberg <j00bar@bitbucket>)

     

Log in to post a comment.

MongoDB Logo MongoDB