Created
August 16, 2018 19:02
-
-
Save nackjicholson/db83869b7931b0bc95fa9e0960921f1c to your computer and use it in GitHub Desktop.
A script for loading the activate_this.py into a non `virtualenv` virtual env like `poetry` or `python -m venv`.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import base64 | |
import os | |
import zlib | |
from pathlib import Path | |
def convert(s): | |
b = base64.b64decode(s.encode('ascii')) | |
return zlib.decompress(b).decode('utf-8') | |
ACTIVATE_THIS = convert(""" | |
eJyNU01v2zAMvetXEB4K21jnDOstQA4dMGCHbeihlyEIDMWmE62yJEiKE//7kXKdpEWLzYBt8evx | |
kRSzLPs6wiEoswM8YdMpjUXcq1Dz6RZa1cSiTkJdr86GsoTRHuCotBayiWqQEYGtMCgfD1KjGYBe | |
5a3p0cRKiEe2NtLAFikftnDco0ko/SFEVgEZ8aRCZDIPY9xbA8pE9M4jfW/B2CjiHq9zbJVZuOQq | |
siwTIvpxKYCembPAU4Muwi/Z4zfvrZ/MXipKeB8C+qisSZYiWfjJfs+0/MFMdWn1hJcO5U7G/SLa | |
xVx8zU6VG/PXLXvfsyyzUqjeWR8hjGE+2iCE1W1tQ82hsCJN9dzKaoexyB/uH79TnjwvxcW0ntSb | |
yZ8jq1Z5Q1UXsyy3gf9nbjTEj7NzQMfCJa/YSmrQ+2D/BqfiOi6sclrGzvoeVivIj8rcfcmnIQRF | |
7XCyeZI7DFe5/lhlCs5PRf5QW66VXT/NrlQ46oD/D6InkOmi3IQcbhKxAX2g4a+Xd5s3UtCtG2py | |
m8eg6WYWqR6SL5OjKMGfSrYt/6kxxQtOpeAgj1LXBNmpE2ElmCSIy5H0zFd8gJ924HWijWhb2hRC | |
6wNEm1QdDZtuSZcEprIUBo/XRNcbQe1OUbQ/r3hPTaPJJDNtFLu8KHV5XoNr3Eo6h6YtOKw8e8yw | |
VF5PnJ+ts3a9/Mz38RpG/AUSzYUW | |
""") | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--virtualenv-dir', default=os.environ['VIRTUAL_ENV']) | |
args = parser.parse_args() | |
activate_this_path = Path(args.virtualenv_dir) / 'bin/activate_this.py' | |
print(f'Writing activate_this.py to {activate_this_path}') | |
with open(activate_this_path, 'w') as fp: | |
fp.write(ACTIVATE_THIS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
poetry run python venv_activate_this.py
Now you can use vim with python and make it understand how to actiavate the correct virtualenvironment for things like ALE and YCM.
https://github.com/pypa/virtualenv/blob/master/virtualenv.py ACTIVATE_THIS variable