#!/usr/bin/env python3 """ This file is used for specifying paths for 'my' package and potentially private configuration. E.g. so you can run something like: with_my python3 -c 'import my.books.kobo as kobo; print(kobo.get_todos())' Feel free to use your preferred way of managing these packages otherwise. """ ###### set this v # can be empty if you're not planning to use modules that use private configuration # otherwise see readme to learn how to set it from pathlib import Path MY_CONFIG = str(Path('~/.config/my').expanduser()) ###### # you shouldn't have the need to modify rest; but let me know if you miss anything! from pathlib import Path # directory where 'my' package is present MY_DIR = str(Path(__file__).resolve().absolute().parent) if __name__ == '__main__': import os import sys def prepend(envvar, path): if len(path) == 0: return old = os.environ.get(envvar, '') val = path + ('' if len(old) == 0 else f':{old}') os.environ[envvar] = val # todo wonder why py.typed file in mycfg didn't help? for v in ['MYPYPATH', 'PYTHONPATH']: prepend(v, MY_DIR) # the private config has higher precedence over my.config in the package (which is just a stub) prepend(v, MY_CONFIG) rest = sys.argv[1:] os.execvp(rest[0], rest)