def embed_version(basepath, ref='<STR_LIT>'):
import io, zipfile, importlib<EOL>try:    from urllib.request import urlopen<EOL>except: from urllib import urlopen<EOL>try:<EOL><INDENT>url = '<STR_LIT>'<EOL>response = urlopen(url.format(ref=ref))<EOL>zf = zipfile.ZipFile(io.BytesIO(response.read()))<EOL>ref = ref[<NUM_LIT:1>:] if ref.startswith('<STR_LIT:v>') else ref<EOL>embed_version = zf.read('<STR_LIT>'.format(ref=ref))<EOL>with open(os.path.join(basepath, '<STR_LIT>'), '<STR_LIT:wb>') as f:<EOL><INDENT>f.write(embed_version)<EOL><DEDENT>return importlib.import_module("<STR_LIT:version>")<EOL><DEDENT>except:<EOL><INDENT>return None<EOL><DEDENT>
Autover is purely a build time dependency in all cases (conda and
pip) except for when you use pip's remote git support [git+url] as
1) you need a dynamically changing version and 2) the environment
starts off clean with zero dependencies installed.
This function acts as a fallback to make Version available until
PEP518 is commonly supported by pip to express build dependencies.