Skip to content

Commit

Permalink
Support more requirements things (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Jul 10, 2020
1 parent eb6113a commit 82386ea
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 5 deletions.
13 changes: 11 additions & 2 deletions builder/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,18 @@ def parse_requirements(requirement: Path) -> List[str]:
with requirement.open("r") as data:
for line in data:
line = line.strip()
if not line or line.startswith("#"):

# Ignore comments or constraint files
if not line or line.startswith(("#", "-c")):
continue

if not line.startswith("-r"):
requirement_list.add(line.split(" ")[-1])
continue
requirement_list.add(line.split(" ")[-1])

# References new requirements file
requirement_list.update(parse_requirements(requirement.parent / line[3:]))

return list(requirement_list)


Expand Down
1 change: 1 addition & 0 deletions requirements_tests.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flake8==3.8.3
pylint==2.5.3
black==19.10b0
pytest==5.4.3
1 change: 1 addition & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""Tests for wheel builder."""
2 changes: 2 additions & 0 deletions tests/requirements/constraints.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Constraint file
typing==1000000000000.0.0
3 changes: 3 additions & 0 deletions tests/requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Core requirements
-c constraints.txt
aiohttp==1.2.3
6 changes: 6 additions & 0 deletions tests/requirements/requirements_all.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# All requirements
-c constraints.txt

-r requirements.txt

aiohue==5.6.7
11 changes: 11 additions & 0 deletions tests/test_pip.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""Tests for pip module."""
from pathlib import Path
from builder import pip


def test_parse_requirements():
assert sorted(
pip.parse_requirements(
Path(__file__).parent / "requirements/requirements_all.txt"
)
) == ["aiohttp==1.2.3", "aiohue==5.6.7"]
10 changes: 7 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = lint, black
envlist = lint, black, test

[testenv]
deps =
Expand All @@ -10,9 +10,13 @@ deps =
basepython = python3
ignore_errors = True
commands =
flake8 builder
flake8 builder tests
pylint --rcfile pylintrc builder

[testenv:black]
commands =
black --target-version py37 --check builder setup.py
black --target-version py37 --check builder tests setup.py

[testenv:test]
commands =
pytest tests

0 comments on commit 82386ea

Please sign in to comment.