Re:py 2.7.1 & openssl

Discussion in 'Python' started by nirinA raseliarison, Mar 31, 2011.

  1. [V N]
    > I installed openssl-1.0.0d.tar.gz on my RHEL 5 box using:
    > ./config --prefix=/usr/local --openssldir=/usr/local/openssl
    > shared zlib


    you need to compile openssl with -fPIC flags,
    depending on your system and compiler:

    ./config linux-generic:gcc -fPIC shared

    and then recompile Python.
    otherwise, look at the make log to see why
    the building of ssl module failed.

    nirinA
    nirinA raseliarison, Mar 31, 2011
    #1
    1. Advertising

  2. nirinA raseliarison

    V N Guest

    Re: py 2.7.1 & openssl

    Thank you for your response. Here's some more information:

    RHEL 5.3 / x86_64, using gcc

    I am now compiling openssl-1.0.0d using:
    ./config --prefix=/usr/local --openssldir=/usr/local/openssl -fPIC
    shared threads zlib
    I do have the logs for config, make and make install. There are no
    errors in any of them. When I run make test, there are no errors
    reported. And, the following files are created in /usr/local/lib64:
    libssl.a, libssl.so, libcrypto.a, libcrypto.so. Also, the binary
    openssl is created in the bin directory.

    When I compile Python, I do not get any errors. In fact, I am able to
    import hashlib, ssl, md5 and
    >>> hashlib.md5

    <built-in function openssl_md5>

    The issue is only with setup tools. I tried the following:

    tar xzf bin/setuptools-0.6c11.tar.gz
    cd setuptools-0.6c11
    $PYHOME/bin/python setup.py build

    I tried to see exactly what fails in the install:
    sudo $PYHOME/bin/python setup.py install_lib <== works fine
    sudo $PYHOME/bin/python setup.py install_headers <== works fine
    sudo $PYHOME/bin/python setup.py install_scripts <== get ERROR

    File "setup.py", line 94, in <module>
    scripts = scripts,
    File "/usr/local/Python-2.7.1/lib/python2.7/distutils/core.py", line
    138, in setup
    ok = dist.parse_command_line()
    File "/export/home/vnori/setuptools-0.6c11/setuptools/dist.py", line
    271, in parse_command_line
    result = _Distribution.parse_command_line(self)
    File "/usr/local/Python-2.7.1/lib/python2.7/distutils/dist.py", line
    467, in parse_command_line
    args = self._parse_command_opts(parser, args)
    File "/export/home/vnori/setuptools-0.6c11/setuptools/dist.py", line
    590, in _parse_command_opts
    nargs = _Distribution._parse_command_opts(self, parser, args)
    File "/usr/local/Python-2.7.1/lib/python2.7/distutils/dist.py", line
    523, in _parse_command_opts
    cmd_class = self.get_command_class(command)
    File "/export/home/vnori/setuptools-0.6c11/setuptools/dist.py", line
    395, in get_command_class
    self.cmdclass[command] = cmdclass = ep.load()
    File "/export/home/vnori/setuptools-0.6c11/pkg_resources.py", line
    1954, in load
    entry = __import__(self.module_name, globals(),globals(),
    ['__name__'])
    File "/export/home/vnori/setuptools-0.6c11/setuptools/command/
    install_scripts.py", line 3, in <module>
    from easy_install import get_script_args, sys_executable, chmod
    File "/export/home/vnori/setuptools-0.6c11/setuptools/command/
    easy_install.py", line 12, in <module>
    import sys, os.path, zipimport, shutil, tempfile, zipfile, re,
    stat, random
    File "/usr/local/Python-2.7.1/lib/python2.7/tempfile.py", line 34,
    in <module>
    from random import Random as _Random
    File "/usr/local/Python-2.7.1/lib/python2.7/random.py", line 49, in
    <module>
    import hashlib as _hashlib
    File "/usr/local/Python-2.7.1/lib/python2.7/hashlib.py", line 136,
    in <module>
    globals()[__func_name] = __get_hash(__func_name)
    File "/usr/local/Python-2.7.1/lib/python2.7/hashlib.py", line 71, in
    __get_builtin_constructor
    import _md5
    ImportError: No module named _md5

    Any idea(s)?
    V N, Mar 31, 2011
    #2
    1. Advertising

  3. nirinA raseliarison

    nirinA Guest

    Re: py 2.7.1 & openssl

    [V N]
    > import _md5
    > ImportError: No module named _md5
    >
    > Any idea(s)?
    >

    try to build Python with pydebug to enable _md5:

    ./configure --with-pydebug

    nirinA
    nirinA, Mar 31, 2011
    #3
  4. nirinA raseliarison

    V N Guest

    Re: py 2.7.1 & openssl

    Yes, _md5 is enabled but I get a very long list under

    Failed to build these modules:
    _bisect _codecs_cn _codecs_hk
    _codecs_iso2022 _codecs_jp _codecs_kr
    _codecs_tw _collections _csv
    _ctypes _ctypes_test _curses
    _curses_panel _elementtree _functools
    _hashlib _heapq _hotshot
    _io _json _locale
    _lsprof _multibytecodec _multiprocessing
    _random _socket _sqlite3
    _ssl _struct _testcapi
    array audioop binascii
    bz2 cmath cPickle
    crypt cStringIO datetime
    fcntl future_builtins grp
    itertools linuxaudiodev math
    mmap nis operator
    ossaudiodev parser pyexpat
    readline resource select
    spwd strop syslog
    termios time unicodedata
    zlib

    This list was empty earlier.
    V N, Apr 1, 2011
    #4
  5. nirinA raseliarison

    nirinA Guest

    Re: py 2.7.1 & openssl

    hi,

    > Yes, _md5 is enabled but I get a very long list under
    > Failed to build these modules:
    > ... list of mostly all extension modules ...
    > This list was empty earlier.


    at some point, the compilation failed to detect
    needed headers or libraries files.
    i suggest you to try something simple in order to
    see what is wrong in the compilation step.

    first, when compiling openssl.
    your wrote in original post:

    > I installed openssl-1.0.0d.tar.gz on my RHEL 5 box using:
    > ./config --prefix=/usr/local --openssldir=/usr/local/openssl
    > shared zlib
    > make
    > sudo make install


    just try:

    ./config
    make
    make install

    and nothing else.
    do su root, when you install, not sudo.
    don't use any --prefix=xxx nor --openssldir=xxx.
    use the default location, that is /usr/local/ssl
    as this is the location where Python looks for
    ssl headers and libraries.
    don't use shared. Python uses static libraries and
    as far as i can tell, shared libraries are not
    supported yet on x86_64 platform.
    with openssl-1.0.0d, i think you don't even need
    to specify the -fPIC flag, but using it doesn't hurt.

    you also wrote:

    > And, the following files are created in /usr/local/lib64:
    > libssl.a, libssl.so, libcrypto.a, libcrypto.so. Also, the binary
    > openssl is created in the bin directory.


    these files aren't used at all, unless you change the setup.py
    file to build _ssl extension.
    i repeat: Python uses /usr/local/ssl directory
    (or /usr/contrib/ssl/) to look for ssl headers and libraries.

    secondly, when compiling Python:

    > Then I installed python 2.7.1 using
    > PYHOME=/usr/local/Python-2.7.1; export PYHOME
    > LD_RUN_PATH=$PYHOME/lib; export LD_RUN_PATH
    > LDFLAGS="-L /usr/local/lib64 -L /usr/local/lib"; export
    > LDFLAGS
    > CPPFLAGS="-I /usr/local/include -I /usr/local/include/
    > openssl"; export CPPFLAGS
    > ./configure --enable-shared --prefix=$PYHOME > log_cfg 2>&1
    > make > log_mk 2>&1
    > sudo make install > log_mk_i 2>&1


    try something simple instead of these messy configurations!
    just try:

    ./configure
    make
    make install

    if you want to install Python in a specific directory,
    e.g. /usr/local/Python-2.7.1 , use:

    make install DESTDIR=/usr/local/Python-2.7.1

    and then, you play with:

    export LD_LIBRARY_PATH=/usr/local/Python-2.7.1/lib
    /usr/local/Python-2.7.1/bin/python

    if you really want to specify some libraries and include files,
    but usually you don't, Python is smart enough to find them,
    don't use :

    > LDFLAGS="-L /usr/local/lib64 -L /usr/local/lib"; export
    > LDFLAGS
    > CPPFLAGS="-I /usr/local/include -I /usr/local/include/
    > openssl"; export CPPFLAGS


    pass them in the configuration line instead:

    CPPFLAGS="-I/usr/local/include/openssl" \
    LDFLAGS="-L/usr/local/lib64" \
    ./configure

    notice that there is no space between
    the -I or -L and the directory name.
    and the backslash to continue long line.

    finally, don't use sudo.
    try to log as root if possible.
    may be you cannot access some
    files needed for compilation
    as a simple user.
    and some LD*** and CPP*** flags
    are reset when you use sudo.

    hope this helps

    nirinA
    --
    Simple is better than complex.
    nirinA, Apr 1, 2011
    #5
  6. nirinA raseliarison

    V N Guest

    Re: py 2.7.1 & openssl

    I tried all your suggestions. No success.

    On Apr 1, 8:35 am, nirinA <> wrote:
    > hi,
    >
    > > Yes, _md5 is enabled but I get a very long list under
    > >  Failed to build these modules:
    > > ... list of mostly all extension modules ...
    > > This list was empty earlier.

    >
    > at some point, the compilation failed to detect
    > needed headers or libraries files.
    > i suggest you to try something simple in order to
    > see  what is wrong in the compilation step.
    V N, Apr 1, 2011
    #6
  7. Re: py 2.7.1 & openssl

    [V N]
    > I tried all your suggestions. No success.

    don't forget to run:
    make distclean
    before you rerun configure

    nirinA
    nirinA raseliarison, Apr 2, 2011
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Bergstrom
    Replies:
    0
    Views:
    1,213
    John Bergstrom
    Aug 3, 2003
  2. Giovanni

    Java Web Start & OpenSSL

    Giovanni, Jan 7, 2004, in forum: Java
    Replies:
    0
    Views:
    936
    Giovanni
    Jan 7, 2004
  3. root@127.0.0.1
    Replies:
    1
    Views:
    5,856
    Roedy Green
    Oct 15, 2005
  4. Jorge Rivera

    Linux OpenSSL C++ Problem

    Jorge Rivera, Jan 2, 2004, in forum: C++
    Replies:
    1
    Views:
    1,913
    Victor Bazarov
    Jan 2, 2004
  5. Redd Vinylene
    Replies:
    6
    Views:
    298
    Jakub Pawlowicz
    Nov 18, 2008
Loading...

Share This Page