diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1eba94a5..406c3a3c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -152,7 +152,7 @@ jobs: - name: Build docs run: | - pip install -e .[dev] + pip install -e .[docs] make htmldocs - name: Checkout gh-pages diff --git a/Makefile b/Makefile index 7a09181c..67417a3f 100644 --- a/Makefile +++ b/Makefile @@ -20,17 +20,16 @@ clean: compile: - $(PYTHON) setup.py build_ext --inplace --cython-always + env ASYNCPG_BUILD_CYTHON_ALWAYS=1 $(PYTHON) -m pip install -e . debug: - ASYNCPG_DEBUG=1 $(PYTHON) setup.py build_ext --inplace - + env ASYNCPG_DEBUG=1 $(PYTHON) -m pip install -e . test: - PYTHONASYNCIODEBUG=1 $(PYTHON) setup.py test - $(PYTHON) setup.py test - USE_UVLOOP=1 $(PYTHON) setup.py test + PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest -v tests.suite + $(PYTHON) -m unittest -v tests.suite + USE_UVLOOP=1 $(PYTHON) -m unittest -v tests.suite testinstalled: @@ -38,9 +37,9 @@ testinstalled: quicktest: - $(PYTHON) setup.py test + $(PYTHON) -m unittest -v tests.suite htmldocs: - $(PYTHON) setup.py build_ext --inplace + $(PYTHON) -m pip install -e .[docs] $(MAKE) -C docs html diff --git a/asyncpg/connection.py b/asyncpg/connection.py index 0b13d356..d54927cf 100644 --- a/asyncpg/connection.py +++ b/asyncpg/connection.py @@ -2007,14 +2007,15 @@ async def connect(dsn=None, *, :param SessionAttribute target_session_attrs: If specified, check that the host has the correct attribute. Can be one of: - "any": the first successfully connected host - "primary": the host must NOT be in hot standby mode - "standby": the host must be in hot standby mode - "read-write": the host must allow writes - "read-only": the host most NOT allow writes - "prefer-standby": first try to find a standby host, but if - none of the listed hosts is a standby server, - return any of them. + + "any": the first successfully connected host + "primary": the host must NOT be in hot standby mode + "standby": the host must be in hot standby mode + "read-write": the host must allow writes + "read-only": the host most NOT allow writes + "prefer-standby": first try to find a standby host, but if + none of the listed hosts is a standby server, + return any of them. If not specified will try to use PGTARGETSESSIONATTRS from the environment. diff --git a/docs/conf.py b/docs/conf.py index 0ea293b8..cb371299 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,6 +1,5 @@ #!/usr/bin/env python3 -import alabaster import os import sys @@ -39,7 +38,7 @@ copyright = '2016-present, the asyncpg authors and contributors' author = '' release = version -language = None +language = "en" exclude_patterns = ['_build'] pygments_style = 'sphinx' todo_include_todos = False @@ -48,12 +47,6 @@ # -- Options for HTML output ---------------------------------------------- html_theme = 'sphinx_rtd_theme' -# html_theme_options = { -# 'description': 'asyncpg is a fast PostgreSQL client library for the ' -# 'Python asyncio framework', -# 'show_powered_by': False, -# } -html_theme_path = [alabaster.get_path()] html_title = 'asyncpg Documentation' html_short_title = 'asyncpg' html_static_path = ['_static'] @@ -66,11 +59,6 @@ html_show_sourcelink = False html_show_sphinx = False html_show_copyright = True -html_context = { - 'css_files': [ - '_static/theme_overrides.css', - ], -} htmlhelp_basename = 'asyncpgdoc' diff --git a/docs/index.rst b/docs/index.rst index 93671abc..833a7039 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,5 +1,6 @@ -.. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master - :target: https://travis-ci.org/MagicStack/asyncpg +.. image:: https://github.com/MagicStack/asyncpg/workflows/Tests/badge.svg + :target: https://github.com/MagicStack/asyncpg/actions?query=workflow%3ATests+branch%3Amaster + :alt: GitHub Actions status .. image:: https://img.shields.io/pypi/status/asyncpg.svg?maxAge=2592000?style=plastic :target: https://pypi.python.org/pypi/asyncpg diff --git a/pyproject.toml b/pyproject.toml index 71beae87..36540bd0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,68 @@ +[project] +name = "asyncpg" +description = "An asyncio PostgreSQL driver" +authors = [{name = "MagicStack Inc", email = "hello@magic.io"}] +requires-python = '>=3.7.0' +readme = "README.rst" +license = {text = "Apache License, Version 2.0"} +dynamic = ["version"] +keywords = [ + "database", + "postgres", +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Framework :: AsyncIO", + "Intended Audience :: Developers", + "License :: OSI Approved :: Apache Software License", + "Operating System :: POSIX", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Programming Language :: Python :: 3 :: Only", + "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", + "Topic :: Database :: Front-Ends", +] +dependencies = [ + 'typing-extensions>=3.7.4.3;python_version<"3.8"', +] + +[project.urls] +github = "https://github.com/MagicStack/asyncpg" + +[project.optional-dependencies] +test = [ + 'flake8~=5.0.4', + 'uvloop>=0.15.3; platform_system != "Windows"', +] +docs = [ + 'Sphinx~=5.3.0', + 'sphinxcontrib-asyncio~=0.3.0', + 'sphinx_rtd_theme>=1.2.2', +] + [build-system] -requires = ["setuptools>=42", "wheel"] +requires = [ + "setuptools>=60", + "wheel", + + "Cython(>=0.29.24,<0.30.0)" +] build-backend = "setuptools.build_meta" +[tool.setuptools] +zip-safe = false + +[tool.setuptools.packages.find] +include = ["asyncpg", "asyncpg.*"] + +[tool.setuptools.exclude-package-data] +"*" = ["*.c", "*.h"] + [tool.cibuildwheel] build-frontend = "build" test-extras = "test" diff --git a/setup.py b/setup.py index af0bcdc3..269e2fd7 100644 --- a/setup.py +++ b/setup.py @@ -27,30 +27,6 @@ CYTHON_DEPENDENCY = 'Cython(>=0.29.24,<0.30.0)' -# Minimal dependencies required to test asyncpg. -TEST_DEPENDENCIES = [ - 'flake8~=5.0.4', - 'uvloop>=0.15.3; platform_system != "Windows"', -] - -# Dependencies required to build documentation. -DOC_DEPENDENCIES = [ - 'Sphinx~=4.1.2', - 'sphinxcontrib-asyncio~=0.3.0', - 'sphinx_rtd_theme~=0.5.2', -] - -EXTRA_DEPENDENCIES = { - 'docs': DOC_DEPENDENCIES, - 'test': TEST_DEPENDENCIES, - # Dependencies required to develop asyncpg. - 'dev': [ - CYTHON_DEPENDENCY, - 'pytest>=6.0', - ] + DOC_DEPENDENCIES + TEST_DEPENDENCIES -} - - CFLAGS = ['-O2'] LDFLAGS = [] @@ -170,6 +146,18 @@ def finalize_options(self): if getattr(self, '_initialized', False): return + if not self.cython_always: + self.cython_always = bool(os.environ.get( + "ASYNCPG_BUILD_CYTHON_ALWAYS")) + + if self.cython_annotate is None: + self.cython_annotate = os.environ.get( + "ASYNCPG_BUILD_CYTHON_ANNOTATE") + + if self.cython_directives is None: + self.cython_directives = os.environ.get( + "ASYNCPG_BUILD_CYTHON_DIRECTIVES") + need_cythonize = self.cython_always cfiles = {} @@ -235,47 +223,16 @@ def finalize_options(self): setup_requires = [] -if (not (_ROOT / 'asyncpg' / 'protocol' / 'protocol.c').exists() or - '--cython-always' in sys.argv): +if ( + not (_ROOT / 'asyncpg' / 'protocol' / 'protocol.c').exists() + or os.environ.get("ASYNCPG_BUILD_CYTHON_ALWAYS") +): # No Cython output, require Cython to build. setup_requires.append(CYTHON_DEPENDENCY) setuptools.setup( - name='asyncpg', version=VERSION, - description='An asyncio PostgreSQL driver', - long_description=readme, - classifiers=[ - 'Development Status :: 5 - Production/Stable', - 'Framework :: AsyncIO', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: Apache Software License', - 'Operating System :: POSIX', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: Implementation :: CPython', - 'Topic :: Database :: Front-Ends', - ], - platforms=['macOS', 'POSIX', 'Windows'], - python_requires='>=3.7.0', - zip_safe=False, - author='MagicStack Inc', - author_email='hello@magic.io', - url='https://github.com/MagicStack/asyncpg', - license='Apache License, Version 2.0', - packages=setuptools.find_packages( - exclude=['tests', 'tools'], - ), - package_data={ - # Cython sources needed for tracebacks - "": ["*.pyx", "*.pxd", "*.pxi"], - }, ext_modules=[ setuptools.extension.Extension( "asyncpg.pgproto.pgproto", @@ -291,9 +248,6 @@ def finalize_options(self): extra_compile_args=CFLAGS, extra_link_args=LDFLAGS), ], - install_requires=['typing-extensions>=3.7.4.3;python_version<"3.8"'], cmdclass={'build_ext': build_ext, 'build_py': build_py, 'sdist': sdist}, - test_suite='tests.suite', - extras_require=EXTRA_DEPENDENCIES, setup_requires=setup_requires, )