
This isn't an issue with Homebrew but an issue for users to configure themselves. It's also nonsensical with current Python configurations e.g. https://discourse.brew.sh/t/brew-doctor-warnings-about-python-3-6-site-packages-and-sitecustomize/1805/1
Homebrew's Formula API
This is the (partially) documented public API for Homebrew.
The main class you should look at is the {Formula} class (and classes linked from there). That's the class that's used to create Homebrew formulae (i.e. package descriptions). Assume anything else you stumble upon is private.
You may also find the Formula Cookbook and Ruby Style Guide helpful in creating formulae.
Good luck!