Skip to content

Commit

Permalink
Fix tox installs (#4603)
Browse files Browse the repository at this point in the history
* 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: pypa/twine#894
  • Loading branch information
jmahlik authored Apr 22, 2024
1 parent 03888f6 commit f026f02
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.black]
line-length = 100
1 change: 1 addition & 0 deletions requirements/tox/black_requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
black==24.3.0
2 changes: 1 addition & 1 deletion requirements/tox/twine_requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
twine==3.8.0
twine==5.0.0
37 changes: 28 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -136,39 +141,53 @@ 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
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]
Expand Down

0 comments on commit f026f02

Please sign in to comment.