Skip to content

Instantly share code, notes, and snippets.

@tjguk
Created December 23, 2018 12:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjguk/babef6799c87b3a5e2c240ca8add9c45 to your computer and use it in GitHub Desktop.
Save tjguk/babef6799c87b3a5e2c240ca8add9c45 to your computer and use it in GitHub Desktop.
Explore https://github.com/mu-editor/mu/pull/726 in different environments
import os, sys
import site
def munged(text):
user_profile = os.environ['USERPROFILE'].lower()
return text.lower().replace(user_profile, "[user]")
with open("pr726.log", "w") as f:
f.write("CWD: %s\n" % munged(os.getcwd()))
f.write("File location: %s\n" % munged(__file__))
f.write("User Site Enabled: %s\n" % site.ENABLE_USER_SITE)
f.write("User Site Packages: %s (%s)\n" % (munged(site.getusersitepackages()), "exists" if os.path.exists(site.getusersitepackages()) else "does not exist"))
f.write("sys.flags: %s\n" % (sys.flags,))
mu_pth_filepath = os.path.join(site.getusersitepackages(), "mu.pth")
if os.path.isfile(mu_pth_filepath):
f.write("mu.pth is present at %s\n" % munged(mu_pth_filepath))
with open(mu_pth_filepath) as mu_f:
for line in mu_f:
f.write("- %s" % munged(line))
else:
f.write("mu.pth is not present at %s\n" % munged(mu_pth_filepath))
f.write("sys.path\n")
for p in sys.path:
f.write("- %s\n" % munged(p))
print(open("pr726.log").read())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment