diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9b4c4bc74b1..2ba688afbe8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -27,7 +27,7 @@ repos: - id: validate_manifest - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.4 + rev: v0.7.3 hooks: - id: ruff - id: ruff-format diff --git a/poetry.lock b/poetry.lock index 716203f6b9b..63c85ff1d4a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand. [[package]] name = "backports-tarfile" @@ -819,38 +819,43 @@ files = [ [[package]] name = "mypy" -version = "1.11.0" +version = "1.13.0" description = "Optional static typing for Python" optional = false python-versions = ">=3.8" files = [ - {file = "mypy-1.11.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:a3824187c99b893f90c845bab405a585d1ced4ff55421fdf5c84cb7710995229"}, - {file = "mypy-1.11.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:96f8dbc2c85046c81bcddc246232d500ad729cb720da4e20fce3b542cab91287"}, - {file = "mypy-1.11.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:1a5d8d8dd8613a3e2be3eae829ee891b6b2de6302f24766ff06cb2875f5be9c6"}, - {file = "mypy-1.11.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:72596a79bbfb195fd41405cffa18210af3811beb91ff946dbcb7368240eed6be"}, - {file = "mypy-1.11.0-cp310-cp310-win_amd64.whl", hash = "sha256:35ce88b8ed3a759634cb4eb646d002c4cef0a38f20565ee82b5023558eb90c00"}, - {file = "mypy-1.11.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:98790025861cb2c3db8c2f5ad10fc8c336ed2a55f4daf1b8b3f877826b6ff2eb"}, - {file = "mypy-1.11.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:25bcfa75b9b5a5f8d67147a54ea97ed63a653995a82798221cca2a315c0238c1"}, - {file = "mypy-1.11.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:0bea2a0e71c2a375c9fa0ede3d98324214d67b3cbbfcbd55ac8f750f85a414e3"}, - {file = "mypy-1.11.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:d2b3d36baac48e40e3064d2901f2fbd2a2d6880ec6ce6358825c85031d7c0d4d"}, - {file = "mypy-1.11.0-cp311-cp311-win_amd64.whl", hash = "sha256:d8e2e43977f0e09f149ea69fd0556623919f816764e26d74da0c8a7b48f3e18a"}, - {file = "mypy-1.11.0-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:1d44c1e44a8be986b54b09f15f2c1a66368eb43861b4e82573026e04c48a9e20"}, - {file = "mypy-1.11.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:cea3d0fb69637944dd321f41bc896e11d0fb0b0aa531d887a6da70f6e7473aba"}, - {file = "mypy-1.11.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a83ec98ae12d51c252be61521aa5731f5512231d0b738b4cb2498344f0b840cd"}, - {file = "mypy-1.11.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:c7b73a856522417beb78e0fb6d33ef89474e7a622db2653bc1285af36e2e3e3d"}, - {file = "mypy-1.11.0-cp312-cp312-win_amd64.whl", hash = "sha256:f2268d9fcd9686b61ab64f077be7ffbc6fbcdfb4103e5dd0cc5eaab53a8886c2"}, - {file = "mypy-1.11.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:940bfff7283c267ae6522ef926a7887305945f716a7704d3344d6d07f02df850"}, - {file = "mypy-1.11.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:14f9294528b5f5cf96c721f231c9f5b2733164e02c1c018ed1a0eff8a18005ac"}, - {file = "mypy-1.11.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:d7b54c27783991399046837df5c7c9d325d921394757d09dbcbf96aee4649fe9"}, - {file = "mypy-1.11.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:65f190a6349dec29c8d1a1cd4aa71284177aee5949e0502e6379b42873eddbe7"}, - {file = "mypy-1.11.0-cp38-cp38-win_amd64.whl", hash = "sha256:dbe286303241fea8c2ea5466f6e0e6a046a135a7e7609167b07fd4e7baf151bf"}, - {file = "mypy-1.11.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:104e9c1620c2675420abd1f6c44bab7dd33cc85aea751c985006e83dcd001095"}, - {file = "mypy-1.11.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:f006e955718ecd8d159cee9932b64fba8f86ee6f7728ca3ac66c3a54b0062abe"}, - {file = "mypy-1.11.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:becc9111ca572b04e7e77131bc708480cc88a911adf3d0239f974c034b78085c"}, - {file = "mypy-1.11.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:6801319fe76c3f3a3833f2b5af7bd2c17bb93c00026a2a1b924e6762f5b19e13"}, - {file = "mypy-1.11.0-cp39-cp39-win_amd64.whl", hash = "sha256:c1a184c64521dc549324ec6ef7cbaa6b351912be9cb5edb803c2808a0d7e85ac"}, - {file = "mypy-1.11.0-py3-none-any.whl", hash = "sha256:56913ec8c7638b0091ef4da6fcc9136896914a9d60d54670a75880c3e5b99ace"}, - {file = "mypy-1.11.0.tar.gz", hash = "sha256:93743608c7348772fdc717af4aeee1997293a1ad04bc0ea6efa15bf65385c538"}, + {file = "mypy-1.13.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:6607e0f1dd1fb7f0aca14d936d13fd19eba5e17e1cd2a14f808fa5f8f6d8f60a"}, + {file = "mypy-1.13.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:8a21be69bd26fa81b1f80a61ee7ab05b076c674d9b18fb56239d72e21d9f4c80"}, + {file = "mypy-1.13.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b2353a44d2179846a096e25691d54d59904559f4232519d420d64da6828a3a7"}, + {file = "mypy-1.13.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:0730d1c6a2739d4511dc4253f8274cdd140c55c32dfb0a4cf8b7a43f40abfa6f"}, + {file = "mypy-1.13.0-cp310-cp310-win_amd64.whl", hash = "sha256:c5fc54dbb712ff5e5a0fca797e6e0aa25726c7e72c6a5850cfd2adbc1eb0a372"}, + {file = "mypy-1.13.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:581665e6f3a8a9078f28d5502f4c334c0c8d802ef55ea0e7276a6e409bc0d82d"}, + {file = "mypy-1.13.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:3ddb5b9bf82e05cc9a627e84707b528e5c7caaa1c55c69e175abb15a761cec2d"}, + {file = "mypy-1.13.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:20c7ee0bc0d5a9595c46f38beb04201f2620065a93755704e141fcac9f59db2b"}, + {file = "mypy-1.13.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:3790ded76f0b34bc9c8ba4def8f919dd6a46db0f5a6610fb994fe8efdd447f73"}, + {file = "mypy-1.13.0-cp311-cp311-win_amd64.whl", hash = "sha256:51f869f4b6b538229c1d1bcc1dd7d119817206e2bc54e8e374b3dfa202defcca"}, + {file = "mypy-1.13.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:5c7051a3461ae84dfb5dd15eff5094640c61c5f22257c8b766794e6dd85e72d5"}, + {file = "mypy-1.13.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:39bb21c69a5d6342f4ce526e4584bc5c197fd20a60d14a8624d8743fffb9472e"}, + {file = "mypy-1.13.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:164f28cb9d6367439031f4c81e84d3ccaa1e19232d9d05d37cb0bd880d3f93c2"}, + {file = "mypy-1.13.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:a4c1bfcdbce96ff5d96fc9b08e3831acb30dc44ab02671eca5953eadad07d6d0"}, + {file = "mypy-1.13.0-cp312-cp312-win_amd64.whl", hash = "sha256:a0affb3a79a256b4183ba09811e3577c5163ed06685e4d4b46429a271ba174d2"}, + {file = "mypy-1.13.0-cp313-cp313-macosx_10_13_x86_64.whl", hash = "sha256:a7b44178c9760ce1a43f544e595d35ed61ac2c3de306599fa59b38a6048e1aa7"}, + {file = "mypy-1.13.0-cp313-cp313-macosx_11_0_arm64.whl", hash = "sha256:5d5092efb8516d08440e36626f0153b5006d4088c1d663d88bf79625af3d1d62"}, + {file = "mypy-1.13.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:de2904956dac40ced10931ac967ae63c5089bd498542194b436eb097a9f77bc8"}, + {file = "mypy-1.13.0-cp313-cp313-musllinux_1_1_x86_64.whl", hash = "sha256:7bfd8836970d33c2105562650656b6846149374dc8ed77d98424b40b09340ba7"}, + {file = "mypy-1.13.0-cp313-cp313-win_amd64.whl", hash = "sha256:9f73dba9ec77acb86457a8fc04b5239822df0c14a082564737833d2963677dbc"}, + {file = "mypy-1.13.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:100fac22ce82925f676a734af0db922ecfea991e1d7ec0ceb1e115ebe501301a"}, + {file = "mypy-1.13.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7bcb0bb7f42a978bb323a7c88f1081d1b5dee77ca86f4100735a6f541299d8fb"}, + {file = "mypy-1.13.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bde31fc887c213e223bbfc34328070996061b0833b0a4cfec53745ed61f3519b"}, + {file = "mypy-1.13.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:07de989f89786f62b937851295ed62e51774722e5444a27cecca993fc3f9cd74"}, + {file = "mypy-1.13.0-cp38-cp38-win_amd64.whl", hash = "sha256:4bde84334fbe19bad704b3f5b78c4abd35ff1026f8ba72b29de70dda0916beb6"}, + {file = "mypy-1.13.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:0246bcb1b5de7f08f2826451abd947bf656945209b140d16ed317f65a17dc7dc"}, + {file = "mypy-1.13.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:7f5b7deae912cf8b77e990b9280f170381fdfbddf61b4ef80927edd813163732"}, + {file = "mypy-1.13.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7029881ec6ffb8bc233a4fa364736789582c738217b133f1b55967115288a2bc"}, + {file = "mypy-1.13.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:3e38b980e5681f28f033f3be86b099a247b13c491f14bb8b1e1e134d23bb599d"}, + {file = "mypy-1.13.0-cp39-cp39-win_amd64.whl", hash = "sha256:a6789be98a2017c912ae6ccb77ea553bbaf13d27605d2ca20a76dfbced631b24"}, + {file = "mypy-1.13.0-py3-none-any.whl", hash = "sha256:9c250883f9fd81d212e0952c92dbfcc96fc237f4b7c92f56ac81fd48460b3e5a"}, + {file = "mypy-1.13.0.tar.gz", hash = "sha256:0291a61b6fbf3e6673e3405cfcc0e7650bebc7939659fdca2702958038bd835e"}, ] [package.dependencies] @@ -860,6 +865,7 @@ typing-extensions = ">=4.6.0" [package.extras] dmypy = ["psutil (>=4.0)"] +faster-cache = ["orjson"] install-types = ["pip"] mypyc = ["setuptools (>=50)"] reports = ["lxml"] @@ -880,7 +886,7 @@ name = "nodeenv" version = "1.9.1" description = "Node.js virtual environment builder" optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" files = [ {file = "nodeenv-1.9.1-py2.py3-none-any.whl", hash = "sha256:ba11c9782d29c27c70ffbdda2d7415098754709be8a7056d79a737cd901155c9"}, {file = "nodeenv-1.9.1.tar.gz", hash = "sha256:6ec12890a2dab7946721edbfbcd91f3319c6ccc9aec47be7c7e6b7011ee6645f"}, diff --git a/pyproject.toml b/pyproject.toml index 1ac026df493..5e35aee21ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -98,8 +98,6 @@ extend-exclude = [ # External to the project's coding standards "tests/fixtures/git/*", "tests/fixtures/project_with_setup*/*", - "tests/masonry/builders/fixtures/pep_561_stub_only*/*", - "tests/utils/fixtures/setups/*", ] fix = true line-length = 88 diff --git a/src/poetry/console/application.py b/src/poetry/console/application.py index c5c1348d885..c038db7f02b 100644 --- a/src/poetry/console/application.py +++ b/src/poetry/console/application.py @@ -16,7 +16,6 @@ from cleo.events.event_dispatcher import EventDispatcher from cleo.exceptions import CleoError from cleo.formatters.style import Style -from cleo.io.null_io import NullIO from poetry.__version__ import __version__ from poetry.console.command_loader import CommandLoader @@ -322,13 +321,10 @@ def configure_installer_for_command(command: InstallerCommand, io: IO) -> None: ) command.set_installer(installer) - def _load_plugins(self, io: IO | None = None) -> None: + def _load_plugins(self, io: IO) -> None: if self._plugins_loaded: return - if io is None: - io = NullIO() - self._disable_plugins = io.input.has_parameter_option("--no-plugins") if not self._disable_plugins: diff --git a/src/poetry/inspection/lazy_wheel.py b/src/poetry/inspection/lazy_wheel.py index 8722a04ef5c..41826ebe8ea 100644 --- a/src/poetry/inspection/lazy_wheel.py +++ b/src/poetry/inspection/lazy_wheel.py @@ -10,11 +10,10 @@ from bisect import bisect_right from contextlib import contextmanager from tempfile import NamedTemporaryFile +from typing import IO from typing import TYPE_CHECKING from typing import Any -from typing import BinaryIO from typing import ClassVar -from typing import cast from urllib.parse import urlparse from zipfile import BadZipFile from zipfile import ZipFile @@ -168,14 +167,14 @@ def minimal_intervals_covering( yield from self._merge(start, end, left, right) -class ReadOnlyIOWrapper(BinaryIO): - """Implement read-side ``BinaryIO`` methods wrapping an inner ``BinaryIO``. +class ReadOnlyIOWrapper(IO[bytes]): + """Implement read-side ``IO[bytes]`` methods wrapping an inner ``IO[bytes]``. This wrapper is useful because Python currently does not distinguish read-only streams at the type level. """ - def __init__(self, inner: BinaryIO) -> None: + def __init__(self, inner: IO[bytes]) -> None: self._file = inner def __enter__(self) -> Self: @@ -296,7 +295,8 @@ def __init__( session: Session | Authenticator, delete_backing_file: bool = True, ) -> None: - super().__init__(cast(BinaryIO, NamedTemporaryFile(delete=delete_backing_file))) + inner = NamedTemporaryFile(delete=delete_backing_file) # noqa: SIM115 + super().__init__(inner) self._merge_intervals: MergeIntervals | None = None self._length: int | None = None diff --git a/src/poetry/utils/helpers.py b/src/poetry/utils/helpers.py index 22608f8c3eb..bd3ea330aaa 100644 --- a/src/poetry/utils/helpers.py +++ b/src/poetry/utils/helpers.py @@ -397,7 +397,7 @@ def extractall(source: Path, dest: Path, zip: bool) -> None: else: # These versions of python shipped with a broken tarfile data_filter, per # https://github.com/python/cpython/issues/107845. - broken_tarfile_filter = {(3, 8, 17), (3, 9, 17), (3, 10, 12), (3, 11, 4)} + broken_tarfile_filter = {(3, 9, 17), (3, 10, 12), (3, 11, 4)} with tarfile.open(source) as archive: if ( hasattr(tarfile, "data_filter") diff --git a/src/poetry/vcs/git/system.py b/src/poetry/vcs/git/system.py index 27ab0330002..2d0ffc761f3 100644 --- a/src/poetry/vcs/git/system.py +++ b/src/poetry/vcs/git/system.py @@ -40,7 +40,7 @@ def run(*args: Any, **kwargs: Any) -> None: git_command = find_git_command() env = os.environ.copy() env["GIT_TERMINAL_PROMPT"] = "0" - subprocess.check_call( # type: ignore[call-arg] + subprocess.check_call( git_command + list(args), stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL, diff --git a/tests/console/conftest.py b/tests/console/conftest.py index f14cf70d3c1..11b7a3d2268 100644 --- a/tests/console/conftest.py +++ b/tests/console/conftest.py @@ -97,7 +97,8 @@ def poetry( @pytest.fixture def app(poetry: Poetry) -> PoetryTestApplication: app_ = PoetryTestApplication(poetry) - app_._load_plugins() + io = NullIO() + app_._load_plugins(io) return app_ diff --git a/tests/integration/test_utils_vcs_git.py b/tests/integration/test_utils_vcs_git.py index 1e4229e0f48..e17966f3d6b 100644 --- a/tests/integration/test_utils_vcs_git.py +++ b/tests/integration/test_utils_vcs_git.py @@ -310,11 +310,11 @@ def test_system_git_fallback_on_http_401( GIT_USERNAME = os.environ.get("POETRY_TEST_INTEGRATION_GIT_USERNAME") GIT_PASSWORD = os.environ.get("POETRY_TEST_INTEGRATION_GIT_PASSWORD") -HTTP_AUTH_CREDENTIALS_AVAILABLE = not (GIT_USERNAME and GIT_PASSWORD) +HTTP_AUTH_CREDENTIALS_UNAVAILABLE = not (GIT_USERNAME and GIT_PASSWORD) @pytest.mark.skipif( - HTTP_AUTH_CREDENTIALS_AVAILABLE, + HTTP_AUTH_CREDENTIALS_UNAVAILABLE, reason="HTTP authentication credentials not available", ) def test_configured_repository_http_auth( diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/__init__.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi deleted file mode 100644 index d79e6e39ee0..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/module.pyi +++ /dev/null @@ -1,4 +0,0 @@ -"""Example module""" -from typing import Tuple - -version_info = Tuple[int, int, int] diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/subpkg/__init__.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only/pkg-stubs/subpkg/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only/pyproject.toml b/tests/masonry/builders/fixtures/pep_561_stub_only/pyproject.toml deleted file mode 100644 index 36a077afd95..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[tool.poetry] -name = "pep-561-stubs" -version = "0.1" -description = "PEP 561 stub package example" -authors = [ - "Oleg Höfling " -] -license = "MIT" -packages = [ - {include = "pkg-stubs"} -] - -[tool.poetry.dependencies] -python = "^3.6" diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/__init__.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi deleted file mode 100644 index d79e6e39ee0..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/module.pyi +++ /dev/null @@ -1,4 +0,0 @@ -"""Example module""" -from typing import Tuple - -version_info = Tuple[int, int, int] diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/py.typed b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/py.typed deleted file mode 100644 index b648ac92333..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/py.typed +++ /dev/null @@ -1 +0,0 @@ -partial diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/subpkg/__init__.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pkg-stubs/subpkg/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pyproject.toml b/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pyproject.toml deleted file mode 100644 index db202c04a1c..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only_partial/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[tool.poetry] -name = "pep-561-stubs" -version = "0.1" -description = "PEP 561 stub package example with the py.typed marker file" -authors = [ - "Oleg Höfling " -] -license = "MIT" -packages = [ - {include = "pkg-stubs"} -] - -[tool.poetry.dependencies] -python = "^3.6" diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_src/pyproject.toml b/tests/masonry/builders/fixtures/pep_561_stub_only_src/pyproject.toml deleted file mode 100644 index 666b2b24f6d..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only_src/pyproject.toml +++ /dev/null @@ -1,14 +0,0 @@ -[tool.poetry] -name = "pep-561-stubs" -version = "0.1" -description = "PEP 561 stub package example with an src layout" -authors = [ - "Oleg Höfling " -] -license = "MIT" -packages = [ - {include = "pkg-stubs", from = "src"} -] - -[tool.poetry.dependencies] -python = "^3.6" diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/__init__.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi deleted file mode 100644 index d79e6e39ee0..00000000000 --- a/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/module.pyi +++ /dev/null @@ -1,4 +0,0 @@ -"""Example module""" -from typing import Tuple - -version_info = Tuple[int, int, int] diff --git a/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/subpkg/__init__.pyi b/tests/masonry/builders/fixtures/pep_561_stub_only_src/src/pkg-stubs/subpkg/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/utils/fixtures/setups/ansible/requirements.txt b/tests/utils/fixtures/setups/ansible/requirements.txt deleted file mode 100644 index 09ba9fc6f06..00000000000 --- a/tests/utils/fixtures/setups/ansible/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Note: this requirements.txt file is used to specify what dependencies are -# needed to make the package run rather than for deployment of a tested set of -# packages. Thus, this should be the loosest set possible (only required -# packages, not optional ones, and with the widest range of versions that could -# be suitable) -jinja2 -PyYAML -paramiko -cryptography -setuptools diff --git a/tests/utils/fixtures/setups/ansible/setup.py b/tests/utils/fixtures/setups/ansible/setup.py deleted file mode 100644 index 3bebf1c3b9a..00000000000 --- a/tests/utils/fixtures/setups/ansible/setup.py +++ /dev/null @@ -1,326 +0,0 @@ -from __future__ import annotations - -import json -import os -import os.path -import re -import sys -import warnings - -from collections import defaultdict -from distutils.command.build_scripts import build_scripts as BuildScripts -from distutils.command.sdist import sdist as SDist - - -try: - from setuptools import find_packages - from setuptools import setup - from setuptools.command.build_py import build_py as BuildPy - from setuptools.command.install_lib import install_lib as InstallLib - from setuptools.command.install_scripts import install_scripts as InstallScripts -except ImportError: - print( - "Ansible now needs setuptools in order to build. Install it using" - " your package manager (usually python-setuptools) or via pip (pip" - " install setuptools).", - file=sys.stderr, - ) - sys.exit(1) - -sys.path.insert(0, os.path.abspath("lib")) -from ansible.release import __author__ -from ansible.release import __version__ - - -SYMLINK_CACHE = "SYMLINK_CACHE.json" - - -def _find_symlinks(topdir, extension=""): - """Find symlinks that should be maintained - - Maintained symlinks exist in the bin dir or are modules which have - aliases. Our heuristic is that they are a link in a certain path which - point to a file in the same directory. - """ - symlinks = defaultdict(list) - for base_path, dirs, files in os.walk(topdir): - for filename in files: - filepath = os.path.join(base_path, filename) - if os.path.islink(filepath) and filename.endswith(extension): - target = os.readlink(filepath) - if os.path.dirname(target) == "": - link = filepath[len(topdir) :] - if link.startswith("/"): - link = link[1:] - symlinks[os.path.basename(target)].append(link) - return symlinks - - -def _cache_symlinks(symlink_data): - with open(SYMLINK_CACHE, "w") as f: - json.dump(symlink_data, f) - - -def _maintain_symlinks(symlink_type, base_path): - """Switch a real file into a symlink""" - try: - # Try the cache first because going from git checkout to sdist is the - # only time we know that we're going to cache correctly - with open(SYMLINK_CACHE) as f: - symlink_data = json.load(f) - except OSError as e: - # IOError on py2, OSError on py3. Both have errno - if e.errno == 2: - # SYMLINKS_CACHE doesn't exist. Fallback to trying to create the - # cache now. Will work if we're running directly from a git - # checkout or from an sdist created earlier. - symlink_data = { - "script": _find_symlinks("bin"), - "library": _find_symlinks("lib", ".py"), - } - - # Sanity check that something we know should be a symlink was - # found. We'll take that to mean that the current directory - # structure properly reflects symlinks in the git repo - if "ansible-playbook" in symlink_data["script"]["ansible"]: - _cache_symlinks(symlink_data) - else: - raise - else: - raise - symlinks = symlink_data[symlink_type] - - for source in symlinks: - for dest in symlinks[source]: - dest_path = os.path.join(base_path, dest) - if not os.path.islink(dest_path): - try: - os.unlink(dest_path) - except OSError as e: - if e.errno == 2: - # File does not exist which is all we wanted - pass - os.symlink(source, dest_path) - - -class BuildPyCommand(BuildPy): - def run(self): - BuildPy.run(self) - _maintain_symlinks("library", self.build_lib) - - -class BuildScriptsCommand(BuildScripts): - def run(self): - BuildScripts.run(self) - _maintain_symlinks("script", self.build_dir) - - -class InstallLibCommand(InstallLib): - def run(self): - InstallLib.run(self) - _maintain_symlinks("library", self.install_dir) - - -class InstallScriptsCommand(InstallScripts): - def run(self): - InstallScripts.run(self) - _maintain_symlinks("script", self.install_dir) - - -class SDistCommand(SDist): - def run(self): - # have to generate the cache of symlinks for release as sdist is the - # only command that has access to symlinks from the git repo - symlinks = { - "script": _find_symlinks("bin"), - "library": _find_symlinks("lib", ".py"), - } - _cache_symlinks(symlinks) - - SDist.run(self) - - -def read_file(file_name): - """Read file and return its contents.""" - with open(file_name) as f: - return f.read() - - -def read_requirements(file_name): - """Read requirements file as a list.""" - reqs = read_file(file_name).splitlines() - if not reqs: - raise RuntimeError( - "Unable to read requirements from the %s file" - "That indicates this copy of the source code is incomplete." % file_name - ) - return reqs - - -PYCRYPTO_DIST = "pycrypto" - - -def get_crypto_req(): - """Detect custom crypto from ANSIBLE_CRYPTO_BACKEND env var. - - pycrypto or cryptography. We choose a default but allow the user to - override it. This translates into pip install of the sdist deciding what - package to install and also the runtime dependencies that pkg_resources - knows about. - """ - crypto_backend = os.environ.get("ANSIBLE_CRYPTO_BACKEND", "").strip() - - if crypto_backend == PYCRYPTO_DIST: - # Attempt to set version requirements - return "%s >= 2.6" % PYCRYPTO_DIST - - return crypto_backend or None - - -def substitute_crypto_to_req(req): - """Replace crypto requirements if customized.""" - crypto_backend = get_crypto_req() - - if crypto_backend is None: - return req - - def is_not_crypto(r): - CRYPTO_LIBS = PYCRYPTO_DIST, "cryptography" - return not any(r.lower().startswith(c) for c in CRYPTO_LIBS) - - return [r for r in req if is_not_crypto(r)] + [crypto_backend] - - -def read_extras(): - """Specify any extra requirements for installation.""" - extras = dict() - extra_requirements_dir = "packaging/requirements" - for extra_requirements_filename in os.listdir(extra_requirements_dir): - filename_match = re.search( - r"^requirements-(\w*).txt$", extra_requirements_filename - ) - if not filename_match: - continue - extra_req_file_path = os.path.join( - extra_requirements_dir, extra_requirements_filename - ) - try: - extras[filename_match.group(1)] = read_file( - extra_req_file_path - ).splitlines() - except RuntimeError: - pass - return extras - - -def get_dynamic_setup_params(): - """Add dynamically calculated setup params to static ones.""" - return { - # Retrieve the long description from the README - "long_description": read_file("README.rst"), - "install_requires": substitute_crypto_to_req( - read_requirements("requirements.txt") - ), - "extras_require": read_extras(), - } - - -static_setup_params = dict( - # Use the distutils SDist so that symlinks are not expanded - # Use a custom Build for the same reason - cmdclass={ - "build_py": BuildPyCommand, - "build_scripts": BuildScriptsCommand, - "install_lib": InstallLibCommand, - "install_scripts": InstallScriptsCommand, - "sdist": SDistCommand, - }, - name="ansible", - version=__version__, - description="Radically simple IT automation", - author=__author__, - author_email="info@ansible.com", - url="https://ansible.com/", - project_urls={ - "Bug Tracker": "https://github.com/ansible/ansible/issues", - "CI: Shippable": "https://app.shippable.com/github/ansible/ansible", - "Code of Conduct": "https://docs.ansible.com/ansible/latest/community/code_of_conduct.html", - "Documentation": "https://docs.ansible.com/ansible/", - "Mailing lists": "https://docs.ansible.com/ansible/latest/community/communication.html#mailing-list-information", - "Source Code": "https://github.com/ansible/ansible", - }, - license="GPLv3+", - # Ansible will also make use of a system copy of python-six and - # python-selectors2 if installed but use a Bundled copy if it's not. - python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*", - package_dir={"": "lib"}, - packages=find_packages("lib"), - package_data={ - "": [ - "module_utils/powershell/*.psm1", - "module_utils/powershell/*/*.psm1", - "modules/windows/*.ps1", - "modules/windows/*/*.ps1", - "galaxy/data/*/*.*", - "galaxy/data/*/*/.*", - "galaxy/data/*/*/*.*", - "galaxy/data/*/tests/inventory", - "config/base.yml", - "config/module_defaults.yml", - ] - }, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Information Technology", - "Intended Audience :: System Administrators", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", - "Natural Language :: English", - "Operating System :: POSIX", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Topic :: System :: Installation/Setup", - "Topic :: System :: Systems Administration", - "Topic :: Utilities", - ], - scripts=[ - "bin/ansible", - "bin/ansible-playbook", - "bin/ansible-pull", - "bin/ansible-doc", - "bin/ansible-galaxy", - "bin/ansible-console", - "bin/ansible-connection", - "bin/ansible-vault", - "bin/ansible-config", - "bin/ansible-inventory", - ], - data_files=[], - # Installing as zip files would break due to references to __file__ - zip_safe=False, -) - - -def main(): - """Invoke installation process using setuptools.""" - setup_params = dict(static_setup_params, **get_dynamic_setup_params()) - ignore_warning_regex = ( - r"Unknown distribution option: '(project_urls|python_requires)'" - ) - warnings.filterwarnings( - "ignore", - message=ignore_warning_regex, - category=UserWarning, - module="distutils.dist", - ) - setup(**setup_params) - warnings.resetwarnings() - - -if __name__ == "__main__": - main() diff --git a/tests/utils/fixtures/setups/extras_require_with_vars/setup.py b/tests/utils/fixtures/setups/extras_require_with_vars/setup.py deleted file mode 100644 index e40db81d327..00000000000 --- a/tests/utils/fixtures/setups/extras_require_with_vars/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - - -tests_require = ["pytest"] - -setup( - name="extras_require_with_vars", - version="0.0.1", - description="test setup_reader.py", - install_requires=[], - extras_require={"test": tests_require}, -) diff --git a/tests/utils/fixtures/setups/flask/setup.py b/tests/utils/fixtures/setups/flask/setup.py deleted file mode 100644 index 74a059deed6..00000000000 --- a/tests/utils/fixtures/setups/flask/setup.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env python -from __future__ import annotations - -import re - -from collections import OrderedDict - -from setuptools import setup - - -with open("README.rst", encoding="utf8") as f: - readme = f.read() - -with open("flask/__init__.py", encoding="utf8") as f: - version = re.search(r"__version__ = \'(.*?)\'", f.read()).group(1) - -setup( - name="Flask", - version=version, - url="https://www.palletsprojects.com/p/flask/", - project_urls=OrderedDict( - ( - ("Documentation", "http://flask.pocoo.org/docs/"), - ("Code", "https://github.com/pallets/flask"), - ("Issue tracker", "https://github.com/pallets/flask/issues"), - ) - ), - license="BSD", - author="Armin Ronacher", - author_email="armin.ronacher@active-4.com", - maintainer="Pallets team", - maintainer_email="contact@palletsprojects.com", - description="A simple framework for building complex web applications.", - long_description=readme, - packages=["flask", "flask.json"], - include_package_data=True, - zip_safe=False, - platforms="any", - python_requires=">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*", - install_requires=[ - "Werkzeug>=0.14", - "Jinja2>=2.10", - "itsdangerous>=0.24", - "click>=5.1", - ], - extras_require={ - "dotenv": ["python-dotenv"], - "dev": [ - "pytest>=3", - "coverage", - "tox", - "sphinx", - "pallets-sphinx-themes", - "sphinxcontrib-log-cabinet", - ], - "docs": ["sphinx", "pallets-sphinx-themes", "sphinxcontrib-log-cabinet"], - }, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Environment :: Web Environment", - "Framework :: Flask", - "Intended Audience :: Developers", - "License :: OSI Approved :: BSD License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Topic :: Internet :: WWW/HTTP :: Dynamic Content", - "Topic :: Internet :: WWW/HTTP :: WSGI :: Application", - "Topic :: Software Development :: Libraries :: Application Frameworks", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - entry_points={"console_scripts": ["flask = flask.cli:main"]}, -) diff --git a/tests/utils/fixtures/setups/minimal/setup.py b/tests/utils/fixtures/setups/minimal/setup.py deleted file mode 100644 index 536cf1785ef..00000000000 --- a/tests/utils/fixtures/setups/minimal/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - - -setup() diff --git a/tests/utils/fixtures/setups/pendulum/setup.py b/tests/utils/fixtures/setups/pendulum/setup.py deleted file mode 100644 index 705bd404289..00000000000 --- a/tests/utils/fixtures/setups/pendulum/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -from __future__ import annotations - -from distutils.core import setup - -from build import * # nopycln: import - - -packages = [ - "pendulum", - "pendulum._extensions", - "pendulum.formatting", - "pendulum.locales", - "pendulum.locales.da", - "pendulum.locales.de", - "pendulum.locales.en", - "pendulum.locales.es", - "pendulum.locales.fa", - "pendulum.locales.fo", - "pendulum.locales.fr", - "pendulum.locales.ko", - "pendulum.locales.lt", - "pendulum.locales.pt_br", - "pendulum.locales.zh", - "pendulum.mixins", - "pendulum.parsing", - "pendulum.parsing.exceptions", - "pendulum.tz", - "pendulum.tz.data", - "pendulum.tz.zoneinfo", - "pendulum.utils", -] - -package_data = {"": ["*"]} - -install_requires = ["python-dateutil>=2.6,<3.0", "pytzdata>=2018.3"] - -extras_require = {':python_version < "3.5"': ["typing>=3.6,<4.0"]} - -setup_kwargs = { - "name": "pendulum", - "version": "2.0.4", - "description": "Python datetimes made easy", - "author": "Sébastien Eustace", - "author_email": "sebastien@eustace.io", - "url": "https://pendulum.eustace.io", - "packages": packages, - "package_data": package_data, - "install_requires": install_requires, - "extras_require": extras_require, - "python_requires": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", -} - -build(setup_kwargs) - -setup(**setup_kwargs) diff --git a/tests/utils/fixtures/setups/pyyaml/setup.py b/tests/utils/fixtures/setups/pyyaml/setup.py deleted file mode 100644 index ce865368d2a..00000000000 --- a/tests/utils/fixtures/setups/pyyaml/setup.py +++ /dev/null @@ -1,356 +0,0 @@ -from __future__ import annotations - - -NAME = "PyYAML" -VERSION = "3.13" -DESCRIPTION = "YAML parser and emitter for Python" -LONG_DESCRIPTION = """\ -YAML is a data serialization format designed for human readability -and interaction with scripting languages. PyYAML is a YAML parser -and emitter for Python. - -PyYAML features a complete YAML 1.1 parser, Unicode support, pickle -support, capable extension API, and sensible error messages. PyYAML -supports standard YAML tags and provides Python-specific tags that -allow to represent an arbitrary Python object. - -PyYAML is applicable for a broad range of tasks from complex -configuration files to object serialization and persistence.""" -AUTHOR = "Kirill Simonov" -AUTHOR_EMAIL = "xi@resolvent.net" -LICENSE = "MIT" -PLATFORMS = "Any" -URL = "http://pyyaml.org/wiki/PyYAML" -DOWNLOAD_URL = f"http://pyyaml.org/download/pyyaml/{NAME}-{VERSION}.tar.gz" -CLASSIFIERS = [ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Topic :: Software Development :: Libraries :: Python Modules", - "Topic :: Text Processing :: Markup", -] - - -LIBYAML_CHECK = """ -#include - -int main(void) { - yaml_parser_t parser; - yaml_emitter_t emitter; - - yaml_parser_initialize(&parser); - yaml_parser_delete(&parser); - - yaml_emitter_initialize(&emitter); - yaml_emitter_delete(&emitter); - - return 0; -} -""" - - -import os.path -import platform -import sys - -from distutils import log -from distutils.command.bdist_rpm import bdist_rpm as _bdist_rpm -from distutils.command.build_ext import build_ext as _build_ext -from distutils.core import Command -from distutils.core import Distribution as _Distribution -from distutils.core import Extension as _Extension -from distutils.core import setup -from distutils.dir_util import mkpath -from distutils.errors import CompileError -from distutils.errors import DistutilsError -from distutils.errors import DistutilsPlatformError -from distutils.errors import LinkError - - -if "setuptools.extension" in sys.modules: - _Extension = sys.modules["setuptools.extension"]._Extension - sys.modules["distutils.core"].Extension = _Extension - sys.modules["distutils.extension"].Extension = _Extension - sys.modules["distutils.command.build_ext"].Extension = _Extension - -with_cython = False -try: - from Cython.Distutils import build_ext as _build_ext - from Cython.Distutils.extension import Extension as _Extension - - with_cython = True -except ImportError: - pass - -try: - from wheel.bdist_wheel import bdist_wheel -except ImportError: - bdist_wheel = None - - -class Distribution(_Distribution): - def __init__(self, attrs=None): - _Distribution.__init__(self, attrs) - if not self.ext_modules: - return - for idx in range(len(self.ext_modules) - 1, -1, -1): - ext = self.ext_modules[idx] - if not isinstance(ext, Extension): - continue - setattr(self, ext.attr_name, None) - self.global_options = [ - ( - ext.option_name, - None, - "include %s (default if %s is available)" - % (ext.feature_description, ext.feature_name), - ), - (ext.neg_option_name, None, "exclude %s" % ext.feature_description), - ] + self.global_options - self.negative_opt = self.negative_opt.copy() - self.negative_opt[ext.neg_option_name] = ext.option_name - - def has_ext_modules(self): - if not self.ext_modules: - return False - for ext in self.ext_modules: - with_ext = self.ext_status(ext) - if with_ext is None or with_ext: - return True - return False - - def ext_status(self, ext): - implementation = platform.python_implementation() - if implementation != "CPython": - return False - if isinstance(ext, Extension): - with_ext = getattr(self, ext.attr_name) - return with_ext - else: - return True - - -class Extension(_Extension): - def __init__( - self, name, sources, feature_name, feature_description, feature_check, **kwds - ): - if not with_cython: - for filename in sources[:]: - base, ext = os.path.splitext(filename) - if ext == ".pyx": - sources.remove(filename) - sources.append("%s.c" % base) - _Extension.__init__(self, name, sources, **kwds) - self.feature_name = feature_name - self.feature_description = feature_description - self.feature_check = feature_check - self.attr_name = "with_" + feature_name.replace("-", "_") - self.option_name = "with-" + feature_name - self.neg_option_name = "without-" + feature_name - - -class build_ext(_build_ext): - def run(self): - optional = True - disabled = True - for ext in self.extensions: - with_ext = self.distribution.ext_status(ext) - if with_ext is None: - disabled = False - elif with_ext: - optional = False - disabled = False - break - if disabled: - return - try: - _build_ext.run(self) - except DistutilsPlatformError: - exc = sys.exc_info()[1] - if optional: - log.warn(str(exc)) - log.warn("skipping build_ext") - else: - raise - - def get_source_files(self): - self.check_extensions_list(self.extensions) - filenames = [] - for ext in self.extensions: - if with_cython: - self.cython_sources(ext.sources, ext) - for filename in ext.sources: - filenames.append(filename) - base = os.path.splitext(filename)[0] - for ext in ["c", "h", "pyx", "pxd"]: - filename = f"{base}.{ext}" - if filename not in filenames and os.path.isfile(filename): - filenames.append(filename) - return filenames - - def get_outputs(self): - self.check_extensions_list(self.extensions) - outputs = [] - for ext in self.extensions: - fullname = self.get_ext_fullname(ext.name) - filename = os.path.join(self.build_lib, self.get_ext_filename(fullname)) - if os.path.isfile(filename): - outputs.append(filename) - return outputs - - def build_extensions(self): - self.check_extensions_list(self.extensions) - for ext in self.extensions: - with_ext = self.distribution.ext_status(ext) - if with_ext is None: - with_ext = self.check_extension_availability(ext) - if not with_ext: - continue - if with_cython: - ext.sources = self.cython_sources(ext.sources, ext) - self.build_extension(ext) - - def check_extension_availability(self, ext): - cache = os.path.join(self.build_temp, "check_%s.out" % ext.feature_name) - if not self.force and os.path.isfile(cache): - data = open(cache).read().strip() - if data == "1": - return True - elif data == "0": - return False - mkpath(self.build_temp) - src = os.path.join(self.build_temp, "check_%s.c" % ext.feature_name) - open(src, "w").write(ext.feature_check) - log.info("checking if %s is compilable" % ext.feature_name) - try: - [obj] = self.compiler.compile( - [src], - macros=ext.define_macros + [(undef,) for undef in ext.undef_macros], - include_dirs=ext.include_dirs, - extra_postargs=(ext.extra_compile_args or []), - depends=ext.depends, - ) - except CompileError: - log.warn("") - log.warn( - "%s is not found or a compiler error: forcing --%s" - % (ext.feature_name, ext.neg_option_name) - ) - log.warn( - "(if %s is installed correctly, you may need to" % ext.feature_name - ) - log.warn(" specify the option --include-dirs or uncomment and") - log.warn(" modify the parameter include_dirs in setup.cfg)") - open(cache, "w").write("0\n") - return False - prog = "check_%s" % ext.feature_name - log.info("checking if %s is linkable" % ext.feature_name) - try: - self.compiler.link_executable( - [obj], - prog, - output_dir=self.build_temp, - libraries=ext.libraries, - library_dirs=ext.library_dirs, - runtime_library_dirs=ext.runtime_library_dirs, - extra_postargs=(ext.extra_link_args or []), - ) - except LinkError: - log.warn("") - log.warn( - "%s is not found or a linker error: forcing --%s" - % (ext.feature_name, ext.neg_option_name) - ) - log.warn( - "(if %s is installed correctly, you may need to" % ext.feature_name - ) - log.warn(" specify the option --library-dirs or uncomment and") - log.warn(" modify the parameter library_dirs in setup.cfg)") - open(cache, "w").write("0\n") - return False - open(cache, "w").write("1\n") - return True - - -class bdist_rpm(_bdist_rpm): - def _make_spec_file(self): - argv0 = sys.argv[0] - features = [] - for ext in self.distribution.ext_modules: - if not isinstance(ext, Extension): - continue - with_ext = getattr(self.distribution, ext.attr_name) - if with_ext is None: - continue - if with_ext: - features.append("--" + ext.option_name) - else: - features.append("--" + ext.neg_option_name) - sys.argv[0] = " ".join([argv0] + features) - spec_file = _bdist_rpm._make_spec_file(self) - sys.argv[0] = argv0 - return spec_file - - -class test(Command): - - user_options = [] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - build_cmd = self.get_finalized_command("build") - build_cmd.run() - sys.path.insert(0, build_cmd.build_lib) - sys.path.insert(0, "tests/lib3") - import test_all - - if not test_all.main([]): - raise DistutilsError("Tests failed") - - -cmdclass = {"build_ext": build_ext, "bdist_rpm": bdist_rpm, "test": test} -if bdist_wheel: - cmdclass["bdist_wheel"] = bdist_wheel - - -if __name__ == "__main__": - - setup( - name=NAME, - version=VERSION, - description=DESCRIPTION, - long_description=LONG_DESCRIPTION, - author=AUTHOR, - author_email=AUTHOR_EMAIL, - license=LICENSE, - platforms=PLATFORMS, - url=URL, - download_url=DOWNLOAD_URL, - classifiers=CLASSIFIERS, - package_dir={"": "lib3"}, - packages=["yaml"], - ext_modules=[ - Extension( - "_yaml", - ["ext/_yaml.pyx"], - "libyaml", - "LibYAML bindings", - LIBYAML_CHECK, - libraries=["yaml"], - ) - ], - distclass=Distribution, - cmdclass=cmdclass, - ) diff --git a/tests/utils/fixtures/setups/requests/setup.py b/tests/utils/fixtures/setups/requests/setup.py deleted file mode 100644 index e8c2df313b1..00000000000 --- a/tests/utils/fixtures/setups/requests/setup.py +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env python -# Learn more: https://github.com/kennethreitz/setup.py -from __future__ import annotations - -import os -import sys - -from codecs import open - -from setuptools import setup -from setuptools.command.test import test as TestCommand - - -here = os.path.abspath(os.path.dirname(__file__)) - - -class PyTest(TestCommand): - user_options = [("pytest-args=", "a", "Arguments to pass into py.test")] - - def initialize_options(self): - TestCommand.initialize_options(self) - try: - from multiprocessing import cpu_count - - self.pytest_args = ["-n", str(cpu_count()), "--boxed"] - except (ImportError, NotImplementedError): - self.pytest_args = ["-n", "1", "--boxed"] - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - import pytest - - errno = pytest.main(self.pytest_args) - sys.exit(errno) - - -# 'setup.py publish' shortcut. -if sys.argv[-1] == "publish": - os.system("python setup.py sdist bdist_wheel") - os.system("twine upload dist/*") - sys.exit() - -packages = ["requests"] - -requires = [ - "chardet>=3.0.2,<3.1.0", - "idna>=2.5,<2.8", - "urllib3>=1.21.1,<1.25", - "certifi>=2017.4.17", -] -test_requirements = [ - "pytest-httpbin==0.0.7", - "pytest-cov", - "pytest-mock", - "pytest-xdist", - "PySocks>=1.5.6, !=1.5.7", - "pytest>=2.8.0", -] - -about = {} -with open(os.path.join(here, "requests", "__version__.py"), "r", "utf-8") as f: - exec(f.read(), about) - -with open("README.md", "r", "utf-8") as f: - readme = f.read() -with open("HISTORY.md", "r", "utf-8") as f: - history = f.read() - -setup( - name=about["__title__"], - version=about["__version__"], - description=about["__description__"], - long_description=readme, - long_description_content_type="text/markdown", - author=about["__author__"], - author_email=about["__author_email__"], - url=about["__url__"], - packages=packages, - package_data={"": ["LICENSE", "NOTICE"], "requests": ["*.pem"]}, - package_dir={"requests": "requests"}, - include_package_data=True, - python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*", - install_requires=requires, - license=about["__license__"], - zip_safe=False, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "Natural Language :: English", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python", - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], - cmdclass={"test": PyTest}, - tests_require=test_requirements, - extras_require={ - "security": ["pyOpenSSL >= 0.14", "cryptography>=1.3.4", "idna>=2.0.0"], - "socks": ["PySocks>=1.5.6, !=1.5.7"], - 'socks:sys_platform == "win32" and python_version == "2.7"': ["win_inet_pton"], - }, -) diff --git a/tests/utils/fixtures/setups/setuptools_setup/setup.py b/tests/utils/fixtures/setups/setuptools_setup/setup.py deleted file mode 100644 index c8e0dafe38c..00000000000 --- a/tests/utils/fixtures/setups/setuptools_setup/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -from __future__ import annotations - -import setuptools - - -setuptools.setup( - name="my_package", - version="0.1.2", - author="John Doe", - author_email="john@example.orh", - description="Just a description", - url="https://example.org", - packages=setuptools.find_packages(), -) diff --git a/tests/utils/fixtures/setups/sqlalchemy/setup.py b/tests/utils/fixtures/setups/sqlalchemy/setup.py deleted file mode 100644 index b44d21509e4..00000000000 --- a/tests/utils/fixtures/setups/sqlalchemy/setup.py +++ /dev/null @@ -1,206 +0,0 @@ -from __future__ import annotations - -import os -import platform -import re -import sys - -from distutils.command.build_ext import build_ext -from distutils.errors import CCompilerError -from distutils.errors import DistutilsExecError -from distutils.errors import DistutilsPlatformError - -from setuptools import Distribution as _Distribution -from setuptools import Extension -from setuptools import find_packages -from setuptools import setup -from setuptools.command.test import test as TestCommand - - -cmdclass = {} - -cpython = platform.python_implementation() == "CPython" - -ext_modules = [ - Extension( - "sqlalchemy.cprocessors", sources=["lib/sqlalchemy/cextension/processors.c"] - ), - Extension( - "sqlalchemy.cresultproxy", sources=["lib/sqlalchemy/cextension/resultproxy.c"] - ), - Extension("sqlalchemy.cutils", sources=["lib/sqlalchemy/cextension/utils.c"]), -] - -ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError) -if sys.platform == "win32": - # 2.6's distutils.msvc9compiler can raise an IOError when failing to - # find the compiler - ext_errors += (IOError,) - - -class BuildFailed(Exception): - def __init__(self): - self.cause = sys.exc_info()[1] # work around py 2/3 different syntax - - -class ve_build_ext(build_ext): - # This class allows C extension building to fail. - - def run(self): - try: - build_ext.run(self) - except DistutilsPlatformError: - raise BuildFailed() - - def build_extension(self, ext): - try: - build_ext.build_extension(self, ext) - except ext_errors: - raise BuildFailed() - except ValueError: - # this can happen on Windows 64 bit, see Python issue 7511 - if "'path'" in str(sys.exc_info()[1]): # works with both py 2/3 - raise BuildFailed() - raise - - -cmdclass["build_ext"] = ve_build_ext - - -class Distribution(_Distribution): - def has_ext_modules(self): - # We want to always claim that we have ext_modules. This will be fine - # if we don't actually have them (such as on PyPy) because nothing - # will get built, however we don't want to provide an overally broad - # Wheel package when building a wheel without C support. This will - # ensure that Wheel knows to treat us as if the build output is - # platform specific. - return True - - -class PyTest(TestCommand): - # from http://pytest.org/latest/goodpractices.html\ - # #integrating-with-setuptools-python-setup-py-test-pytest-runner - # TODO: prefer pytest-runner package at some point, however it was - # not working at the time of this comment. - user_options = [("pytest-args=", "a", "Arguments to pass to py.test")] - - default_options = ["-n", "4", "-q", "--nomemory"] - - def initialize_options(self): - TestCommand.initialize_options(self) - self.pytest_args = "" - - def finalize_options(self): - TestCommand.finalize_options(self) - self.test_args = [] - self.test_suite = True - - def run_tests(self): - import shlex - - # import here, cause outside the eggs aren't loaded - import pytest - - errno = pytest.main(self.default_options + shlex.split(self.pytest_args)) - sys.exit(errno) - - -cmdclass["test"] = PyTest - - -def status_msgs(*msgs): - print("*" * 75) - for msg in msgs: - print(msg) - print("*" * 75) - - -with open( - os.path.join(os.path.dirname(__file__), "lib", "sqlalchemy", "__init__.py") -) as v_file: - VERSION = re.compile(r".*__version__ = '(.*?)'", re.S).match(v_file.read()).group(1) - -with open(os.path.join(os.path.dirname(__file__), "README.rst")) as r_file: - readme = r_file.read() - - -def run_setup(with_cext): - kwargs = {} - if with_cext: - kwargs["ext_modules"] = ext_modules - else: - kwargs["ext_modules"] = [] - - setup( - name="SQLAlchemy", - version=VERSION, - description="Database Abstraction Library", - author="Mike Bayer", - author_email="mike_mp@zzzcomputing.com", - url="http://www.sqlalchemy.org", - packages=find_packages("lib"), - package_dir={"": "lib"}, - license="MIT License", - cmdclass=cmdclass, - tests_require=["pytest >= 2.5.2", "mock", "pytest-xdist"], - long_description=readme, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Programming Language :: Python", - "Programming Language :: Python :: 3", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Database :: Front-Ends", - "Operating System :: OS Independent", - ], - distclass=Distribution, - extras_require={ - "mysql": ["mysqlclient"], - "pymysql": ["pymysql"], - "postgresql": ["psycopg2"], - "postgresql_pg8000": ["pg8000"], - "postgresql_psycopg2cffi": ["psycopg2cffi"], - "oracle": ["cx_oracle"], - "mssql_pyodbc": ["pyodbc"], - "mssql_pymssql": ["pymssql"], - }, - **kwargs - ) - - -if not cpython: - run_setup(False) - status_msgs( - "WARNING: C extensions are not supported on " - + "this Python platform, speedups are not enabled.", - "Plain-Python build succeeded.", - ) -elif os.environ.get("DISABLE_SQLALCHEMY_CEXT"): - run_setup(False) - status_msgs( - "DISABLE_SQLALCHEMY_CEXT is set; " + "not attempting to build C extensions.", - "Plain-Python build succeeded.", - ) - -else: - try: - run_setup(True) - except BuildFailed as exc: - status_msgs( - exc.cause, - "WARNING: The C extension could not be compiled, " - + "speedups are not enabled.", - "Failure information, if any, is above.", - "Retrying the build without the C extension now.", - ) - - run_setup(False) - - status_msgs( - "WARNING: The C extension could not be compiled, " - + "speedups are not enabled.", - "Plain-Python build succeeded.", - ) diff --git a/tests/utils/fixtures/setups/with-setup-cfg-attr/setup.cfg b/tests/utils/fixtures/setups/with-setup-cfg-attr/setup.cfg deleted file mode 100644 index c45d1e62869..00000000000 --- a/tests/utils/fixtures/setups/with-setup-cfg-attr/setup.cfg +++ /dev/null @@ -1,19 +0,0 @@ -[metadata] -name = with-setup-cfg-attr -version = attr: with_setup_cfg_attr.__version__ - -[options] -zip_safe = true -python_requires = >=2.6,!=3.0,!=3.1,!=3.2,!=3.3 -setup_requires = setuptools>=36.2.2 -install_requires = - six - tomlkit - -[options.extras_require] -validation = - cerberus -tests = - pytest - pytest-xdist - pytest-cov diff --git a/tests/utils/fixtures/setups/with-setup-cfg-attr/setup.py b/tests/utils/fixtures/setups/with-setup-cfg-attr/setup.py deleted file mode 100644 index 536cf1785ef..00000000000 --- a/tests/utils/fixtures/setups/with-setup-cfg-attr/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - - -setup() diff --git a/tests/utils/fixtures/setups/with-setup-cfg-minimal/setup.cfg b/tests/utils/fixtures/setups/with-setup-cfg-minimal/setup.cfg deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tests/utils/fixtures/setups/with-setup-cfg-minimal/setup.py b/tests/utils/fixtures/setups/with-setup-cfg-minimal/setup.py deleted file mode 100644 index 536cf1785ef..00000000000 --- a/tests/utils/fixtures/setups/with-setup-cfg-minimal/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - - -setup() diff --git a/tests/utils/fixtures/setups/with-setup-cfg/setup.cfg b/tests/utils/fixtures/setups/with-setup-cfg/setup.cfg deleted file mode 100644 index edae13166af..00000000000 --- a/tests/utils/fixtures/setups/with-setup-cfg/setup.cfg +++ /dev/null @@ -1,20 +0,0 @@ -[metadata] -name = with-setup-cfg -version = 1.2.3 -description = Package with setup.cfg - -[options] -zip_safe = true -python_requires = >=2.6,!=3.0,!=3.1,!=3.2,!=3.3 -setup_requires = setuptools>=36.2.2 -install_requires = - six - tomlkit - -[options.extras_require] -validation = - cerberus -tests = - pytest - pytest-xdist - pytest-cov diff --git a/tests/utils/fixtures/setups/with-setup-cfg/setup.py b/tests/utils/fixtures/setups/with-setup-cfg/setup.py deleted file mode 100644 index 536cf1785ef..00000000000 --- a/tests/utils/fixtures/setups/with-setup-cfg/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -from __future__ import annotations - -from setuptools import setup - - -setup() diff --git a/tests/utils/test_python_manager.py b/tests/utils/test_python_manager.py index 48bcb917638..9113bd1bf4d 100644 --- a/tests/utils/test_python_manager.py +++ b/tests/utils/test_python_manager.py @@ -74,11 +74,11 @@ def test_get_preferred_python_use_poetry_python_disabled_fallback( config: Config, mocker: MockerFixture ) -> None: config.config["virtualenvs"]["use-poetry-python"] = False - with mocker.patch( + mocker.patch( "subprocess.check_output", side_effect=subprocess.CalledProcessError(1, "some command"), - ): - python = Python.get_preferred_python(config) + ) + python = Python.get_preferred_python(config) assert python.executable == Path(sys.executable)