Python at compile - possible to add to PYTHONPATH

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rh0dium

    Python at compile - possible to add to PYTHONPATH

    Hi all,

    Can anyone help me out. I would like to have python automatically look
    in a path for modules similar to editing the PYTHONPATH but do it at
    compile time so every user doesn't have to do this..

    Soo...

    I want to add /foo/bar to the PYTHONPATH build so I don't have to add
    it later on. Is there a way to do this?

    ../configure ??

    ../configure --help doesn't help..


    Thanks

  • Serge Orlov

    #2
    Re: Python at compile - possible to add to PYTHONPATH

    On 21 Jun 2006 15:54:56 -0700, rh0dium <steven.klass@g mail.com> wrote:[color=blue]
    > Hi all,
    >
    > Can anyone help me out. I would like to have python automatically look
    > in a path for modules similar to editing the PYTHONPATH but do it at
    > compile time so every user doesn't have to do this..
    >
    > Soo...
    >
    > I want to add /foo/bar to the PYTHONPATH build so I don't have to add
    > it later on. Is there a way to do this?[/color]

    You don't need to recompile python. Just change sys.path before all
    import statements.

    Comment

    • Avell Diroll

      #3
      Re: Python at compile - possible to add to PYTHONPATH

      rh0dium wrote:
      (snip)[color=blue]
      > I want to add /foo/bar to the PYTHONPATH build so I don't have to add
      > it later on. Is there a way to do this?[/color]
      (snip)

      If i understand correctly, you want to add a directory to your
      PYTHONPATH for a specific script without modifying the system PYTHONPATH
      global variable ...

      To import the Gazonk() class defined in /foo/bar/baz.py without adding
      /foo/bar to PYTHONPATH you can try this:

      ###

      import sys
      sys.path.append ('/foo/bar')

      import baz
      quux = baz.Gazonk()

      ###

      hope it helped ...

      Comment

      • rh0dium

        #4
        Re: Python at compile - possible to add to PYTHONPATH

        Hi all,

        Thanks for the response. Yeah that's what I'm currently doing but I
        thought that it would be cleaner for me to append my own location at
        compile time. I'm surprised that this doesn't exist..

        Thanks.



        Avell Diroll wrote:[color=blue]
        > rh0dium wrote:
        > (snip)[color=green]
        > > I want to add /foo/bar to the PYTHONPATH build so I don't have to add
        > > it later on. Is there a way to do this?[/color]
        > (snip)
        >
        > If i understand correctly, you want to add a directory to your
        > PYTHONPATH for a specific script without modifying the system PYTHONPATH
        > global variable ...
        >
        > To import the Gazonk() class defined in /foo/bar/baz.py without adding
        > /foo/bar to PYTHONPATH you can try this:
        >
        > ###
        >
        > import sys
        > sys.path.append ('/foo/bar')
        >
        > import baz
        > quux = baz.Gazonk()
        >
        > ###
        >
        > hope it helped ...[/color]

        Comment

        Working...