From f026f0288a83d2b8d6d6c6b4d61a1beb6fa3fc75 Mon Sep 17 00:00:00 2001 From: Justin Date: Mon, 22 Apr 2024 16:57:49 -0500 Subject: [PATCH] Fix tox installs (#4603) * change: adjust tox black stages to install from requirements file Also remove uneeded config in the command, it is now set in the pyproject.toml so IDE's and other tooling outside tox picks up the setting. * change: improve tox install times by not installing all deps when not needed Moved to using deps to override the test extra being installed in skip_install tox stages. Now only the needed deps are installed. Improves install time by around 7x. Closes #4591 * change: bump twine version to 5.0.0 Twine 3.8.0 didn't include its dependencies. The tox stage happened to work from packaging being installed as a transitive. Ref: https://github.com/pypa/twine/issues/894 --- pyproject.toml | 2 ++ requirements/tox/black_requirements.txt | 1 + requirements/tox/twine_requirements.txt | 2 +- tox.ini | 37 +++++++++++++++++++------ 4 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 pyproject.toml create mode 100644 requirements/tox/black_requirements.txt diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000000..aa4949aa1c --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,2 @@ +[tool.black] +line-length = 100 diff --git a/requirements/tox/black_requirements.txt b/requirements/tox/black_requirements.txt new file mode 100644 index 0000000000..70f3034c8d --- /dev/null +++ b/requirements/tox/black_requirements.txt @@ -0,0 +1 @@ +black==24.3.0 diff --git a/requirements/tox/twine_requirements.txt b/requirements/tox/twine_requirements.txt index f9d2c8fdce..489eeb83e0 100644 --- a/requirements/tox/twine_requirements.txt +++ b/requirements/tox/twine_requirements.txt @@ -1 +1 @@ -twine==3.8.0 +twine==5.0.0 diff --git a/tox.ini b/tox.ini index f92654842d..718e968013 100644 --- a/tox.ini +++ b/tox.ini @@ -100,28 +100,33 @@ commands = [testenv:flake8] skipdist = true skip_install = true +deps = + -r requirements/tox/flake8_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/flake8_requirements.txt flake8 [testenv:pylint] skipdist = true skip_install = true +deps = + -r requirements/tox/pylint_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/pylint_requirements.txt python -m pylint --rcfile=.pylintrc -j 0 src/sagemaker [testenv:spelling] skipdist = true skip_install = true +deps = + -r requirements/tox/spelling_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/spelling_requirements.txt python -m pylint --rcfile=.pylintrc --disable all --enable spelling --spelling-dict en_US src/sagemaker/{posargs} [testenv:twine] # https://packaging.python.org/guides/making-a-pypi-friendly-readme/#validating-restructuredtext-markup +skip_install = true +deps = + -r requirements/tox/twine_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/twine_requirements.txt python setup.py sdist twine check dist/*.tar.gz @@ -136,25 +141,32 @@ commands = sphinx-build -T -W -b html -d _build/doctrees-readthedocs -D language=en . _build/html [testenv:doc8] +deps = + -r requirements/tox/doc8_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/doc8_requirements.txt doc8 --ignore-path tests/data/serve_resources/mlflow/pytorch/data/pickle_module_info.txt [testenv:black-format] # Used during development (before committing) to format .py files. +skip_install = true setenv = LC_ALL=C.UTF-8 LANG=C.UTF-8 +deps = + -r requirements/tox/black_requirements.txt commands = - black -l 100 ./ + black ./ [testenv:black-check] # Used by automated build steps to check that all files are properly formatted. +skip_install = true setenv = LC_ALL=C.UTF-8 LANG=C.UTF-8 +deps = + -r requirements/tox/black_requirements.txt commands = - black -l 100 --diff --color --check ./ + black --diff --color --check ./ [testenv:clean] skip_install = true @@ -162,13 +174,20 @@ commands = coverage erase [testenv:typing] +# Do not skip installation here, the extras are needed for mypy to get type info +skip_install = false +extras = + all +deps = + -r requirements/tox/mypy_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/mypy_requirements.txt mypy src/sagemaker [testenv:docstyle] +skip_install = true +deps = + -r requirements/tox/pydocstyle_requirements.txt commands = - pip install --exists-action=w -r requirements/tox/pydocstyle_requirements.txt pydocstyle src/sagemaker [testenv:collect-tests]