Skip to content

Commit

Permalink
Add symlink to current appenv.
Browse files Browse the repository at this point in the history
This allows adding a stable path to the Python interpreter in IDEs like
VS Code.
  • Loading branch information
sweh authored and elikoga committed Feb 21, 2024
1 parent 6ab8f61 commit 5cc8cf0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/appenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ def prepare(self, args=None, remaining=None):
b"".join(hash_content)).hexdigest()[:8]
env_dir = os.path.join(self.appenv_dir, env_hash)

whitelist = set([env_dir, os.path.join(self.appenv_dir, "unclean")])
whitelist = set([
env_dir,
os.path.join(self.appenv_dir, "unclean"),
os.path.join(self.appenv_dir, 'current')])
for path in glob.glob(
"{appenv_dir}/*".format(appenv_dir=self.appenv_dir)):
if path not in whitelist:
Expand Down Expand Up @@ -369,6 +372,12 @@ def prepare(self, args=None, remaining=None):

with open(os.path.join(env_dir, "appenv.ready"), "w") as f:
f.write("Ready or not, here I come, you can't hide\n")
current_path = os.path.join(self.appenv_dir, 'current')
try:
os.unlink(current_path)
except FileNotFoundError:
pass
os.symlink(env_dir, current_path)

self.env_dir = env_dir

Expand Down

0 comments on commit 5cc8cf0

Please sign in to comment.