Created
May 1, 2020 22:53
-
-
Save chrisjbillington/a40f37f9c4c830d6ec7aa446148ade71 to your computer and use it in GitHub Desktop.
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 | |
from subprocess import check_call | |
REPOS = [ | |
'blacs', | |
'labscript', | |
'labscript_devices', | |
'labscript_utils', | |
'lyse', | |
'runmanager', | |
'runviewer', | |
] | |
DEFAULT_BASE_URL = 'https://github.com/labscript-suite' | |
def clone(base_url): | |
for repo in REPOS: | |
check_call(['git', 'clone', f'{base_url}/{repo}.git', f'{repo}.git']) | |
if base_url != DEFAULT_BASE_URL: | |
check_call( | |
['git', 'remote', 'add', 'upstream', f'{DEFAULT_BASE_URL}/{repo}.git'], | |
cwd=f'{repo}.git', | |
) | |
def install(): | |
# Install without dependencies, avoids projects attempting to download each other | |
# from PyPI as dependencies: | |
for repo in REPOS: | |
check_call( | |
['pip', 'install', '-e', '.', '--no-deps'], cwd=f'{repo}.git', | |
) | |
# Then install remaining dependencies: | |
for repo in REPOS: | |
check_call( | |
['pip', 'install', '-e', '.'], cwd=f'{repo}.git', | |
) | |
def main(): | |
parser = argparse.ArgumentParser(description=R"""clone labscript suite repositories | |
and run 'pip install -e' on each. This can be used within a fresh virtual | |
environment to create a labscript suite development environment. See README.md | |
in this project for further instructions. """ ) | |
parser.add_argument( | |
'base_url', | |
nargs='?', | |
metavar='base_url', | |
default=DEFAULT_BASE_URL, | |
help=f"""Base URL of repositories to use. Set this to e.g. your own github | |
base URL to clone your own forks of the repositories. Defaults to | |
{DEFAULT_BASE_URL}""", | |
) | |
parser.add_argument( | |
'--clone', | |
action='store_false', | |
dest='install', | |
help="""Clone repositories only, don't run 'pip install -e' on them""", | |
) | |
parser.add_argument( | |
'--install', | |
action='store_false', | |
dest='clone', | |
help="""Do not clone repositories, run 'pip install -e' on existing repositories | |
only. Repositories that do not exist will be skipped. This can be useful to | |
reinstall after modifying dependencies or build-time steps such that it is | |
necessary to run setup.py again.""") | |
args = parser.parse_args() | |
if args.clone: | |
clone(args.base_url) | |
if args.install: | |
install() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment