diff --git a/.ci/Dockerfile.client b/.ci/Dockerfile.client index 1b3a937ab..f55544b28 100644 --- a/.ci/Dockerfile.client +++ b/.ci/Dockerfile.client @@ -13,4 +13,4 @@ RUN python -m pip install \ -r dev-requirements.txt COPY . . -RUN python -m pip install -e . +RUN python -m pip install -e .[tests] diff --git a/.ci/run-repository.sh b/.ci/run-repository.sh index 4ad01d69f..3d663bc35 100755 --- a/.ci/run-repository.sh +++ b/.ci/run-repository.sh @@ -36,6 +36,7 @@ OPENSEARCH_REQUIRED_VERSION="2.12.0" COMPARE_VERSION=`echo $OPENSEARCH_REQUIRED_VERSION $OPENSEARCH_VERSION | tr ' ' '\n' | sort -V | uniq | head -n 1` if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then docker run \ + --tty \ --network=${network_name} \ --env "STACK_VERSION=${STACK_VERSION}" \ --env "OPENSEARCH_URL=${opensearch_url}" \ @@ -48,9 +49,10 @@ if [ "$COMPARE_VERSION" != "$OPENSEARCH_REQUIRED_VERSION" ]; then --name opensearch-py \ --rm \ opensearch-project/opensearch-py \ - python setup.py test + python test_opensearchpy/run_tests.py else docker run \ + --tty \ --network=${network_name} \ --env "STACK_VERSION=${STACK_VERSION}" \ --env "OPENSEARCH_URL=${opensearch_url}" \ @@ -63,7 +65,7 @@ else --name opensearch-py \ --rm \ opensearch-project/opensearch-py \ - python setup.py test + python test_opensearchpy/run_tests.py fi unset TEST_PATTERN diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 93ff42e5d..52a3bcadf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,9 +61,9 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - python -m pip install setuptools wheel twine + python -m pip install twine build - name: Build source distribution - run: python setup.py sdist bdist_wheel + run: pyproject-build - name: Check with Twine working-directory: dist run: twine check * diff --git a/.github/workflows/integration-unreleased.yml b/.github/workflows/integration-unreleased.yml index 08da24a28..4329d1f38 100644 --- a/.github/workflows/integration-unreleased.yml +++ b/.github/workflows/integration-unreleased.yml @@ -71,6 +71,6 @@ jobs: mkdir -p junit python -m pip install -U --no-cache-dir --disable-pip-version-check pip python -m pip install --no-cache-dir --disable-pip-version-check -r dev-requirements.txt - python -m pip install -e . - python setup.py test + python -m pip install -e .[tests] + python test_opensearchpy/run_tests.py working-directory: opensearch-py diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 7499f2640..6a541bb13 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -33,8 +33,7 @@ jobs: run: | python -m pip install --upgrade build - name: Build project for distribution - run: | - python -m build + run: pyproject-build - name: upload windows dists uses: actions/upload-artifact@v4 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 3953624f8..4a10c3f37 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Updated opensearch-py APIs to reflect [opensearch-api-specification@578a78d](https://github.com/opensearch-project/opensearch-api-specification/commit/578a78dcec746e81da88f81ad442ab1836db7694) ### Changed - Rename `DenseVector` field type to `KnnVector` ([925](https://github.com/opensearch-project/opensearch-py/pull/925)) +- Migrate `setup.py` to a `pyproject.toml` ([951](https://github.com/opensearch-project/opensearch-py/pull/951)) ### Deprecated ### Removed ### Fixed diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 218eb0b13..67f356b21 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -54,13 +54,13 @@ export OPENSEARCH_PASSWORD=myStrongPassword123! If you have one running. ``` -python setup.py test +python test_opensearchpy/run_tests.py ``` To run tests in a specific test file. ``` -python setup.py test -s test_opensearchpy/test_connection/test_base_connection.py +python test_opensearchpy/run_tests.py -s test_opensearchpy/test_connection/test_base_connection.py ``` If you want to auto-start one, the following will start a new instance and run tests against the latest version of OpenSearch. diff --git a/MANIFEST.in b/MANIFEST.in index 9f446e083..0368d6456 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,7 +4,7 @@ include CONTRIBUTING.md include LICENSE include MANIFEST.in include README.md -include setup.py +include pyproject.toml recursive-include opensearch* py.typed prune test_opensearch diff --git a/Makefile b/Makefile index c4cc2a012..084f53e9b 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ push: PYTHON_VERSION=${PYTHON_VERSION} docker-compose push client run_tests: - OPENSEARCH_VERSION=${OPENSEARCH_VERSION} PYTHON_VERSION=${PYTHON_VERSION} docker-compose -p "${OPEN_VERSION}-${PYTHON_VERSION}" run client python setup.py test + OPENSEARCH_VERSION=${OPENSEARCH_VERSION} PYTHON_VERSION=${PYTHON_VERSION} docker-compose -p "${OPEN_VERSION}-${PYTHON_VERSION}" run client python test_opensearchpy/run_tests.py start_opensearch: OPENSEARCH_VERSION=${OPENSEARCH_VERSION} docker-compose up -d opensearch diff --git a/dev-requirements.txt b/dev-requirements.txt index d32ba339c..48888b95b 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -9,6 +9,7 @@ pytz deepmerge Events setuptools==71.1.0 +build numpy; python_version<="3.12" pandas; python_version<="3.12" diff --git a/noxfile.py b/noxfile.py index a0fcc7959..59767247c 100644 --- a/noxfile.py +++ b/noxfile.py @@ -30,7 +30,6 @@ import nox SOURCE_FILES = ( - "setup.py", "noxfile.py", "opensearchpy/", "test_opensearchpy/", @@ -44,7 +43,7 @@ @nox.session(python=["3.8", "3.9", "3.10", "3.11", "3.12"]) # type: ignore def test(session: Any) -> None: """ - runs all tests with a fresh python environment using "python setup.py test" + runs all tests with a fresh python environment :param session: current nox session """ session.install(".") @@ -56,9 +55,10 @@ def test(session: Any) -> None: "python", "-c", "import opensearchpy\nprint(opensearchpy.AsyncOpenSearch())" ) + session.install(".[tests]") session.install("-r", "dev-requirements.txt") - session.run("python", "setup.py", "test") + session.run("python", "test_opensearchpy/run_tests.py") @nox.session(python=["3.8"]) # type: ignore diff --git a/opensearchpy/_async/client/client.py b/opensearchpy/_async/client/client.py index 408073602..96040e93d 100644 --- a/opensearchpy/_async/client/client.py +++ b/opensearchpy/_async/client/client.py @@ -22,7 +22,7 @@ def __init__( self, hosts: Optional[str] = None, transport_class: Type[Transport] = Transport, - **kwargs: Any + **kwargs: Any, ) -> None: """ :arg hosts: list of nodes, or a single node, we should connect to. diff --git a/opensearchpy/_async/helpers/actions.py b/opensearchpy/_async/helpers/actions.py index 16a080110..c57284c46 100644 --- a/opensearchpy/_async/helpers/actions.py +++ b/opensearchpy/_async/helpers/actions.py @@ -84,7 +84,7 @@ async def _process_bulk_chunk( raise_on_error: bool = True, ignore_status: Any = (), *args: Any, - **kwargs: Any + **kwargs: Any, ) -> AsyncGenerator[Tuple[bool, Any], None]: """ Send a bulk request to opensearch and process the output. @@ -159,7 +159,7 @@ async def async_streaming_bulk( yield_ok: bool = True, ignore_status: Any = (), *args: Any, - **kwargs: Any + **kwargs: Any, ) -> AsyncGenerator[Tuple[bool, Any], None]: """ Streaming bulk consumes actions from the iterable passed in and yields @@ -261,7 +261,7 @@ async def async_bulk( stats_only: bool = False, ignore_status: Optional[Union[int, Collection[int]]] = (), *args: Any, - **kwargs: Any + **kwargs: Any, ) -> Tuple[int, Union[int, List[Any]]]: """ Helper for the :meth:`~opensearchpy.AsyncOpenSearch.bulk` api that provides @@ -322,7 +322,7 @@ async def async_scan( request_timeout: Any = None, clear_scroll: bool = True, scroll_kwargs: Any = None, - **kwargs: Any + **kwargs: Any, ) -> Any: """ Simple abstraction on top of the diff --git a/opensearchpy/_async/helpers/index.py b/opensearchpy/_async/helpers/index.py index 68da05333..3912f0520 100644 --- a/opensearchpy/_async/helpers/index.py +++ b/opensearchpy/_async/helpers/index.py @@ -25,7 +25,7 @@ def __init__( template: Any, index: Any = None, order: Any = None, - **kwargs: Any + **kwargs: Any, ) -> None: if index is None: self._index = AsyncIndex(template, **kwargs) diff --git a/opensearchpy/_async/transport.py b/opensearchpy/_async/transport.py index 70ad43d83..2cbfc2725 100644 --- a/opensearchpy/_async/transport.py +++ b/opensearchpy/_async/transport.py @@ -78,7 +78,7 @@ def __init__( retry_on_status: Any = (502, 503, 504), retry_on_timeout: bool = False, send_get_body_as: str = "GET", - **kwargs: Any + **kwargs: Any, ) -> None: """ :arg hosts: list of dictionaries, each containing keyword arguments to @@ -141,7 +141,7 @@ def __init__( retry_on_status=retry_on_status, retry_on_timeout=retry_on_timeout, send_get_body_as=send_get_body_as, - **kwargs + **kwargs, ) # Since we defer connections / sniffing to not occur diff --git a/opensearchpy/client/client.py b/opensearchpy/client/client.py index 408073602..96040e93d 100644 --- a/opensearchpy/client/client.py +++ b/opensearchpy/client/client.py @@ -22,7 +22,7 @@ def __init__( self, hosts: Optional[str] = None, transport_class: Type[Transport] = Transport, - **kwargs: Any + **kwargs: Any, ) -> None: """ :arg hosts: list of nodes, or a single node, we should connect to. diff --git a/opensearchpy/helpers/faceted_search.py b/opensearchpy/helpers/faceted_search.py index 42c9b751c..520ec8fe0 100644 --- a/opensearchpy/helpers/faceted_search.py +++ b/opensearchpy/helpers/faceted_search.py @@ -171,7 +171,7 @@ def get_value_filter(self, filter_value: Any) -> Any: "gte": filter_value, "lt": filter_value + self._params["interval"], } - } + }, ) @@ -244,7 +244,7 @@ def get_value_filter(self, filter_value: Any) -> Any: filter_value ), } - } + }, ) diff --git a/opensearchpy/helpers/index.py b/opensearchpy/helpers/index.py index bb1569a49..8359415e6 100644 --- a/opensearchpy/helpers/index.py +++ b/opensearchpy/helpers/index.py @@ -44,7 +44,7 @@ def __init__( template: Any, index: Any = None, order: Any = None, - **kwargs: Any + **kwargs: Any, ) -> None: if index is None: self._index = Index(template, **kwargs) diff --git a/opensearchpy/transport.py b/opensearchpy/transport.py index 559d03873..17853eb8b 100644 --- a/opensearchpy/transport.py +++ b/opensearchpy/transport.py @@ -116,7 +116,7 @@ def __init__( retry_on_timeout: bool = False, send_get_body_as: str = "GET", metrics: Metrics = MetricsNone(), - **kwargs: Any + **kwargs: Any, ) -> None: """ :arg hosts: list of dictionaries, each containing keyword arguments to diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..08e9d9991 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,110 @@ +[build-system] +requires = ["setuptools==71.1.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "opensearch-py" +description = "Python client for OpenSearch" +readme = "README.md" +requires-python = ">=3.8,<4" +license = { text = "Apache-2.0" } +authors = [ + { name = "Aleksei Atavin", email = "axeo@aiven.io" }, + { name = "Denis Zalevskiy", email = "dez@aiven.io" }, + { name = "Rushi Agrawal", email = "rushi.agr@gmail.com" }, + { name = "Shephali Mittal", email = "shephalm@amazon.com" }, +] +maintainers = [ + { name = "Aleksei Atavin", email = "axeo@aiven.io" }, + { name = "Denis Zalevskiy", email = "dez@aiven.io" }, + { name = "Rushi Agrawal", email = "rushi.agr@gmail.com" }, + { name = "Shephali Mittal", email = "shephalm@amazon.com" }, +] +dynamic = ["version"] + +classifiers = [ + "Development Status :: 5 - Production/Stable", + "License :: OSI Approved :: Apache Software License", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] + +dependencies = [ + 'urllib3>=1.26.19,<1.27; python_version < "3.10"', + 'urllib3>=1.26.19,!=2.2.0,!=2.2.1,<3; python_version >= "3.10"', + "requests>=2.32.0,<3.0.0", + "python-dateutil", + "certifi>=2024.07.04", + "Events", +] + +[project.optional-dependencies] +tests = [ + "requests>=2.0.0,<3.0.0", + "coverage<8.0.0", + "pyyaml", + "pytest>=3.0.0", + "pytest-cov", + "pytz", + "botocore", + "pytest-mock<4.0.0", +] +async = [ + "aiohttp>=3.10.11,<4", +] +docs = [ + "sphinx", + "sphinx_rtd_theme", + "myst_parser", + "sphinx_copybutton", + # re-add async dependencies + "aiohttp>=3.10.11,<4", +] +develop = [ + "black>=24.3.0", + "jinja2", + # re-add tests dependencies + "requests>=2.0.0,<3.0.0", + "coverage<8.0.0", + "pyyaml", + "pytest>=3.0.0", + "pytest-cov", + "pytz", + "botocore", + "pytest-mock<4.0.0", + # re-add docs dependencies + "sphinx", + "sphinx_rtd_theme", + "myst_parser", + "sphinx_copybutton", + # re-add async dependencies + "aiohttp>=3.10.11,<4", +] +kerberos = ["requests_kerberos"] + +[project.urls] +Documentation = "https://opensearch.org/docs/clients/python" +Source = "https://github.com/opensearch-project/opensearch-py" +"Issue Tracker" = "https://github.com/opensearch-project/opensearch-py/issues" + +[tool.setuptools] +zip-safe = false + +[tool.setuptools.package-data] +"opensearchpy" = ["py.typed"] + +[tool.setuptools.dynamic] +version = { attr = "opensearchpy._version.__versionstr__" } + +[tool.setuptools.packages.find] +where = ["."] +include = ["opensearchpy*"] +exclude = ["test_opensearchpy*"] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 3bf5300d0..000000000 --- a/setup.cfg +++ /dev/null @@ -1,20 +0,0 @@ -[bdist_rpm] -requires = python python-urllib3 - -[flake8] -ignore = E203, E266, E501, W503 -max-line-length = 240 - -[tool:pytest] -junit_family=legacy -asyncio_mode=auto - -[isort] -profile=black - -[black] -max-line-length = 240 -target-version = 'py38' - -[mypy] -ignore_missing_imports=True diff --git a/setup.py b/setup.py deleted file mode 100644 index f0b897bb7..000000000 --- a/setup.py +++ /dev/null @@ -1,125 +0,0 @@ -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. -# -# Modifications Copyright OpenSearch Contributors. See -# GitHub history for details. -# -# Licensed to Elasticsearch B.V. under one or more contributor -# license agreements. See the NOTICE file distributed with -# this work for additional information regarding copyright -# ownership. Elasticsearch B.V. licenses this file to you under -# the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - - -import re -from os.path import abspath, dirname, join - -from setuptools import find_packages, setup - -PACKAGE_NAME = "opensearch-py" -PACKAGE_VERSION = "" -BASE_DIR = abspath(dirname(__file__)) - -with open( - join(BASE_DIR, PACKAGE_NAME.replace("-", ""), "_version.py"), encoding="utf-8" -) as f: - data = f.read() - m = re.search(r"^__versionstr__: str\s+=\s+[\"\']([^\"\']+)[\"\']", data, re.M) - if m: - PACKAGE_VERSION = m.group(1) - else: - raise Exception(f"Invalid version: {data}") - -with open(join(BASE_DIR, "README.md"), encoding="utf-8") as f: - long_description = f.read().strip() - -MODULE_DIR = PACKAGE_NAME.replace("-", "") -packages = [ - package - for package in find_packages(where=".", exclude=("test_opensearchpy*",)) - if package == MODULE_DIR or package.startswith(MODULE_DIR + ".") -] -install_requires = [ - 'urllib3>=1.26.19,<1.27 ; python_version < "3.10"', - 'urllib3>=1.26.19,!=2.2.0,!=2.2.1,<3 ; python_version >= "3.10"', - "requests>=2.32.0, <3.0.0", - "python-dateutil", - "certifi>=2024.07.04", - "Events", -] -tests_require = [ - "requests>=2.0.0, <3.0.0", - "coverage<8.0.0", - "pyyaml", - "pytest>=3.0.0", - "pytest-cov", - "pytz", - "botocore", - "pytest-mock<4.0.0", -] - -async_require = ["aiohttp>=3.10.11,<4"] - -docs_require = ["sphinx", "sphinx_rtd_theme", "myst_parser", "sphinx_copybutton"] -generate_require = ["black>=24.3.0", "jinja2"] - -setup( - name=PACKAGE_NAME, - description="Python client for OpenSearch", - license="Apache-2.0", - url="https://github.com/opensearch-project/opensearch-py", - long_description=long_description, - long_description_content_type="text/markdown", - version=PACKAGE_VERSION, - author="Aleksei Atavin, Denis Zalevskiy, Rushi Agrawal, Shephali Mittal", - author_email="axeo@aiven.io, dez@aiven.io, rushi.agr@gmail.com, shephalm@amazon.com", - maintainer="Aleksei Atavin, Denis Zalevskiy, Rushi Agrawal, Shephali Mittal", - maintainer_email="axeo@aiven.io, dez@aiven.io, rushi.agr@gmail.com, shephalm@amazon.com", - project_urls={ - "Documentation": "https://opensearch.org/docs/clients/python", - "Source Code": "https://github.com/opensearch-project/opensearch-py", - "Issue Tracker": "https://github.com/opensearch-project/opensearch-py/issues", - }, - packages=packages, - package_data={"opensearchpy": ["py.typed"]}, - include_package_data=True, - zip_safe=False, - classifiers=[ - "Development Status :: 5 - Production/Stable", - "License :: OSI Approved :: Apache Software License", - "Intended Audience :: Developers", - "Operating System :: OS Independent", - "Programming Language :: Python", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], - python_requires=">=3.8, <4", - install_requires=install_requires, - test_suite="test_opensearchpy.run_tests.run_all", - tests_require=tests_require, - extras_require={ - "develop": tests_require + docs_require + generate_require, - "docs": docs_require + async_require, - "async": async_require, - "kerberos": ["requests_kerberos"], - }, -) diff --git a/test_opensearchpy/run_tests.py b/test_opensearchpy/run_tests.py index a9f01b7b4..0efdf18d3 100755 --- a/test_opensearchpy/run_tests.py +++ b/test_opensearchpy/run_tests.py @@ -63,12 +63,13 @@ def fetch_opensearch_repo() -> None: if environ.get("TEST_OPENSEARCH_NOFETCH", False): return - from test_opensearchpy.test_cases import SkipTest - from test_opensearchpy.test_server import get_client + from unittest import SkipTest + + from opensearchpy.helpers import test # find out the sha of the running client try: - client = get_client() + client = test.get_test_client() sha = client.info()["version"]["build_hash"] except (SkipTest, KeyError): print("No running opensearch >1.X server...") @@ -123,7 +124,7 @@ def run_all(argv: Any = None) -> None: fetch_opensearch_repo() # always insert coverage when running tests - if argv is None: + if argv is None or (argv and "run_tests.py" in argv[0]): junit_xml = join( abspath(dirname(dirname(__file__))), "junit", "opensearch-py-junit.xml" ) diff --git a/test_opensearchpy/test_async/test_helpers/test_document.py b/test_opensearchpy/test_async/test_helpers/test_document.py index 51fb5f30f..db94ef776 100644 --- a/test_opensearchpy/test_async/test_helpers/test_document.py +++ b/test_opensearchpy/test_async/test_helpers/test_document.py @@ -238,9 +238,9 @@ async def test_custom_field_in_nested() -> None: async def test_multi_works_after_doc_has_been_saved() -> None: c = SimpleCommit() c.full_clean() - c.files.append("setup.py") + c.files.append("pyproject.toml") - assert c.to_dict() == {"files": ["setup.py"]} + assert c.to_dict() == {"files": ["pyproject.toml"]} async def test_multi_works_in_nested_after_doc_has_been_serialized() -> None: diff --git a/test_opensearchpy/test_async/test_server/test_helpers/test_data.py b/test_opensearchpy/test_async/test_server/test_helpers/test_data.py index 61a70cca8..7ba5788a5 100644 --- a/test_opensearchpy/test_async/test_server/test_helpers/test_data.py +++ b/test_opensearchpy/test_async/test_server/test_helpers/test_data.py @@ -979,7 +979,7 @@ async def create_git_index(client: Any, index: Any) -> None: "commit_repo": {"name": "commit", "parent": "opensearch-py"}, "files": [ "opensearchpy/query.py", - "setup.py", + "pyproject.toml", "test_opensearchpy/test_dsl/test_query.py", ], "committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"}, @@ -1043,7 +1043,7 @@ async def create_git_index(client: Any, index: Any) -> None: "files": [ "opensearchpy/__init__.py", "test_opensearchpy/test_dsl/run_tests.py", - "setup.py", + "pyproject.toml", "README.rst", "test_opensearchpy/test_dsl/__init__.py", ], diff --git a/test_opensearchpy/test_helpers/test_document.py b/test_opensearchpy/test_helpers/test_document.py index b261e54e3..3bedeba23 100644 --- a/test_opensearchpy/test_helpers/test_document.py +++ b/test_opensearchpy/test_helpers/test_document.py @@ -248,9 +248,9 @@ def test_custom_field_in_nested() -> None: def test_multi_works_after_doc_has_been_saved() -> None: c: Any = SimpleCommit() c.full_clean() - c.files.append("setup.py") + c.files.append("pyproject.toml") - assert c.to_dict() == {"files": ["setup.py"]} + assert c.to_dict() == {"files": ["pyproject.toml"]} def test_multi_works_in_nested_after_doc_has_been_serialized() -> None: diff --git a/test_opensearchpy/test_server/test_helpers/test_data.py b/test_opensearchpy/test_server/test_helpers/test_data.py index d3d357ab8..e7ff5bbd6 100644 --- a/test_opensearchpy/test_server/test_helpers/test_data.py +++ b/test_opensearchpy/test_server/test_helpers/test_data.py @@ -996,7 +996,7 @@ def create_git_index(client: Any, index: Any) -> None: "commit_repo": {"name": "commit", "parent": "opensearch-py"}, "files": [ "opensearchpy/query.py", - "setup.py", + "pyproject.toml", "test_opensearchpy/test_dsl/test_query.py", ], "committer": {"name": "Honza Kr\xe1l", "email": "honza.kral@gmail.com"}, @@ -1060,7 +1060,7 @@ def create_git_index(client: Any, index: Any) -> None: "files": [ "opensearchpy/__init__.py", "test_opensearchpy/test_dsl/run_tests.py", - "setup.py", + "pyproject.toml", "README.rst", "test_opensearchpy/test_dsl/__init__.py", ], diff --git a/utils/build_dists.py b/utils/build_dists.py index c11459587..524f27c49 100644 --- a/utils/build_dists.py +++ b/utils/build_dists.py @@ -27,7 +27,7 @@ """A command line tool for building and verifying releases Can be used for building both 'opensearchpy' and 'opensearchpyX' dists. -Only requires 'name' in 'setup.py' and the directory to be changed. +Only requires 'name' in 'pyproject.toml' and the directory to be changed. """ import contextlib @@ -58,7 +58,7 @@ def set_tmp_dir() -> None: # type: ignore def run(*argv: Any, expect_exit_code: int = 0) -> None: """ runs a command within this script - :param argv: command to run e.g. "git" "checkout" "--" "setup.py" "opensearchpy/" + :param argv: command to run e.g. "git" "checkout" "--" "pyproject.toml" "opensearchpy/" :param expect_exit_code: code to compare with actual exit code from command. will exit the process if they do not match the proper exit code @@ -200,9 +200,9 @@ def main() -> None: Notes: does not run on MacOS; this script is generally driven by a GitHub Action located in .github/workflows/unified-release.yml """ - run("git", "checkout", "--", "setup.py", "opensearchpy/") + run("git", "checkout", "--", "pyproject.toml", "opensearchpy/") run("rm", "-rf", "build/", "dist/*", "*.egg-info", ".eggs") - run("python", "setup.py", "sdist", "bdist_wheel") + run("pyproject-build") # Grab the major version to be used as a suffix. version_path = os.path.join(BASE_DIR, "opensearchpy/_version.py") @@ -286,25 +286,25 @@ def main() -> None: file.truncate() file.write(version_data) - # Rewrite setup.py with the new name. - setup_py_path = os.path.join(BASE_DIR, "setup.py") + # Rewrite pyproject.toml with the new name. + setup_py_path = os.path.join(BASE_DIR, "pyproject.toml") with open(setup_py_path, encoding="utf-8") as file: setup_py = file.read() with open(setup_py_path, "w", encoding="utf-8") as file: file.truncate() - assert 'PACKAGE_NAME = "opensearch-py"' in setup_py + assert 'name = "opensearch-py"' in setup_py file.write( setup_py.replace( - 'PACKAGE_NAME = "opensearch-py"', - f'PACKAGE_NAME = "opensearch-py{suffix}"', + 'name = "opensearch-py"', + f'name = "opensearch-py{suffix}"', ) ) # Build the sdist/wheels - run("python", "setup.py", "sdist", "bdist_wheel") + run("pyproject-build") # Clean up everything. - run("git", "checkout", "--", "setup.py", "opensearchpy/") + run("git", "checkout", "--", "pyproject.toml", "opensearchpy/") if suffix: run("rm", "-rf", f"opensearchpy{suffix}/")