*.pyc files without using absolute path

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

    #1

    *.pyc files without using absolute path

    Hello,

    I have a project with a number of python modules, which means there are
    several *.py files all in the same folder /usr/local/myproject/*.py .
    I ran the program to test it and of course as a result the *.pyc files were
    created. Since everything was running fine I gave the *.pyc files (not the
    source) to a friend of mine. He put it in his home dir and executed the
    program. Then there was an error because some of the modules tried to import
    the others with absolute path "/usr/local/myproject/*.pyc) which did not
    exists on my friend's machine.
    To get more clarification I searched for the absolute path in my local *.pyc
    files (grep -a "/usr/local/myproject" *.pyc) and indeed there were a lot of
    matching lines.
    How can I make Python create *.pyc files without absolute path when all the
    modules (besides built-in like "string", "os" etc. ) are in the same dir ?

    Thanks to you !
    Alex
  • Thomas Heller

    #2
    Re: *.pyc files without using absolute path

    Alexander Hoffmann <alexander.hoff mann@netgenius. de> writes:
    [color=blue]
    > Hello,
    >
    > I have a project with a number of python modules, which means there are
    > several *.py files all in the same folder /usr/local/myproject/*.py .
    > I ran the program to test it and of course as a result the *.pyc files were
    > created. Since everything was running fine I gave the *.pyc files (not the
    > source) to a friend of mine. He put it in his home dir and executed the
    > program. Then there was an error because some of the modules tried to import
    > the others with absolute path "/usr/local/myproject/*.pyc) which did not
    > exists on my friend's machine.
    > To get more clarification I searched for the absolute path in my local *.pyc
    > files (grep -a "/usr/local/myproject" *.pyc) and indeed there were a lot of
    > matching lines.
    > How can I make Python create *.pyc files without absolute path when all the
    > modules (besides built-in like "string", "os" etc. ) are in the same dir ?[/color]

    The builtin compile function can do that.

    Thomas

    Comment

    Working...