Oct-03-2018, 10:09 AM
When I install a package using pip, I would like to disable the creation of __pycache__ folders and .pyc files. I tried option -B with python and --no-cache-dir with pip but this does not prevent creation of these files/folders. Is anything else required for this to work?
Output:(foo) [user@centos75 test]$ python -V
Python 3.6.3
(foo) [user@centos75 test]$ which python
/opt/test/foo/bin/python
(foo) [user@centos75 test]$ ll /opt/test/foo/bin/python
lrwxrwxrwx. 1 user user 39 Oct 3 11:45 /opt/test/foo/bin/python -> /opt/rh/rh-python36/root/usr/bin/python
(foo) [user@centos75 test]$ find foo -name *.pyc | grep idna
(foo) [user@centos75 test]$ python -I -B -m pip install idna --disable-pip-version-check --no-cache-dir
Collecting idna
Downloading https://files.pythonhosted.org/packages/4b/2a/0276479a4b3caeb8a8c1af2f8e4355746a97fab05a372e4a2c6a6b876165/idna-2.7-py2.py3-none-any.whl (58kB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 61kB 2.2MB/s
Installing collected packages: idna
Successfully installed idna-2.7
(foo) [user@centos75 test]$ find foo -name *.pyc | grep idna
foo/lib/python3.6/site-packages/idna/__pycache__/__init__.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/codec.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/compat.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/core.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/idnadata.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/intranges.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/package_data.cpython-36.pyc
foo/lib/python3.6/site-packages/idna/__pycache__/uts46data.cpython-36.pyc
(foo) [user@centos75 test]$