diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 5dd6687..49dfd7a 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -8,18 +8,16 @@ ARG BUILDER_GID=1000 ENV BUILDER_USER elastic ENV BUILDER_GROUP elastic +WORKDIR /code/elasticsearch-serverless-python + # Create user RUN groupadd --system -g ${BUILDER_GID} ${BUILDER_GROUP} \ && useradd --system --shell /bin/bash -u ${BUILDER_UID} -g ${BUILDER_GROUP} -d /var/lib/elastic -m elastic 1>/dev/null 2>/dev/null \ - && mkdir -p /code/elasticsearch-py && mkdir /code/elasticsearch-py/build \ + && mkdir /code/elasticsearch-serverless-python/build \ && chown -R ${BUILDER_USER}:${BUILDER_GROUP} /code/ -COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . -WORKDIR /code/elasticsearch-py USER ${BUILDER_USER}:${BUILDER_GROUP} -COPY dev-requirements.txt . +COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . RUN python -m pip install \ -U --no-cache-dir \ --disable-pip-version-check \ - nox -rdev-requirements.txt -COPY --chown=$BUILDER_USER:$BUILDER_GROUP . . -RUN python -m pip install -U -e . + .[dev] diff --git a/.ci/make.sh b/.ci/make.sh index 7b0d227..0850858 100755 --- a/.ci/make.sh +++ b/.ci/make.sh @@ -152,12 +152,7 @@ if [[ "$CMD" == "assemble" ]]; then fi if [[ "$CMD" == "bump" ]]; then - docker run \ - --rm -v $repo:/code/elasticsearch-serverless-python \ - $product \ - /bin/bash -c "python /code/elasticsearch-serverless-python/utils/bump-version.py $VERSION" - - exit 0 + echo "TODO" fi if [[ "$CMD" == "codegen" ]]; then diff --git a/.readthedocs.yml b/.readthedocs.yml index 9a0b445..bde08ba 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,9 +1,15 @@ +--- version: 2 sphinx: configuration: docs/sphinx/conf.py +build: + os: ubuntu-22.04 + tools: + python: "3.10" + python: - version: "3.7" install: - - requirements: dev-requirements.txt - path: . + extra_requirements: + - "docs" diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 5069744..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,14 +0,0 @@ -include CONTRIBUTING.md -include LICENSE -include MANIFEST.in -include README.rst -include NOTICE -include CHANGELOG.md -include setup.py -recursive-include elasticsearch_serverless* py.typed *.pyi -recursive-include docs/sphinx * - -prune docs/sphinx/_build -prune test_elasticsearch_serverless -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index f8360eb..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,24 +0,0 @@ -elastic-transport>=8.0.0b1, <9 -requests>=2, <3 -aiohttp -pytest -pytest-cov -pytest-asyncio -coverage -sphinx -jinja2 -python-dateutil -unasync -pyyaml>=5.4 -isort -black -twine -build -nox - -# No wheels for Python 3.10 yet! -numpy; python_version<"3.10" -pandas; python_version<"3.10" - -# Testing the 'search_mvt' API response -mapbox-vector-tile; python_version<"3.10" diff --git a/docs/sphinx/api.rst b/docs/sphinx/api.rst index 60fc550..e989557 100644 --- a/docs/sphinx/api.rst +++ b/docs/sphinx/api.rst @@ -17,12 +17,12 @@ arguments are required for all Elasticsearch ------------- -.. py:module:: elasticsearch +.. py:module:: elasticsearch_serverless .. autoclass:: Elasticsearch :members: -.. py:module:: elasticsearch.client +.. py:module:: elasticsearch_serverless.client Async Search ------------ diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 3ef4f44..be1274a 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -35,7 +35,7 @@ master_doc = "index" # General information about the project. -project = "Python Elasticsearch client" +project = "Python Elasticsearch Serverless client" copyright = "%d, Elasticsearch B.V" % datetime.date.today().year version = elasticsearch_serverless.__versionstr__ diff --git a/docs/sphinx/exceptions.rst b/docs/sphinx/exceptions.rst index 32c01d6..914c64b 100644 --- a/docs/sphinx/exceptions.rst +++ b/docs/sphinx/exceptions.rst @@ -3,7 +3,7 @@ Exceptions & Warnings ===================== -.. py:module:: elasticsearch +.. py:module:: elasticsearch_serverless API Errors ---------- diff --git a/docs/sphinx/index.rst b/docs/sphinx/index.rst index db23a87..96b8dda 100644 --- a/docs/sphinx/index.rst +++ b/docs/sphinx/index.rst @@ -1,7 +1,7 @@ -Python Elasticsearch Client -=========================== +Python Elasticsearch Serverless Client +====================================== -Official low-level client for Elasticsearch. Its goal is to provide common +Official low-level client for Elasticsearch Serverless. Its goal is to provide common ground for all Elasticsearch-related code in Python; because of this it tries to be opinion-free and very extendable. diff --git a/noxfile.py b/noxfile.py index 31e3cba..fa9e23e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -22,7 +22,6 @@ SOURCE_DIR = os.path.dirname(os.path.abspath(__file__)) SOURCE_FILES = ( "docs/sphinx/conf.py", - "setup.py", "noxfile.py", "elasticsearch_serverless/", "test_elasticsearch_serverless/", @@ -32,8 +31,7 @@ @nox.session(python=["3.7", "3.8", "3.9", "3.10", "3.11"]) def test(session): - session.install(".") - session.install("-r", "dev-requirements.txt") + session.install(".[dev]") junit_xml = os.path.join( SOURCE_DIR, "junit", "elasticsearch-serverless-python-junit.xml" @@ -106,10 +104,5 @@ def lint(session): @nox.session() def docs(session): - session.install( - "-rdev-requirements.txt", "sphinx-rtd-theme", "sphinx-autodoc-typehints" - ) - session.install(".") - session.run("python", "-m", "pip", "install", "sphinx-autodoc-typehints") - + session.install(".[docs]") session.run("sphinx-build", "docs/sphinx/", "docs/sphinx/_build", "-b", "html") diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..80ef924 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,111 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "elasticsearch-serverless" +version = "0.1.0" +description = "Python client for Elasticsearch Serverless" +readme = "README.rst" +license = "Apache-2.0" +requires-python = ">=3.7, <4" +authors = [ + { name = "Elastic Clients Team", email = "clients-team@elastic.co" }, +] +maintainers = [ + { name = "Elastic Clients Team", email = "clients-team@elastic.co" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +keywords = [ + "elasticsearch", + "elastic", + "kibana", + "mapping", + "REST", + "search", + "client", + "index", +] +dependencies = [ + "elastic-transport>=8,<9", +] + +[project.optional-dependencies] +async = [ + "aiohttp>=3,<4", +] +requests = [ + "requests>=2.4.0, <3.0.0", +] +dev = [ + "requests>=2, <3", + "aiohttp", + "pytest", + "pytest-cov", + "pytest-asyncio", + "coverage", + "jinja2", + "python-dateutil", + "unasync", + "pyyaml>=5.4", + "isort", + "black", + "twine", + "build", + "nox", + "numpy", + "pandas", + "mapbox-vector-tile", +] +docs = [ + "sphinx-rtd-theme>=1.2.2", + "sphinx-autodoc-typehints", + "sphinx==6.2.1", +] + +[project.urls] +Documentation = "https://elasticsearch-serverless-python.readthedocs.io" +Homepage = "https://github.com/elastic/elasticsearch-serverless-python" +"Issue Tracker" = "https://github.com/elastic/elasticsearch-serverless-python/issues" +"Source Code" = "https://github.com/elastic/elasticsearch-serverless-python" + +[tool.hatch.build.targets.sdist] +include = [ + "/elasticsearch_serverless", + "/CHANGELOG.md", + "/CONTRIBUTING.md", + "/LICENSE", + "/NOTICE", + "/README.rst", + "/setup.cfg", + "/docs/sphinx", +] + +[tool.pytest] +junit_family = "legacy" +addopts = "-vvv -p no:logging --cov-report=term-missing --cov=elasticsearch_serverless --cov-config=.pyproject.toml" + +[tool.isort] +profile = "black" + +[tool.coverage.report] +exclude_lines = [ + "raise NotImplementedError*", +] + +[tool.mypy] +ignore_missing_imports = true diff --git a/setup.cfg b/setup.cfg index a527b5b..403f26a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,16 +1,2 @@ [flake8] ignore = E203, E266, E501, W503 - -[tool:pytest] -junit_family=legacy -addopts = -vvv -p no:logging --cov-report=term-missing --cov=elasticsearch --cov-config=.coveragerc - -[tool:isort] -profile=black - -[report] -exclude_lines= - raise NotImplementedError* - -[mypy] -ignore_missing_imports = True diff --git a/setup.py b/setup.py deleted file mode 100644 index 738c195..0000000 --- a/setup.py +++ /dev/null @@ -1,99 +0,0 @@ -# -*- coding: utf-8 -*- -# 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 = "elasticsearch_serverless" -base_dir = abspath(dirname(__file__)) - -with open(join(base_dir, package_name, "_version.py")) as f: - package_version = re.search( - r"__versionstr__\s+=\s+[\"\']([^\"\']+)[\"\']", f.read() - ).group(1) - -with open(join(base_dir, "README.rst")) as f: - # Remove reST raw directive from README as they're not allowed on PyPI - # Those blocks start with a newline and continue until the next newline - mode = None - lines = [] - for line in f: - if line.startswith(".. raw::"): - mode = "ignore_nl" - elif line == "\n": - mode = "wait_nl" if mode == "ignore_nl" else None - if mode is None: - lines.append(line) - - long_description = "".join(lines) - - -packages = [ - package - for package in find_packages(where=".", exclude=("test_elasticsearch_serverless*",)) - if package == package_name or package.startswith(package_name + ".") -] - -install_requires = ["elastic-transport>=8,<9"] -async_requires = ["aiohttp>=3,<4"] - -setup( - name=package_name, - description="Python client for Elasticsearch Serverless", - license="Apache-2.0", - url="https://github.com/elastic/elasticsearch-serverless-python", - long_description=long_description, - long_description_content_type="text/x-rst", - version=package_version, - author="Josh Mock", - author_email="joshua.mock@elastic.co", - maintainer="Josh Mock", - maintainer_email="joshua.mock@elastic.co", - project_urls={ - "Documentation": "https://elasticsearch-serverless-python.readthedocs.io", - "Source Code": "https://github.com/elastic/elasticsearch-serverless-python", - "Issue Tracker": "https://github.com/elastic/elasticsearch-serverless-python/issues", - }, - packages=packages, - package_data={"elasticsearch_serverless": ["py.typed", "*.pyi"]}, - 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", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - ], - python_requires=">=3.7, <4", - install_requires=install_requires, - extras_require={ - "requests": ["requests>=2.4.0, <3.0.0"], - "async": async_requires, - }, -) diff --git a/utils/bump-version.py b/utils/bump-version.py deleted file mode 100644 index a5ff868..0000000 --- a/utils/bump-version.py +++ /dev/null @@ -1,85 +0,0 @@ -# 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. - -"""Command line tool which changes the branch to be -ready to build and test the given Elastic stack version. -""" - -import re -import sys -from pathlib import Path - -SOURCE_DIR = Path(__file__).absolute().parent.parent - - -def find_and_replace(path, pattern, replace): - # Does a find and replace within a file path and complains - # if the given pattern isn't found in the file. - with open(path, "r") as f: - old_data = f.read() - - if re.search(pattern, old_data, flags=re.MULTILINE) is None: - print(f"Didn't find the pattern {pattern!r} in {path!s}") - exit(1) - - new_data = re.sub(pattern, replace, old_data, flags=re.MULTILINE) - with open(path, "w") as f: - f.truncate() - f.write(new_data) - - -def main(): - if len(sys.argv) != 2: - print("usage: utils/bump-version.py [stack version]") - exit(1) - - stack_version = sys.argv[1] - try: - python_version = re.search(r"^([0-9][0-9\.]*[0-9]+)", stack_version).group(1) - except AttributeError: - print(f"Couldn't match the given stack version {stack_version!r}") - exit(1) - - # Pad the version value with .0 until there - # we have the major, minor, and patch. - for _ in range(3): - if len(python_version.split(".")) >= 3: - break - python_version += ".0" - - find_and_replace( - path=SOURCE_DIR / "elasticsearch_serverless/_version.py", - pattern=r"__versionstr__ = \"[0-9]+[0-9\.]*[0-9](?:\+dev)?\"", - replace=f'__versionstr__ = "{python_version}"', - ) - - # These values should always be the 'major.minor-SNAPSHOT' - major_minor_version = ".".join(python_version.split(".")[:2]) - find_and_replace( - path=SOURCE_DIR / ".ci/test-matrix.yml", - pattern=r'STACK_VERSION:\s+\- "[0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?"', - replace=f'STACK_VERSION:\n - "{major_minor_version}.0-SNAPSHOT"', - ) - find_and_replace( - path=SOURCE_DIR / ".github/workflows/unified-release.yml", - pattern=r'STACK_VERSION:\s+"[0-9]+[0-9\.]*[0-9](?:\-SNAPSHOT)?"', - replace=f'STACK_VERSION: "{major_minor_version}-SNAPSHOT"', - ) - - -if __name__ == "__main__": - main()