def download_version(version='current', dest_dir=None): """Download specific expyfun version Parameters ---------- version : str Version to check out (7-character git commit number). Can also be ``'current'`` (default) to download whatever the latest ``upstream/master`` version is. dest_dir : str | None Destination directory. If None, the current working directory is used. Notes ----- This function requires installation of ``gitpython``. """ _check_git() _check_version_format(version) if dest_dir is None: dest_dir = os.getcwd() if not isinstance(dest_dir, string_types) or not op.isdir(dest_dir): raise IOError('Destination directory {0} does not exist' ''.format(dest_dir)) if op.isdir(op.join(dest_dir, 'expyfun')): raise IOError('Destination directory {0} already has "expyfun" ' 'subdirectory'.format(dest_dir)) # fetch locally and get the proper version tempdir = _TempDir() expyfun_dir = op.join(tempdir, 'expyfun') # git will auto-create this dir repo_url = 'git://github.com/LABSN/expyfun.git' run_subprocess(['git', 'clone', repo_url, expyfun_dir]) version = _active_version(expyfun_dir) if version == 'current' else version try: run_subprocess(['git', 'checkout', version], cwd=expyfun_dir) except Exception as exp: raise RuntimeError('Could not check out version {0}: {1}' ''.format(version, str(exp))) assert _active_version(expyfun_dir) == version # install orig_dir = os.getcwd() os.chdir(expyfun_dir) sys.path.insert(0, expyfun_dir) # ensure our new "setup" is imported orig_stdout = sys.stdout try: from setup import git_version, setup_package assert git_version().lower() == version[:7].lower() sys.stdout = StringIO() with warnings.catch_warnings(record=True): # PEP440 setup_package(script_args=['build', '--build-purelib', dest_dir]) finally: sys.stdout = orig_stdout sys.path.pop(sys.path.index(expyfun_dir)) os.chdir(orig_dir) print('Successfully checked out expyfun version:\n\n%s\n\ninto ' 'destination directory:\n\n%s\n' % (version, op.join(dest_dir)))
def download_version(version, dest_dir=None): """Download specific expyfun version Parameters ---------- version : str Version to check out (7-character git commit number). dest_dir : str | None Destination directory. If None, the current working directory is used. Notes ----- This function requires installation of ``gitpython``. """ _check_git() _check_version_format(version) if dest_dir is None: dest_dir = os.getcwd() if not isinstance(dest_dir, string_types) or not op.isdir(dest_dir): raise IOError('Destination directory {0} does not exist' ''.format(dest_dir)) if op.isdir(op.join(dest_dir, 'expyfun')): raise IOError('Destination directory {0} already has "expyfun" ' 'subdirectory'.format(dest_dir)) # fetch locally and get the proper version tempdir = _TempDir() expyfun_dir = op.join(tempdir, 'expyfun') # git will auto-create this dir repo_url = 'git://github.com/LABSN/expyfun.git' run_subprocess(['git', 'clone', repo_url, expyfun_dir]) try: run_subprocess(['git', 'checkout', version], cwd=expyfun_dir) except Exception as exp: raise RuntimeError('Could not check out version {0}: {1}' ''.format(version, str(exp))) # install orig_dir = os.getcwd() os.chdir(expyfun_dir) sys.path.insert(0, expyfun_dir) # ensure our new "setup" is imported try: from setup import git_version, setup_package assert git_version().lower() == version[:7].lower() setup_package(script_args=['build', '--build-purelib', dest_dir]) finally: sys.path.pop(sys.path.index(expyfun_dir)) os.chdir(orig_dir)
def main(): args = __parse_params_to_settings() if args.version: # This gets handled by setup.py, we just need to not run the main routine print(setup.git_version()) exit(0) __update_settings_from_args(args) proceed = __query_yes_no("Start tagcompare against {} for cid={}, pids={}?" .format(settings.DEFAULT.domain, settings.DEFAULT.campaigns, settings.DEFAULT.publishers)) if not proceed: print("Stopping tagcompare on user input") exit(0) jobname = capture.main() if not args.capture_only: compare.main(build=jobname)
from setup import codeopts, git_version, setup if __name__ == '__main__': __version__ = git_version() codeopts['version'] = __version__ setup(**codeopts)