Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Discuss] Python script question

On 08/03/2011 06:31 PM, Shankar Viswanathan wrote:
> On Wed, Aug 3, 2011 at 10:28 AM, Jerry Feldman <gaf at> wrote:
>> A coworker of mine has a Python script set up as:
>> #! $PATH_TO_PYTHON/python
>> ... python code
>> It is not unusual to have commands like this. Mailman does this with
>> several of its commands. The issue here is that he needs to use an
>> environment variable to call the python interpreter. We certainly can do
>> it a messy way:
>> #! /bin/bash
>> $PATH_TO_PYTHON/python
>> But this would require a wrapper script.
>> Or he can use an explicit path to the python interpreter.
>> #! /usr/bin/python
>> The problem here is that the version of python he uses MUST be
>> encapsulated in our company's product.
>> #! /mnt/fubar/versionxyz/bin/python
>> But this will possibly differ with each release of our company's product
>> since we maintain a number of releases here.  Some other solutions is to
>> set up symlinks in the local directory.
>> Any ideas on how to get the loader to expand the environment variable
>> after the #!??
> At work, we use the 'modules' system to solve this problem:
> We put the list of modules and versions needed for a project in a
> .bashrc file that we customize for each project/customer. You just
> have to load the specific .bashrc file for your project, which can
> also contain other environment variables in addition to the modules.
> The python script can then simply have:
> #!/usr/bin/env python
> <python code>
> This has proved very flexible and versatile system for us when dealing
> with multiple tools, both internal and those from external vendors.
> You just have to spend some time initially creating the modulefile for
> each tool.
> Hope this helps,
> Shankar
Here at work, we encapsulate all products so the product does not depend
on anything installed on the system (other than things like the kernel
and libc. Compilers, languages like Perl and Python, libraries, such as
cplex, et. al. I've probably got about 6 different copies of Python 2.6.
I have no control of this since this is done in Toronto.

Jerry Feldman <gaf at>
Boston Linux and Unix
PGP key id: 537C5846
PGP Key fingerprint: 3D1B 8377 A3C0 A5F2 ECBB  CA3B 4607 4319 537C 5846

BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!

Boston Linux & Unix /