def task_lab(): """start a jupyter lab server (with all other extensions)""" env = "test" lockfile = P.get_lockfile(env) str_lock = str(lockfile) needs_build = "lab1" in str_lock or "lab2" in str_lock frozen = P.PIP_LISTS[env] run_in = P.RUN_IN[env] pym = [*run_in, *P.PYM] app_dir = [] if needs_build and not P.IN_BINDER: app_dir = ["--app-dir", P.APP_DIR] lab = [*pym, "jupyter", "lab"] lab_ext = [*pym, "jupyter", "labextension"] serve_deps = [frozen] if needs_build: yield dict( name="ext", uptodate=[config_changed({"labextensions": P.LAB_EXTENSIONS})], actions=[ [ *lab_ext, "install", *app_dir, *P.LAB_EXTENSIONS, "--no-build" ], [*lab, "build", *app_dir, "--debug"], ], file_dep=[frozen], targets=[P.APP_INDEX], ) serve_deps += [P.APP_INDEX] def _lab(): p = subprocess.Popen([*lab, *app_dir, "--no-browser", "--debug"], stdin=subprocess.PIPE) try: p.wait() except KeyboardInterrupt: p.terminate() p.communicate(b"y\n") p.terminate() finally: p.wait() print("maybe check your process log") yield dict( name="serve", doc="runs lab (never stops)", uptodate=[lambda: False], actions=[PythonInteractiveAction(_lab)], file_dep=serve_deps, )
def task_lab(): """start JupyterLab, no funny stuff (Note: Single Ctrl+C stops)""" yield dict( name="serve", uptodate=[lambda: False], file_dep=[P.OK / "setup_lab"], actions=[PythonInteractiveAction(_make_lab())], )
def task_bump_version(): def bump(): if git("branch", "--show-current") != "master": sys.exit("You must be on the branch master to do that") git("fetch", "origin", "master") if git("rev-parse", "@{u}") != git("merge-base", "@", "@{u}"): sys.exit("Cannot push a new version, you need to pull first") git_status = git("status", "--porcelain=1").split("\n") if not all( line.startswith(" ") for line in git_status if not line.startswith("?")): sys.exit( "Cannot commit the new version: you have changes to be commited." ) print("Current version is:", ZEROBIN_VERSION) action = "0" while action not in "123": print("What kind of version is it?\n") print("1) Major") print("2) Minor") print("3) Fix") action = input("Enter 1, 2 or 3 (Ctrl + C to quit): ") new_version = list(map(int, ZEROBIN_VERSION.split("."))) action = int(action) - 1 new_version[action] += 1 new_version = ".".join(map(str, new_version)) print("The new version will be:", new_version) if input("Ok? [y/N] ").strip().lower() != "y": sys.exit("The version has NOT been bumped") print("- Updating VERSION file") (SOURCE_DIR / "VERSION").write_text(new_version) print("- Commiting VERSION file") git("add", "zerobin/VERSION") git( "commit", "-m", f"Bumping to version {new_version}", ) print(f"- Adding v{new_version} tag") git("tag", f"v{new_version}") print("- Pushing tag") git("push", "origin", "master", "--tag") return { "actions": [ PythonInteractiveAction(bump), ], }
def gen_task_new_page(cls, post_pages): """Create a new post (interactive).""" yield { "basename": "new_page", "actions": [PythonInteractiveAction(cls.new_post, ( post_pages, False, ))], }
def task_watch(): """watch typescript sources, launch JupyterLab, rebuilding as files change""" yield dict( name="lab", uptodate=[lambda: False], file_dep=[P.OK / "setup_lab"], actions=[PythonInteractiveAction(_make_lab(watch=True))], ) def _docs(): p = None try: p = subprocess.Popen([ "sphinx-autobuild", "-a", "-j8", "--re-ignore", r"'*\.ipynb_checkpoints*'", P.DOCS, P.DOCS_OUT, ]) p.wait() finally: p.terminate() p.wait() if shutil.which("sphinx-autobuild"): yield dict( name="docs", doc= "serve docs, watch (some) sources, livereload (when it can)", uptodate=[lambda: False], file_dep=[P.DOCS_BUILDINFO], actions=[PythonInteractiveAction(_docs)], )
def task_release_test_pypi(): def confirm(): res = input('running release on test pypy!\n' '[yes/NO] ') if res != 'yes': raise Exception return { 'task_dep': ['build'], 'actions': [(PythonInteractiveAction(confirm)), 'twine upload --verbose --disable-progress-bar --repository testpypi dist/*' ], 'verbosity': 2, }
def task_watch(): """watch typescript sources, launch lab, rebuilding as files change""" def _watch(): proc = subprocess.Popen(list(map(str, [*P.APR_DEFAULT, "watch"])), stdin=subprocess.PIPE) try: proc.wait() except KeyboardInterrupt: pass proc.wait() return True return dict( uptodate=[lambda: False], file_dep=[P.OK_PREFLIGHT_LAB], actions=[PythonInteractiveAction(_watch)], )
def task_release_pypi(): def confirm(): res = input( 'running release on NON-test pypy!\n' 'remember to install from a build to test if everytihng is included!\n' 'is the version bumped and everything commited and pushed?\n' 'everything tested?\n' '[yesanditsnotatest/OHMYGODNO] ') if res != 'yesanditsnotatest': raise Exception return { 'task_dep': ['build'], 'actions': [(PythonInteractiveAction(confirm)), 'twine upload --verbose --disable-progress-bar --repository pypi dist/*' ], 'verbosity': 2 }
def task_lab(): """run JupyterLab "normally" (not watching sources)""" def lab(): proc = subprocess.Popen(list(map(str, [*P.APR_DEV, "lab"])), stdin=subprocess.PIPE) try: proc.wait() except KeyboardInterrupt: print( "attempting to stop lab, you may want to check your process monitor" ) proc.terminate() proc.communicate(b"y\n") proc.wait() return True return dict( uptodate=[lambda: False], file_dep=[P.LAB_INDEX, P.OK_PIP_INSTALL, P.OK_PREFLIGHT_LAB], actions=[PythonInteractiveAction(lab)], )