Skip to content

Commit

Permalink
Mention setup.cfg support in the README file
Browse files Browse the repository at this point in the history
Fixes arkq#44
  • Loading branch information
arkq committed Aug 10, 2021
1 parent c29f14c commit 83d9b79
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
1 change: 0 additions & 1 deletion .github/workflows/pythoncheck.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
name: Check Python Package
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Important notice
----------------

In order to collect project's dependencies, this checker evaluates Python code from the
``setup.py`` file stored in the project's root directory. Code evaluation is done with the
`eval() <https://docs.python.org/3/library/functions.html#eval>`_ function. As a fall-back
method, this checker also tries to load dependencies from the ``pyproject.toml`` file from
the `poetry <https://python-poetry.org/>`_ tool section, or from the ``requirements.txt``
text file in the project's root directory.
``setup.py`` file stored in the project's root directory. Code evaluation is done with the `eval()
<https://docs.python.org/3/library/functions.html#eval>`_ function. As a fall-back method, this
checker also tries to load dependencies, in order, from the ``setup.cfg``, the ``pyproject.toml``
file from the `poetry <https://python-poetry.org/>`_ tool section, or from the
``requirements.txt`` text file in the project's root directory.

At this point it is very important to be aware of the consequences of the above approach. One
might inject malicious code into the ``setup.py`` file, which will be executed by this checker.
Expand Down
13 changes: 8 additions & 5 deletions src/flake8_requirements/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from .modules import STDLIB_PY3

# NOTE: Changing this number will alter package version as well.
__version__ = "1.5.0"
__version__ = "1.5.1"
__license__ = "MIT"

LOG = getLogger('flake8.plugin.requirements')
Expand Down Expand Up @@ -346,8 +346,8 @@ def add_options(cls, manager):
"Specify the name (location) of the requirements text file. "
"Unless an absolute path is given, the file will be searched "
"relative to the project's root directory. If this option is "
"given, requirements from setup.py or pyproject.toml will not"
" be taken into account."
"given, requirements from setup.py, setup.cfg or "
"pyproject.toml will not be taken into account."
),
**kw
)
Expand Down Expand Up @@ -466,8 +466,11 @@ def resolve_requirement(cls, requirement, max_depth=0, path=None):
if option in ("-r", "--requirement"):
# Error out if we need to recurse deeper than allowed.
if max_depth <= 0:
msg = "Cannot resolve {}: beyond max depth"
raise RuntimeError(msg.format(requirement))
msg = (
"Cannot resolve {}: "
"Beyond max depth (--requirements-max-depth={})")
raise RuntimeError(msg.format(
requirement, cls.requirements_max_depth))
resolved = []
# Error out if requirements file cannot be opened.
with open(os.path.join(path or cls.root_dir, requirement)) as f:
Expand Down

0 comments on commit 83d9b79

Please sign in to comment.