Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #2275 > unrolled thread

Re:py 2.7.1 & openssl

Started bynirinA raseliarison <nirina.raseliarison@gmail.com>
First post2011-03-31 00:46 -0700
Last post2011-04-02 10:44 +0300
Articles 7 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  Re:py 2.7.1 & openssl nirinA raseliarison <nirina.raseliarison@gmail.com> - 2011-03-31 00:46 -0700
    Re: py 2.7.1 & openssl V N <vijay.nori@gmail.com> - 2011-03-31 10:51 -0700
      Re: py 2.7.1 & openssl nirinA <nirina.raseliarison@gmail.com> - 2011-04-01 01:43 +0300
        Re: py 2.7.1 & openssl V N <vijay.nori@gmail.com> - 2011-03-31 16:42 -0700
          Re: py 2.7.1 & openssl nirinA <nirina.raseliarison@gmail.com> - 2011-04-01 15:35 +0300
            Re: py 2.7.1 & openssl V N <vijay.nori@gmail.com> - 2011-04-01 10:03 -0700
              Re: py 2.7.1 & openssl nirinA raseliarison <nirina.raseliarison@gmail.com> - 2011-04-02 10:44 +0300

#2275 — Re:py 2.7.1 & openssl

FromnirinA raseliarison <nirina.raseliarison@gmail.com>
Date2011-03-31 00:46 -0700
SubjectRe:py 2.7.1 & openssl
Message-ID<mailman.27.1301557619.2990.python-list@python.org>
[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

[toc] | [next] | [standalone]


#2291

FromV N <vijay.nori@gmail.com>
Date2011-03-31 10:51 -0700
Message-ID<84bb4467-97dd-4ed6-a2a0-dcbaf6904746@r4g2000prm.googlegroups.com>
In reply to#2275
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)?

[toc] | [prev] | [next] | [standalone]


#2311

FromnirinA <nirina.raseliarison@gmail.com>
Date2011-04-01 01:43 +0300
Message-ID<mailman.51.1301611416.2990.python-list@python.org>
In reply to#2291
[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

[toc] | [prev] | [next] | [standalone]


#2314

FromV N <vijay.nori@gmail.com>
Date2011-03-31 16:42 -0700
Message-ID<6ab0c9c7-b9da-4a7a-a146-d84172e67936@l2g2000prg.googlegroups.com>
In reply to#2311
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.

[toc] | [prev] | [next] | [standalone]


#2346

FromnirinA <nirina.raseliarison@gmail.com>
Date2011-04-01 15:35 +0300
Message-ID<mailman.71.1301661333.2990.python-list@python.org>
In reply to#2314
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.

[toc] | [prev] | [next] | [standalone]


#2374

FromV N <vijay.nori@gmail.com>
Date2011-04-01 10:03 -0700
Message-ID<a508ab77-81b8-449d-b49e-5df4e28d5660@t19g2000prd.googlegroups.com>
In reply to#2346
I tried all your suggestions. No success.

On Apr 1, 8:35 am, nirinA <nirina.raseliari...@gmail.com> 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.

[toc] | [prev] | [next] | [standalone]


#2442

FromnirinA raseliarison <nirina.raseliarison@gmail.com>
Date2011-04-02 10:44 +0300
Message-ID<mailman.123.1301730261.2990.python-list@python.org>
In reply to#2374
[V N]
> I tried all your suggestions. No success.
don't forget to run:
   make distclean
before you rerun configure

nirinA

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web