Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (setup_reader): parse arguments when setuptools.setup() is used (#1761) #1764

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions poetry/utils/setup_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,11 @@ def _find_setup_call(
continue

func = value.func
if not isinstance(func, ast.Name):
continue

if func.id != "setup":
if not (isinstance(func, ast.Name) and func.id == "setup") and not (
isinstance(func, ast.Attribute)
and func.value.id == "setuptools"
and func.attr == "setup"
):
continue

return value, elements
Expand Down
11 changes: 11 additions & 0 deletions tests/utils/fixtures/setups/setuptools_setup/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import setuptools

setuptools.setup(
name="my_package",
version="0.1.2",
author="John Doe",
author_email="[email protected]",
description="Just a description",
url="https://example.org",
packages=setuptools.find_packages(),
)
11 changes: 11 additions & 0 deletions tests/utils/test_setup_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,14 @@ def test_setup_reader_read_extras_require_with_variables(setup):
assert expected_install_requires == result["install_requires"]
assert expected_extras_require == result["extras_require"]
assert expected_python_requires == result["python_requires"]


@pytest.mark.skipif(not PY35, reason="AST parsing does not work for Python <3.4")
def test_setup_reader_setuptools(setup):
result = SetupReader.read_from_directory(setup("setuptools_setup"))

expected_name = "my_package"
expected_version = "0.1.2"

assert expected_name == result["name"]
assert expected_version == result["version"]