Return the cache directory to write .pyc files for the given .py file path.
(file_path: Path)
| 1180 | |
| 1181 | |
| 1182 | def get_cache_dir(file_path: Path) -> Path: |
| 1183 | """Return the cache directory to write .pyc files for the given .py file path.""" |
| 1184 | if sys.pycache_prefix: |
| 1185 | # given: |
| 1186 | # prefix = '/tmp/pycs' |
| 1187 | # path = '/home/user/proj/test_app.py' |
| 1188 | # we want: |
| 1189 | # '/tmp/pycs/home/user/proj' |
| 1190 | return Path(sys.pycache_prefix) / Path(*file_path.parts[1:-1]) |
| 1191 | else: |
| 1192 | # classic pycache directory |
| 1193 | return file_path.parent / "__pycache__" |
no outgoing calls