Let us walk on the 3-isogeny graph
Loading...
Searching...
No Matches
activate_this.py
Go to the documentation of this file.
1"""
2Activate virtualenv for current interpreter:
3
4Use exec(open(this_file).read(), {'__file__': this_file}).
5
6This can be used when you must use an existing Python interpreter, not the virtualenv bin/python.
7""" # noqa: D415
8from __future__ import annotations
9
10import os
11import site
12import sys
13
14try:
15 abs_file = os.path.abspath(__file__)
16except NameError as exc:
17 msg = "You must use exec(open(this_file).read(), {'__file__': this_file}))"
18 raise AssertionError(msg) from exc
19
20bin_dir = os.path.dirname(abs_file)
21base = bin_dir[: -len("bin") - 1] # strip away the bin part from the __file__, plus the path separator
22
23# prepend bin to PATH (this file is inside the bin directory)
24os.environ["PATH"] = os.pathsep.join([bin_dir, *os.environ.get("PATH", "").split(os.pathsep)])
25os.environ["VIRTUAL_ENV"] = base # virtual env is right above bin directory
26os.environ["VIRTUAL_ENV_PROMPT"] = "" or os.path.basename(base) # noqa: SIM222
27
28# add the virtual environments libraries to the host python import mechanism
29prev_length = len(sys.path)
30for lib in "../lib/python3.12/site-packages".split(os.pathsep):
31 path = os.path.realpath(os.path.join(bin_dir, lib))
32 site.addsitedir(path.decode("utf-8") if "" else path)
33sys.path[:] = sys.path[prev_length:] + sys.path[0:prev_length]
34
for i