From 10f49e53af7992ff8901fc3ba60ef53fc676df45 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 21 Mar 2026 12:27:51 -0400 Subject: Add support for Python 3.6, 3.7, and 3.8 on CI --- .builds/lint-and-test.yml | 8 ++- .gitignore | 1 + pyproject.toml | 3 +- scripts/test.sh | 66 ++++++++++++++++++++-- .../count.sh | 3 +- .../pyproject.toml | 2 +- uv.lock | 54 ++++++++++++------ 7 files changed, 113 insertions(+), 24 deletions(-) diff --git a/.builds/lint-and-test.yml b/.builds/lint-and-test.yml index b91efb7..e3ab99f 100644 --- a/.builds/lint-and-test.yml +++ b/.builds/lint-and-test.yml @@ -1,4 +1,4 @@ -image: alpine/3.23 +image: archlinux submitter: git.sr.ht: enabled: true @@ -10,15 +10,21 @@ triggers: condition: failure to: builds@eugenetriguba.com packages: + - docker - uv sources: - https://git.sr.ht/~eugenetriguba/taskipy2 tasks: + - setup: | + sudo dockerd > /tmp/dockerd.log 2>&1 & - lint: | cd taskipy2 ./scripts/lint.sh - test: | cd taskipy2 + ./scripts/test.sh --python-version 3.6 + ./scripts/test.sh --python-version 3.7 + ./scripts/test.sh --python-version 3.8 ./scripts/test.sh --python-version 3.9 ./scripts/test.sh --python-version 3.10 ./scripts/test.sh --python-version 3.11 diff --git a/.gitignore b/.gitignore index 7dd72d3..32aedf8 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,4 @@ MANIFEST .python-version .DS_Store .venv +requirements.txt diff --git a/pyproject.toml b/pyproject.toml index 908f685..d6ae6cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,7 +31,8 @@ dependencies = [ "tomli>=1.2.3; python_version == '3.6'", "psutil>=5.7.2", "mslex>=1.1.0; sys_platform == 'win32'", - "colorama>=0.4.4", + "colorama>=0.4.4,<0.4.6; python_version == '3.6'", + "colorama>=0.4.6; python_version >= '3.7'", ] packages = [{ include = "taskipy" }] diff --git a/scripts/test.sh b/scripts/test.sh index d980a1a..08a8ab8 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -4,6 +4,35 @@ set -e PYTHON_VERSION="3.14" main() { + parse_args "$@" + + # NOTE: Python versions <= 3.8 do not have pre-built binary support with uv. + # Therefore, instead, we're using docker to download a pre-built image with + # an older version of Python installed. + if echo "3.6" | grep -qw "$PYTHON_VERSION"; then + export_requirements_txt_file_for_py36 + run_in_docker "$PYTHON_VERSION" " + pip install -r requirements.txt + pytest -v + " + elif echo "3.7 3.8" | grep -qw "$PYTHON_VERSION"; then + uv_install_script=$(get_uv_install_script_commands) + run_in_docker "$PYTHON_VERSION" " + $uv_install_script + export UV_PROJECT_ENVIRONMENT=\".venv-$PYTHON_VERSION\" + uv sync --group test + uv run task test + " + else + export UV_PROJECT_ENVIRONMENT=".venv-$PYTHON_VERSION" + uv python install "$PYTHON_VERSION" + uv python pin "$PYTHON_VERSION" + uv sync --group test + uv run task test + fi +} + +parse_args() { while [ $# -gt 0 ]; do case "$1" in --python-version) @@ -17,11 +46,40 @@ main() { esac shift done +} + +run_in_docker() { + version="$1" + script=" + echo \"$version\" > .python-version + $2 + " + docker run \ + --rm \ + --volume "$(pwd)":/app \ + --workdir /app \ + "python:$version-alpine" \ + sh -c "$script" +} + +export_requirements_txt_file_for_py36() { + # Python 3.6 isn't supported at all by uv (uv tries to use a 'text' keyword + # argument in a subprocess open call which doesn't exist until Python 3.7). + # Therefore, we need to export a requirements.txt file on-demand and then + # install it in a 3.6 container via pip. + uv_install_script=$(get_uv_install_script_commands) + run_in_docker "3.7" " + $uv_install_script + uv export --group test --no-editable --no-hashes > requirements.txt + " +} - uv python install "$PYTHON_VERSION" - uv python pin "$PYTHON_VERSION" - uv sync --group test - uv run task test +get_uv_install_script_commands() { + echo " + apk add curl + curl -fsSL https://astral.sh/uv/install.sh | sh + export PATH=\"\$HOME/.local/bin:\$PATH\" + " } main "$@" diff --git a/tests/fixtures/project_with_tasks_that_accept_arguments/count.sh b/tests/fixtures/project_with_tasks_that_accept_arguments/count.sh index 17153d5..6c5feb9 100644 --- a/tests/fixtures/project_with_tasks_that_accept_arguments/count.sh +++ b/tests/fixtures/project_with_tasks_that_accept_arguments/count.sh @@ -1 +1,2 @@ -echo the argument count is $# \ No newline at end of file +#!/bin/sh +echo the argument count is $# diff --git a/tests/fixtures/project_with_tasks_that_accept_arguments/pyproject.toml b/tests/fixtures/project_with_tasks_that_accept_arguments/pyproject.toml index 1459281..1206c2a 100644 --- a/tests/fixtures/project_with_tasks_that_accept_arguments/pyproject.toml +++ b/tests/fixtures/project_with_tasks_that_accept_arguments/pyproject.toml @@ -5,7 +5,7 @@ description = "tasks runner for python projects" [tool.taskipy.tasks] echo_number = "echo the number is " echo_named = "echo got a named argument " -echo_args_count = "bash count.sh" +echo_args_count = "sh count.sh" pre_echo_on_prehook = "echo the number in prehook is " echo_on_prehook = "echo ok" diff --git a/uv.lock b/uv.lock index 970a0b5..f0e2f10 100644 --- a/uv.lock +++ b/uv.lock @@ -1,14 +1,14 @@ version = 1 -revision = 2 +revision = 3 requires-python = ">=3.6" resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version == '3.9.*'", "python_full_version == '3.8.*'", "python_full_version == '3.7.*'", "python_full_version >= '3.6.8' and python_full_version < '3.7'", "python_full_version < '3.6.8'", - "python_full_version >= '3.11'", ] [[package]] @@ -75,17 +75,37 @@ name = "click" version = "8.3.1" source = { registry = "https://pypi.org/simple" } dependencies = [ - { name = "colorama", marker = "python_full_version >= '3.10' and sys_platform == 'win32'" }, + { name = "colorama", version = "0.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10' and sys_platform == 'win32'" }, ] sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, ] +[[package]] +name = "colorama" +version = "0.4.4" +source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.6.8' and python_full_version < '3.7'", + "python_full_version < '3.6.8'", +] +sdist = { url = "https://files.pythonhosted.org/packages/1f/bb/5d3246097ab77fa083a61bd8d3d527b7ae063c7d8e8671b1cf8c4ec10cbe/colorama-0.4.4.tar.gz", hash = "sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b", size = 27813, upload-time = "2020-10-15T18:36:33.372Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/44/98/5b86278fbbf250d239ae0ecb724f8572af1c91f4a11edf4d36a206189440/colorama-0.4.4-py2.py3-none-any.whl", hash = "sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2", size = 16028, upload-time = "2020-10-13T02:42:26.463Z" }, +] + [[package]] name = "colorama" version = "0.4.6" source = { registry = "https://pypi.org/simple" } +resolution-markers = [ + "python_full_version >= '3.11'", + "python_full_version == '3.10.*'", + "python_full_version == '3.9.*'", + "python_full_version == '3.8.*'", + "python_full_version == '3.7.*'", +] sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } wheels = [ { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, @@ -181,8 +201,8 @@ name = "iniconfig" version = "2.3.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ - "python_full_version == '3.10.*'", "python_full_version >= '3.11'", + "python_full_version == '3.10.*'", ] sdist = { url = "https://files.pythonhosted.org/packages/72/34/14ca021ce8e5dfedc35312d08ba8bf51fdd999c576889fc2c24cb97f4f10/iniconfig-2.3.0.tar.gz", hash = "sha256:c76315c77db068650d49c5b56314774a7804df16fee4402c1f19d6d15d8c4730", size = 20503, upload-time = "2025-10-18T21:55:43.219Z" } wheels = [ @@ -399,10 +419,10 @@ name = "packaging" version = "26.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version == '3.9.*'", "python_full_version == '3.8.*'", - "python_full_version >= '3.11'", ] sdist = { url = "https://files.pythonhosted.org/packages/65/ee/299d360cdc32edc7d2cf530f3accf79c4fca01e96ffc950d8a52213bd8e4/packaging-26.0.tar.gz", hash = "sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4", size = 143416, upload-time = "2026-01-21T20:50:39.064Z" } wheels = [ @@ -427,11 +447,11 @@ name = "parameterized" version = "0.9.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version == '3.9.*'", "python_full_version == '3.8.*'", "python_full_version == '3.7.*'", - "python_full_version >= '3.11'", ] sdist = { url = "https://files.pythonhosted.org/packages/ea/49/00c0c0cc24ff4266025a53e41336b79adaa5a4ebfad214f433d623f9865e/parameterized-0.9.0.tar.gz", hash = "sha256:7fc905272cefa4f364c1a3429cbbe9c0f98b793988efb5bf90aac80f08db09b1", size = 24351, upload-time = "2023-03-27T02:01:11.592Z" } wheels = [ @@ -504,9 +524,9 @@ name = "pluggy" version = "1.6.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version == '3.9.*'", - "python_full_version >= '3.11'", ] sdist = { url = "https://files.pythonhosted.org/packages/f9/e2/3e91f31a7d2b083fe6ef3fa267035b518369d9511ffab804f839851d2779/pluggy-1.6.0.tar.gz", hash = "sha256:7dcc130b76258d33b90f61b658791dede3486c3e6bfb003ee5c9bfb396dd22f3", size = 69412, upload-time = "2025-05-15T12:30:07.975Z" } wheels = [ @@ -594,7 +614,7 @@ resolution-markers = [ dependencies = [ { name = "atomicwrites", marker = "python_full_version < '3.7' and sys_platform == 'win32'" }, { name = "attrs", marker = "python_full_version < '3.7'" }, - { name = "colorama", marker = "python_full_version < '3.7' and sys_platform == 'win32'" }, + { name = "colorama", version = "0.4.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.7' and sys_platform == 'win32'" }, { name = "importlib-metadata", version = "4.8.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.7'" }, { name = "iniconfig", version = "1.1.1", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.7'" }, { name = "packaging", version = "21.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.7'" }, @@ -615,7 +635,7 @@ resolution-markers = [ "python_full_version == '3.7.*'", ] dependencies = [ - { name = "colorama", marker = "python_full_version == '3.7.*' and sys_platform == 'win32'" }, + { name = "colorama", version = "0.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.7.*' and sys_platform == 'win32'" }, { name = "exceptiongroup", marker = "python_full_version == '3.7.*'" }, { name = "importlib-metadata", version = "6.7.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.7.*'" }, { name = "iniconfig", version = "2.0.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.7.*'" }, @@ -636,7 +656,7 @@ resolution-markers = [ "python_full_version == '3.8.*'", ] dependencies = [ - { name = "colorama", marker = "python_full_version == '3.8.*' and sys_platform == 'win32'" }, + { name = "colorama", version = "0.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.8.*' and sys_platform == 'win32'" }, { name = "exceptiongroup", marker = "python_full_version == '3.8.*'" }, { name = "iniconfig", version = "2.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.8.*'" }, { name = "packaging", version = "26.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.8.*'" }, @@ -656,7 +676,7 @@ resolution-markers = [ "python_full_version == '3.9.*'", ] dependencies = [ - { name = "colorama", marker = "python_full_version == '3.9.*' and sys_platform == 'win32'" }, + { name = "colorama", version = "0.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.9.*' and sys_platform == 'win32'" }, { name = "exceptiongroup", marker = "python_full_version == '3.9.*'" }, { name = "iniconfig", version = "2.1.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.9.*'" }, { name = "packaging", version = "26.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version == '3.9.*'" }, @@ -674,11 +694,11 @@ name = "pytest" version = "9.0.2" source = { registry = "https://pypi.org/simple" } resolution-markers = [ - "python_full_version == '3.10.*'", "python_full_version >= '3.11'", + "python_full_version == '3.10.*'", ] dependencies = [ - { name = "colorama", marker = "python_full_version >= '3.10' and sys_platform == 'win32'" }, + { name = "colorama", version = "0.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10' and sys_platform == 'win32'" }, { name = "exceptiongroup", marker = "python_full_version == '3.10.*'" }, { name = "iniconfig", version = "2.3.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, { name = "packaging", version = "26.0", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.10'" }, @@ -770,7 +790,8 @@ name = "taskipy2" version = "1.16.0" source = { editable = "." } dependencies = [ - { name = "colorama" }, + { name = "colorama", version = "0.4.4", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.7'" }, + { name = "colorama", version = "0.4.6", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version >= '3.7'" }, { name = "mslex", marker = "sys_platform == 'win32'" }, { name = "psutil" }, { name = "tomli", version = "1.2.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.7'" }, @@ -797,7 +818,8 @@ test = [ [package.metadata] requires-dist = [ - { name = "colorama", specifier = ">=0.4.4" }, + { name = "colorama", marker = "python_full_version == '3.6.*'", specifier = ">=0.4.4,<0.4.6" }, + { name = "colorama", marker = "python_full_version >= '3.7'", specifier = ">=0.4.6" }, { name = "mslex", marker = "sys_platform == 'win32'", specifier = ">=1.1.0" }, { name = "psutil", specifier = ">=5.7.2" }, { name = "tomli", marker = "python_full_version == '3.6.*'", specifier = ">=1.2.3" }, @@ -945,9 +967,9 @@ name = "typing-extensions" version = "4.15.0" source = { registry = "https://pypi.org/simple" } resolution-markers = [ + "python_full_version >= '3.11'", "python_full_version == '3.10.*'", "python_full_version == '3.9.*'", - "python_full_version >= '3.11'", ] sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } wheels = [ -- cgit v1.2.3