Skip to content

Commit

Permalink
Convert install_requirement.py to a module
Browse files Browse the repository at this point in the history
  • Loading branch information
rmartin16 committed May 25, 2023
1 parent 5456993 commit 34be3c0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools build wheel
# Utility script installs tox as defined in pyproject.toml
python install_requirement.py tox --extra dev
python -m install_requirement --extra dev tox
- name: Test
id: test
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
python -m pip install --upgrade pip
python -m pip install --upgrade setuptools build wheel
# Utility script installs tox as defined in pyproject.toml
python install_requirement.py tox --extra dev
python -m install_requirement --extra dev tox
- name: Retrieve Coverage Data
uses: actions/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include README.rst
include AUTHORS
include LICENSE
include docs/spelling_wordlist
include install_requirement.py
include install_requirement/*.py
include pyproject.toml
include tests/integrations/xcode/simctl/README
include tox.ini
Expand Down
6 changes: 6 additions & 0 deletions install_requirement/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

from .install_requirement import main

if __name__ == "__main__":
sys.exit(main())
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def gather_requirements(
project_root = Path(project_root).resolve()
project_metadata = project_wheel_metadata(project_root, isolated=False)
project_requirements = [
req
for req in map(Requirement, project_metadata.get_all("Requires-Dist"))
if not req.marker or req.marker.evaluate(environment={"extra": extra_name})
requirement
for requirement in map(Requirement, project_metadata.get_all("Requires-Dist"))
if not requirement.marker or requirement.marker.evaluate({"extra": extra_name})
]

matching_requirements = [
Expand All @@ -124,7 +124,8 @@ def gather_requirements(

if not matching_requirements:
raise NoRequirementsFound(
f"No requirements matched requested requirements: {', '.join(requested_requirements)}.\n\n"
f"No requirements matched requested requirements: "
f"{', '.join(requested_requirements)}.\n\n"
f"The requirements below were evaluated for matching:\n "
f"{f'{chr(10)} '.join(req.name for req in project_requirements)}",
error_no=1,
Expand All @@ -150,8 +151,6 @@ def install_requirements(requirements: list[Requirement]):
check=True,
)

return 0


def main():
ret_code = 0
Expand Down
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ download = True
# 2023-04-22 see pkgenv ↑
download = {[pkgenv]download}
skip_install = True
commands_pre = python {tox_root}{/}tests{/}env_utils.py install-req pre-commit
deps = build
commands_pre = python -m install_requirement --extra dev --project-root "{tox_root}" pre-commit
commands = pre-commit run --all-files --show-diff-on-failure --color=always

[testenv:py{,38,39,310,311,312}{,-fast}]
Expand Down Expand Up @@ -68,10 +69,13 @@ setenv =
{platform,project}: COVERAGE_EXCLUDE_PYTHON_VERSION=disable
# disable conditional coverage exclusions for host platform to test entire project
project: COVERAGE_EXCLUDE_PLATFORM=disable
deps = build
deps =
build
setuptools
wheel
commands_pre =
python --version
python {tox_root}{/}install_requirement.py coverage --extra dev --project-root {tox_root}
python -m install_requirement --extra dev --project-root "{tox_root}" coverage
commands =
-python -m coverage combine {env:COMBINE_FLAGS}
html: python -m coverage html --skip-covered --skip-empty
Expand Down

0 comments on commit 34be3c0

Please sign in to comment.