Re: [Paraview] Python shell, os.environ
On Thu, Dec 21, 2017 at 15:14:01 +, Heiland, Randy wrote: > Thanks Ben. You’re right, of course. Moreover, my idea for having > (non-admin) users install additional Python modules (e.g., scipy) into > PV’s dir, is a not going to go well. Well, if `sys.path` or `PYTHONPATH` can be pointed to it, it *should* work (though the `numpy` in the package may not be configured properly for `scipy`). > Do we at least agree that if I ask users to start PV from the > Terminal, PV’s Python will then pick up the user’s env vars? It should, but ParaView doesn't do anything to stop it. If it doesn't work, it's probably some Apple framework thing that needs to be told not to do silly things. --Ben ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://paraview.org/mailman/listinfo/paraview
Re: [Paraview] Python shell, os.environ
> On Dec 21, 2017, at 9:34 AM, Ben Boeckelwrote: > > On Wed, Dec 20, 2017 at 22:50:50 +, Heiland, Randy wrote: >> Ah, I see ‘os’ has been hijacked by PV. But something like this seems >> to accomplish what I want, maybe… >> >> Create a new module for PV: >> >> /Applications/ParaView-5.4.1.app/Contents/Python$ more envs.py >> import os >> os.environ['PHYSICELL_DATA']=‘/fill_in_path’ >> >> and then in the PV Python shell, the os.environ will indeed contain >> this new env var. > > This can't be part of the package though since if it is installed > globally, users may not have write access to the .app directory. > > It seems the way to do this is along these lines (in short, Apple isn't > making what you want to do easy): > > > https://superuser.com/questions/476752/setting-environment-variables-in-os-x-for-gui-applications#541068 > > https://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/32405815#32405815 > > There seems to have been something like `~/.launchd.conf` at some point > and `~/.MacOSX/environment.plist` before that, but those has been > deprecated and no longer work. > > —Ben Thanks Ben. You’re right, of course. Moreover, my idea for having (non-admin) users install additional Python modules (e.g., scipy) into PV’s dir, is a not going to go well. Do we at least agree that if I ask users to start PV from the Terminal, PV’s Python will then pick up the user’s env vars? -Randy (who’s really liking: “Step 1: Become an Admin” :) ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://paraview.org/mailman/listinfo/paraview
Re: [Paraview] Python shell, os.environ
On Wed, Dec 20, 2017 at 22:50:50 +, Heiland, Randy wrote: > Ah, I see ‘os’ has been hijacked by PV. But something like this seems > to accomplish what I want, maybe… > > Create a new module for PV: > > /Applications/ParaView-5.4.1.app/Contents/Python$ more envs.py > import os > os.environ['PHYSICELL_DATA']=‘/fill_in_path’ > > and then in the PV Python shell, the os.environ will indeed contain > this new env var. This can't be part of the package though since if it is installed globally, users may not have write access to the .app directory. It seems the way to do this is along these lines (in short, Apple isn't making what you want to do easy): https://superuser.com/questions/476752/setting-environment-variables-in-os-x-for-gui-applications#541068 https://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x/32405815#32405815 There seems to have been something like `~/.launchd.conf` at some point and `~/.MacOSX/environment.plist` before that, but those has been deprecated and no longer work. --Ben ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://paraview.org/mailman/listinfo/paraview
Re: [Paraview] Python shell, os.environ
Thanks Utkarsh. Yes, running pvpython from a Terminal is indeed different from running the Python Shell in the PV app (on OS X anyway), in terms of os.environ. Regardless, hopefully my proposed approach of creating an envs.py module in the PV installation will work. I’m just looking for the simplest solution for our users. -Randy > On Dec 20, 2017, at 9:16 PM, Utkarsh Ayachit> wrote: > > Randy, > > No, `os` hasn't been hijacked by PV. Here's what I get on Linux. > > ./bin/pvpython > Python 3.5.2 (default, Nov 23 2017, 16:37:01) > [GCC 5.4.0 20160609] on linux > Type "help", "copyright", "credits" or "license" for more information. import os os.environ["FOO"] > '12' > > > I suspect it's something to do with App bundles on macOS and what > environment variables they see based on how you launch them. I can't > remember that of the top of my head, but that's where I'd start > looking. > > Utkarsh > > > On Wed, Dec 20, 2017 at 5:50 PM, Heiland, Randy wrote: >> Ah, I see ‘os’ has been hijacked by PV. But something like this seems to >> accomplish what I want, maybe… >> >> Create a new module for PV: >> >> /Applications/ParaView-5.4.1.app/Contents/Python$ more envs.py >> import os >> os.environ['PHYSICELL_DATA']=‘/fill_in_path’ >> >> and then in the PV Python shell, the os.environ will indeed contain this new >> env var. >> >> >>> On Dec 20, 2017, at 4:30 PM, Heiland, Randy wrote: >>> >>> I noticed the Python shell has a very limited os.environ, e.g.: >> os.environ >>> {'SHELL': '/bin/bash', 'SSH_AUTH_SOCK': >>> '/private/tmp/com.apple.launchd.y86uYmHWFV/Listeners', 'XPC_FLAGS': '0x0', >>> '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', 'Apple_PubSub_Socket_Render': >>> '/private/tmp/com.apple.launchd.CM4C6EMoE6/Render', 'LOGNAME': 'heiland', >>> 'USER': 'heiland', 'XPC_SERVICE_NAME': 'org.paraview.ParaView.6', >>> 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'HOME': '/Users/heiland', >>> 'DISPLAY': >>> '/private/tmp/com.apple.launchd.4ORv1l0yeN/org.macosforge.xquartz:0', >>> 'TMPDIR': '/var/folders/l6/s467rzgs75n91gdbkn7vr0f4gn/T/'} >> >>> >>> I’m guessing this is a security measure? Anyway, is there any way one can >>> use an env var to pass in desirable info to PV’s Python, e.g., a dir path >>> to data to be read by a Programmable Source? Or perhaps there’s some other >>> entirely different way to do this? >>> >>> thanks, Randy >>> ___ >>> Powered by www.kitware.com >>> >>> Visit other Kitware open-source projects at >>> http://www.kitware.com/opensource/opensource.html >>> >>> Please keep messages on-topic and check the ParaView Wiki at: >>> http://paraview.org/Wiki/ParaView >>> >>> Search the list archives at: http://markmail.org/search/?q=ParaView >>> >>> Follow this link to subscribe/unsubscribe: >>> https://paraview.org/mailman/listinfo/paraview >> >> ___ >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Please keep messages on-topic and check the ParaView Wiki at: >> http://paraview.org/Wiki/ParaView >> >> Search the list archives at: http://markmail.org/search/?q=ParaView >> >> Follow this link to subscribe/unsubscribe: >> https://paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://paraview.org/mailman/listinfo/paraview
Re: [Paraview] Python shell, os.environ
Randy, No, `os` hasn't been hijacked by PV. Here's what I get on Linux. ./bin/pvpython Python 3.5.2 (default, Nov 23 2017, 16:37:01) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.environ["FOO"] '12' I suspect it's something to do with App bundles on macOS and what environment variables they see based on how you launch them. I can't remember that of the top of my head, but that's where I'd start looking. Utkarsh On Wed, Dec 20, 2017 at 5:50 PM, Heiland, Randywrote: > Ah, I see ‘os’ has been hijacked by PV. But something like this seems to > accomplish what I want, maybe… > > Create a new module for PV: > > /Applications/ParaView-5.4.1.app/Contents/Python$ more envs.py > import os > os.environ['PHYSICELL_DATA']=‘/fill_in_path’ > > and then in the PV Python shell, the os.environ will indeed contain this new > env var. > > >> On Dec 20, 2017, at 4:30 PM, Heiland, Randy wrote: >> >> I noticed the Python shell has a very limited os.environ, e.g.: > os.environ >> {'SHELL': '/bin/bash', 'SSH_AUTH_SOCK': >> '/private/tmp/com.apple.launchd.y86uYmHWFV/Listeners', 'XPC_FLAGS': '0x0', >> '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', 'Apple_PubSub_Socket_Render': >> '/private/tmp/com.apple.launchd.CM4C6EMoE6/Render', 'LOGNAME': 'heiland', >> 'USER': 'heiland', 'XPC_SERVICE_NAME': 'org.paraview.ParaView.6', >> 'PATH': '/usr/bin:/bin:/usr/sbin:/sbin', 'HOME': '/Users/heiland', >> 'DISPLAY': >> '/private/tmp/com.apple.launchd.4ORv1l0yeN/org.macosforge.xquartz:0', >> 'TMPDIR': '/var/folders/l6/s467rzgs75n91gdbkn7vr0f4gn/T/'} > >> >> I’m guessing this is a security measure? Anyway, is there any way one can >> use an env var to pass in desirable info to PV’s Python, e.g., a dir path to >> data to be read by a Programmable Source? Or perhaps there’s some other >> entirely different way to do this? >> >> thanks, Randy >> ___ >> Powered by www.kitware.com >> >> Visit other Kitware open-source projects at >> http://www.kitware.com/opensource/opensource.html >> >> Please keep messages on-topic and check the ParaView Wiki at: >> http://paraview.org/Wiki/ParaView >> >> Search the list archives at: http://markmail.org/search/?q=ParaView >> >> Follow this link to subscribe/unsubscribe: >> https://paraview.org/mailman/listinfo/paraview > > ___ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Search the list archives at: http://markmail.org/search/?q=ParaView > > Follow this link to subscribe/unsubscribe: > https://paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://paraview.org/mailman/listinfo/paraview
Re: [Paraview] Python shell, os.environ
Ah, I see ‘os’ has been hijacked by PV. But something like this seems to accomplish what I want, maybe… Create a new module for PV: /Applications/ParaView-5.4.1.app/Contents/Python$ more envs.py import os os.environ['PHYSICELL_DATA']=‘/fill_in_path’ and then in the PV Python shell, the os.environ will indeed contain this new env var. > On Dec 20, 2017, at 4:30 PM, Heiland, Randywrote: > > I noticed the Python shell has a very limited os.environ, e.g.: os.environ > {'SHELL': '/bin/bash', 'SSH_AUTH_SOCK': > '/private/tmp/com.apple.launchd.y86uYmHWFV/Listeners', 'XPC_FLAGS': '0x0', > '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', 'Apple_PubSub_Socket_Render': > '/private/tmp/com.apple.launchd.CM4C6EMoE6/Render', 'LOGNAME': 'heiland', > 'USER': 'heiland', 'XPC_SERVICE_NAME': 'org.paraview.ParaView.6', 'PATH': > '/usr/bin:/bin:/usr/sbin:/sbin', 'HOME': '/Users/heiland', 'DISPLAY': > '/private/tmp/com.apple.launchd.4ORv1l0yeN/org.macosforge.xquartz:0', > 'TMPDIR': '/var/folders/l6/s467rzgs75n91gdbkn7vr0f4gn/T/'} > > I’m guessing this is a security measure? Anyway, is there any way one can use > an env var to pass in desirable info to PV’s Python, e.g., a dir path to data > to be read by a Programmable Source? Or perhaps there’s some other entirely > different way to do this? > > thanks, Randy > ___ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Search the list archives at: http://markmail.org/search/?q=ParaView > > Follow this link to subscribe/unsubscribe: > https://paraview.org/mailman/listinfo/paraview ___ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: https://paraview.org/mailman/listinfo/paraview