mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/python_virtualenv_detection' into 'master'
python: Add check if current python is inside virtual environment See merge request idf/esp-idf!4088
This commit is contained in:
commit
65d01336d3
@ -14,9 +14,10 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import argparse
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import argparse
|
|
||||||
try:
|
try:
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -34,6 +35,13 @@ def escape_backslash(path):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def is_virtualenv():
|
||||||
|
"""Detects if current python is inside virtualenv, pyvenv (python 3.4-3.5) or venv"""
|
||||||
|
|
||||||
|
return (hasattr(sys, 'real_prefix') or
|
||||||
|
(hasattr(sys, 'base_prefix') and sys.base_prefix != sys.prefix))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
idf_path = os.getenv("IDF_PATH")
|
idf_path = os.getenv("IDF_PATH")
|
||||||
|
|
||||||
@ -79,8 +87,10 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
print('Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required'
|
print('Please refer to the Get Started section of the ESP-IDF Programming Guide for setting up the required'
|
||||||
' packages.')
|
' packages.')
|
||||||
print('Alternatively, you can run "{} -m pip install --user -r {}" for resolving the issue.'
|
print('Alternatively, you can run "{} -m pip install {}-r {}" for resolving the issue.'
|
||||||
''.format(escape_backslash(sys.executable), escape_backslash(args.requirements)))
|
''.format(escape_backslash(sys.executable),
|
||||||
|
'' if is_virtualenv() else '--user ',
|
||||||
|
escape_backslash(args.requirements)))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
print('Python requirements from {} are satisfied.'.format(args.requirements))
|
print('Python requirements from {} are satisfied.'.format(args.requirements))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user