Installing Python modules with Unified Installer

8 Messages Forum Options Options
Embed this topic
Permalink
Brian Roberg
Installing Python modules with Unified Installer
Reply Threaded More
Print post
Permalink
Hello everyone,

The last time I set up a Plone system was back in the days before the Unified Installer.  I like how everything is self-contained with the Unified Installer, but this leaves me with a question: How do I install additional Python modules for Zope to use?  (I know how to do this for the system Python, but not the Zope Python.)  I've got my Plone instance up and running, and now I want to install the python-ldap module so that I can use LDAP authentication.

I'm using the Plone 3.0.3 Unified Installer on Linux.

Cheers,
Brian

P.S. Sorry for the duplicate post in the forum.
Steve McMahon
Re: Installing Python modules with Unified Installer
Reply Threaded More
Print post
Permalink
You do a normal Python module install, but make sure you use the copy
of Python installed with your Zope/Plone.

So, if you were using setup.py, it might look like:

/opt/Plone-3.0.3/Python-2.4.4/bin/python setup.py



On 12/15/07, robergb <robergb@...> wrote:

>
> Hello everyone,
>
> The last time I set up a Plone system was back in the days before the
> Unified Installer.  I like how everything is self-contained with the Unified
> Installer, but this leaves me with a question: How do I install additional
> Python modules for Zope to use?  (I know how to do this for the system
> Python, but not the Zope Python.)  I've got my Plone instance up and
> running, and now I want to install the python-ldap module so that I can use
> LDAP authentication.
>
> I'm using the Plone 3.0.3 Unified Installer on Linux.
>
> Cheers,
> Brian
>
> P.S. Sorry for the duplicate post in the forum.
> --
> View this message in context: http://www.nabble.com/Installing-Python-modules-with-Unified-Installer-tp14354398s15482p14354398.html
> Sent from the Installation, Setup, Upgrades mailing list archive at Nabble.com.
>
>
> _______________________________________________
> Setup mailing list
> Setup@...
> http://lists.plone.org/mailman/listinfo/setup
>


--

______________________________________________________

Steve McMahon
Reid-McMahon, LLC
steve@...
steve@...

_______________________________________________
Setup mailing list
Setup@...
http://lists.plone.org/mailman/listinfo/setup
kteague
Re: Installing Python modules with Unified Installer
Reply Threaded More
Print post
Permalink
In reply to this post by Brian Roberg
The easiest way to work with a particular Python for a particular Plone installation is to put that Python first on your PATH:

$ export PATH=/opt/Plone-3.0.4/Python-2.4.4/bin:$PATH
$ which python
/opt/Plone-3.0.4/Python-2.4.4/bin/python

For python-lap you should then be able to to:

$ python setup.py install

Note that this is basically the same as this:

$ /opt/Plone-3.0.4/Python-2.4.4/bin/python setup.py install

But manipulating your PATH environment variable just saves you a lot of typing. You can also create aliases in your shell profile (~/.bashrc on linux, ~/.profile on Mac OS X) to make it easier to put a particular Python first on your PATH:

# in your .bashrc or .profile
alias py4prod="export PATH=/opt/Plone-3.0.4/Python-2.4.4/bin:$PATH"
alias py4dev="export PATH=/opt/Plone-3.1/Python-2.4.4/bin:$PATH"

Then on your shell just type:

$ py4prod
$ echo $PATH
$ /opt/Plone-3.0.4/Python-2.4.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Jon Stahl
Re: Installing Python modules with Unified Installer
Reply Threaded More
Print post
Permalink
Kevin-

I took the liberty of turning this into a FAQ at:

http://plone.org/documentation/faq/how-do-i-install-python-modules-to-the-unified-installer/

Thanks!  This is a really helpful explanation/tip!  Please let me know if the article needs to be corrected any.

best,
jon
Kevin Teague wrote:
The easiest way to work with a particular Python for a particular Plone installation is to put that Python first on your PATH:

$ export PATH=/opt/Plone-3.0.4/Python-2.4.4/bin:$PATH
$ which python
/opt/Plone-3.0.4/Python-2.4.4/bin/python

For python-lap you should then be able to to:

$ python setup.py install

Note that this is basically the same as this:

$ /opt/Plone-3.0.4/Python-2.4.4/bin/python setup.py install

But manipulating your PATH environment variable just saves you a lot of typing. You can also create aliases in your shell profile (~/.bashrc on linux, ~/.profile on Mac OS X) to make it easier to put a particular Python first on your PATH:

# in your .bashrc or .profile
alias py4prod="export PATH=/opt/Plone-3.0.4/Python-2.4.4/bin:$PATH"
alias py4dev="export PATH=/opt/Plone-3.1/Python-2.4.4/bin:$PATH"

Then on your shell just type:

$ py4prod
$ echo $PATH
$ /opt/Plone-3.0.4/Python-2.4.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
-----
Jon Stahl, Director of Web Solutions
ONE/Northwest - Online Networking for the Environment
http://www.onenw.org
kteague
Re: Installing Python modules with Unified Installer
Reply Threaded More
Print post
Permalink
Cool.

I've been working on some "Python and Plone" notes that I hope to develop into a more full-fledged How-To or Tutorial, since it would be quite helpful to have all of this documented in one place. Often we just have the assumption that people have learned these fundamentals from OS-specific docs or Python-specific docs, but often people learn about these things "the hard way". I know I've made just about every dumb mistake when learning these things myself :)

For the FAQ, the examples could be made a little more explicit by showing before/after behaviour, e.g.:

$ which python
/usr/bin/python
$ export PATH=/opt/Plone-3.0.4/Python-2.4.4/bin:$PATH
$ which python
/opt/Plone-3.0.4/Python-2.4.4/bin/python

For the package example to make it explicit the fact you are working in a source package:

$ cd ~/builds/your-python-package
$ python setup.py install

Also, if you are manipulating your environment, it's important to be aware of this fact. People will often make changes in their shell profile, and then forget all about them, and can run into problems when trying to install Python packages for a different application (or different Plone install). You would never want to do these alterations to the shell profile for the root account for example (beyond providing aliases, since they have to invoked explicitly).

One way to remind yourself of environment customizations is to alter the PS1 environment variable:

hostname:~ username$ echo $PS1
\h:\W \u$
hostname:~ username$ export PS1='(name-of-my-plone-install)\h:\W \u\$ '
(name-of-my-plone-install)hostname:~ username$

Which can be wrapped into an alias:

alias py4prod="PATH=/path/to/python/bin:$PATH; export PS1='(prod-py-plone)\h:\W \u\$ '"

Jupiter2
Installing Python modules with Unified Installer: Deb. Etch
Reply Threaded More
Print post
Permalink
In reply to this post by Jon Stahl
Am trying to get ldap authentication (after installing using the Universal Installer on Debian Etch)
Am at the point of installing ldap module into python under /opt
Have tried instructions here:

http://plone.org/documentation/faq/how-do-i-install-python-modules-to-the-unified-installer/

(thanks) but install falls over.
I am guessing that the problem is in the setup.cfg file with these two lines:

library_dirs = /usr/local/openldap-2.3/lib
include_dirs = /usr/local/openldap-2.3/include /usr/include/sasl

as I am guessing they should point to directories under /opt/Plone-3.0.4/Python-2.4.4 somewhere.

As I am a complete newbie a fuller description:
download python-ldap-2.3.1.tar.gz to /root
untar package: tar -zxvf *.tar.gz
cd python-ldap-2.3.1
$ export PATH=/opt/Plone-3.0.4/Python-2.4.4/bin:$PATH
python setup.py install
falls over here

any help appreciated

James L.
akvalentine
Re: Installing Python modules with Unified Installer: Deb. Etch
Reply Threaded More
Print post
Permalink

Jupiter2 wrote:
I am guessing that the problem is in the setup.cfg file with these two lines:

library_dirs = /usr/local/openldap-2.3/lib
include_dirs = /usr/local/openldap-2.3/include /usr/include/sasl
You need to install the openldap-devel and cyrus-sasl-devel.  After they are installed, set these two variables in your setup.cfg.  Note that the paths may be different depending on your distro; I'm using CentOS 5.

library_dirs = /usr/lib/evolution-openldap/lib
include_dirs = /usr/lib/evolution-openldap/include /usr/include/sasl

Then run:

python setup.py build

Then:

python setup.py install


At least this worked for me.  YMMV.
Jupiter2
Re: Installing Python modules with Unified Installer: Deb. Etch
Reply Threaded More
Print post
Permalink
Thanks for the tip, YMMV,

Since my first post I worked out that I read about the need to install the openldap development environment, but you've given the package an explicit name (which really helps), and also I hadn't been sure which sasl package to install.
It will take me a week or so to get back to this, will let you know how I get on.

Thanks for the response

Some more observations (I'm not asking for a response on these):
I can use synaptic to pull down packages easily enough, but I'm also working out how to separately install them into the python install that comes with the universal installer(UI).
I think there are at least a couple of ways to do this, using 'python build' is  one, the other is using 'buildout' (I have a copy of the M. Aspeli's book on Plone Development). I saw in a forum (somewhere) that someone made the observation that buildout seemed to be a route more guaranteed to get a result. I noticed in the Downloads page that buildout is coming to a future release of the UI.
So one thought I had was to give up on ldap for the time being and maybe try doing it later on when buildout is in the UI.
The other thing that is complicating issues is that I am using the Ebox distro as a firewall in my DMZ and I was going to use the ldap install from that so that the ldap installation is not on the same box as plone. So I have to work out where to put the ldap development files as well.
cheers
James L.

akvalentine wrote:
Jupiter2 wrote:
I am guessing that the problem is in the setup.cfg file with these two lines:

library_dirs = /usr/local/openldap-2.3/lib
include_dirs = /usr/local/openldap-2.3/include /usr/include/sasl
You need to install the openldap-devel and cyrus-sasl-devel.  After they are installed, set these two variables in your setup.cfg.  Note that the paths may be different depending on your distro; I'm using CentOS 5.

library_dirs = /usr/lib/evolution-openldap/lib
include_dirs = /usr/lib/evolution-openldap/include /usr/include/sasl

Then run:

python setup.py build

Then:

python setup.py install


At least this worked for me.  YMMV.