diff --git a/docker/tasks.py b/docker/tasks.py index b5e9a498..64447233 100644 --- a/docker/tasks.py +++ b/docker/tasks.py @@ -18,20 +18,27 @@ from invoke import task, run HERE = os.path.abspath(os.path.dirname(__file__)) +# Distros that have been promoted to Emeritus status. They can still be selected +# manually, but will be excluded by default when selecting all images. +OLD = [ 'ubuntu-14.04' ] + + + @task( aliases=['build_image', 'bi'], help={ 'image': 'Name of a docker image to build. May be specified more than once. Defaults to all.', 'gui': 'Build the gui version of an image instead of just the build image.', + 'include_old': 'Include the "OLD" distros when selecting all.' }, iterable=['image'], ) -def build_images(ctx, image, gui=False): +def build_images(ctx, image, gui=False, include_old=False): """ Build docker image(s). """ if image == []: - image = _get_all_distros(gui) + image = _get_all_distros(gui, include_old) os.chdir(HERE) dist=os.path.abspath('../dist') @@ -51,15 +58,16 @@ def build_images(ctx, image, gui=False): help={ 'image': 'Name of a docker image to test. May be specified more than once. Defaults to all.', 'gui': 'Test the gui version of an image instead of just the build image.', + 'include_old': 'Include the "OLD" distros when selecting all.' }, iterable=['image'], ) -def test_images(ctx, image, gui=False): +def test_images(ctx, image, gui=False, include_old=False): """ Build docker image(s). """ if image == []: - image = _get_all_distros(gui) + image = _get_all_distros(gui, include_old) os.chdir(HERE) dist=os.path.abspath('../dist') @@ -75,16 +83,17 @@ def test_images(ctx, image, gui=False): help={ 'image': 'Name of a docker image to push. May be specified more than once. Defaults to all.', 'gui': 'Push the gui version of an image instead of just the build image.', + 'include_old': 'Include the "OLD" distros when selecting all.' }, iterable=['image'], ) -def push(ctx, image, gui=False): +def push(ctx, image, gui=False, include_old=False): """ Push one or more images to docker hub. User should have already run a `docker login` command. """ if image == []: - image = _get_all_distros(gui) + image = _get_all_distros(gui, include_old) os.chdir(HERE) img_type = 'gui' if gui else 'build' @@ -100,11 +109,12 @@ def push(ctx, image, gui=False): help={ 'image':'Name of a docker image to use for building. May be specified more than once. Defaults to all.', 'port': 'One of "gtk2", "gtk3" or "all". Defaults to "gtk3".', - 'venv': 'The name of a Python virtual environment to use for the build, like Py27, Py36, etc. Defaults to all.' + 'venv': 'The name of a Python virtual environment to use for the build, like Py27, Py36, etc. Defaults to all.', + 'include_old': 'Include the "OLD" distros when selecting all.' }, iterable=['image'], ) -def build_wxpython(ctx, image, venv='all', port='gtk3'): +def build_wxpython(ctx, image, venv='all', port='gtk3', include_old=False): """ Use docker images to build wxPython. @@ -113,7 +123,7 @@ def build_wxpython(ctx, image, venv='all', port='gtk3'): release or snapshot build of wxPython. """ if image == []: - image = _get_all_distros() + image = _get_all_distros(False, include_old) os.chdir(HERE) dist=os.path.abspath('../dist') @@ -148,15 +158,21 @@ def run(ctx, image_tag, cmd=None, gui=False, port=5901, keep=False): pty=True, echo=True) -def _get_all_distros(gui=False): +def _get_all_distros(gui=False, include_old=False): os.chdir(HERE) wildcard = os.path.join('gui' if gui else 'build', '*-*') all_matching = sorted(glob.glob(wildcard)) - return [os.path.basename(item) for item in all_matching] + all_matching = [os.path.basename(item) for item in all_matching] + if not include_old: + all_matching = [name for name in all_matching if name not in OLD] + return all_matching @task() -def showall(ctx, gui=False): - images = _get_all_distros(gui) +def showall(ctx, gui=False, include_old=False): + """ + Just for easy testing of _get_all_distros() + """ + images = _get_all_distros(gui, include_old) for img in images: print(img)