Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preserve original PYTHONPATH in a different env-variable #1104

Closed
nebukadhezer opened this issue Dec 2, 2014 · 5 comments
Closed

Preserve original PYTHONPATH in a different env-variable #1104

nebukadhezer opened this issue Dec 2, 2014 · 5 comments
Labels

Comments

@nebukadhezer
Copy link

Hello,

I hope this wont be mistaken with #187 .
But it sort means to have a way to access the old PYTHONPATH.
Egg
when I run my binary PYTHONPATH is erased and set to "/tmp/__XXXXX" to have the binary run selve contained, which makes total sense.
Still as we are using this for an app to set environments, I sometimes would like to append sth to the PYTHONPATH that existed prior to launching the binary.
Would it be possible to save the old PYTHONPATH from the envirnment somewhere, so one can choose to reuse it afterwards ?
like stuff it into PYINSTALLER_PYTHONPATH_OLD, sure if the PYTHONPATH is emtpy this should not happen...

Or is this impossible to do by design ?

-johannes

@htgoebel
Copy link
Member

htgoebel commented Dec 2, 2014

I'm afraid if we implement such a feature, people will use it and wonder why stuff is not working as expected. (Hmm, maybe we can use some ugly variable-name like ORIG_PYTHONPATH_THIS_MAY_BREAK_PYINSTALLER_BUNDLED_EXECUTABLE ;-)

As a work-around you could use a simple script (shell or .bat) preserving the original PYTHONPATH in a different variable.

@htgoebel htgoebel changed the title PYTHONPATH is overwritten Preserve original PYTHONPATH in a different env-variable Dec 2, 2014
@nebukadhezer
Copy link
Author

Hi,
for the time being I am running the python code directly which works fine... in cases I need to append sth to PYTHONPATH.
It is up to you if you think it is a useful addition to the toolset, and I agree the name above should tip people of not to use it likely.

thanks for the fast answer and the wrapper idea.

Johannes

@htgoebel
Copy link
Member

htgoebel commented Dec 2, 2014

@matysek What do you think? I'm in favour of closing as "won't fix"

@htgoebel htgoebel added the @low label Jun 24, 2015
@htgoebel htgoebel added this to the PyInstaller 3.x milestone Jul 23, 2015
@codewarrior0
Copy link
Contributor

I just noticed something goofy: PyInstaller sets the flag Py_IgnoreEnvironmentFlag, and then tries to use the PYTHONPATH environment to influence Python's initial sys.path. So our use of PYTHONPATH is a complete no-op.

We only set PYTHONPATH before calling Py_Initialize, and only on Python 2. But for Python 2, we don't even need to set sys.path before initializing (only Python 3 cares about that because it needs the encodings module from our base_library.zip). We override sys.path using C apis after initializing anyway.

This makes the fix very trivial indeed.

@codewarrior0
Copy link
Contributor

Fixed in 968311e

PyInstaller no longer touches the PYTHONPATH environ.

@htgoebel htgoebel modified the milestones: PyInstaller 3.1, PyInstaller 3.x, PyInstaller 3.0 Sep 4, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants