diff options
author | noptuno <repollo.marrero@gmail.com> | 2023-04-28 02:29:30 +0200 |
---|---|---|
committer | noptuno <repollo.marrero@gmail.com> | 2023-04-28 02:29:30 +0200 |
commit | 355dee533bb34a571b9367820a63cccb668cf866 (patch) | |
tree | 838af886b4fec07320aeb10f0d1e74ba79e79b5c /venv/lib/python3.9/site-packages/streamlit/env_util.py | |
parent | added pyproject.toml file (diff) | |
download | gpt4free-355dee533bb34a571b9367820a63cccb668cf866.tar gpt4free-355dee533bb34a571b9367820a63cccb668cf866.tar.gz gpt4free-355dee533bb34a571b9367820a63cccb668cf866.tar.bz2 gpt4free-355dee533bb34a571b9367820a63cccb668cf866.tar.lz gpt4free-355dee533bb34a571b9367820a63cccb668cf866.tar.xz gpt4free-355dee533bb34a571b9367820a63cccb668cf866.tar.zst gpt4free-355dee533bb34a571b9367820a63cccb668cf866.zip |
Diffstat (limited to 'venv/lib/python3.9/site-packages/streamlit/env_util.py')
-rw-r--r-- | venv/lib/python3.9/site-packages/streamlit/env_util.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/venv/lib/python3.9/site-packages/streamlit/env_util.py b/venv/lib/python3.9/site-packages/streamlit/env_util.py new file mode 100644 index 00000000..7b78b6a4 --- /dev/null +++ b/venv/lib/python3.9/site-packages/streamlit/env_util.py @@ -0,0 +1,59 @@ +# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import platform +import re +import sys + +_system = platform.system() +IS_WINDOWS = _system == "Windows" +IS_DARWIN = _system == "Darwin" +IS_LINUX_OR_BSD = (_system == "Linux") or ("BSD" in _system) + + +def is_pex(): + """Return if streamlit running in pex. + + Pex modifies sys.path so the pex file is the first path and that's + how we determine we're running in the pex file. + """ + if re.match(r".*pex$", sys.path[0]): + return True + return False + + +def is_repl(): + """Return True if running in the Python REPL.""" + import inspect + + root_frame = inspect.stack()[-1] + filename = root_frame[1] # 1 is the filename field in this tuple. + + if filename.endswith(os.path.join("bin", "ipython")): + return True + + # <stdin> is what the basic Python REPL calls the root frame's + # filename, and <string> is what iPython sometimes calls it. + if filename in ("<stdin>", "<string>"): + return True + + return False + + +def is_executable_in_path(name): + """Check if executable is in OS path.""" + from distutils.spawn import find_executable + + return find_executable(name) is not None |