CPython 3.x and PyPy follow PEP 3147 and store pyc-files in __pycache__
directories with a Python version suffix attached to them. How can I force CPython 2.7 to store its pyc-files in __pycache__
directories as well (opposed to its default behavior of storing pyc-files without suffix right next to the corresponding py-files in the same directory)?
I realize that I should probably not do this system-wide because a lot of other software expects CPython 2.x's default behavior. So what I am looking for is a way to do this per project or per virtual environment or, if there is no other solution, per custom compiled and custom installed (e.g. in ~/bin
) CPython interpreter.
Some research: Relevant discussion on Debian mailing list; code review for PEP 3147 implementation in CPython 3.2.