Skip to content

Commit

Permalink
Move most metadata to pyproject.toml (#1045)
Browse files Browse the repository at this point in the history
Catch up with the times.
  • Loading branch information
elprans committed Jul 6, 2023
1 parent 83c1159 commit faa94d1
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Expand Up @@ -152,7 +152,7 @@ jobs:

- name: Build docs
run: |
pip install -e .[dev]
pip install -e .[docs]
make htmldocs
- name: Checkout gh-pages
Expand Down
15 changes: 7 additions & 8 deletions Makefile
Expand Up @@ -20,27 +20,26 @@ 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:
cd "$${HOME}" && $(PYTHON) $(ROOT)/tests/__init__.py


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
17 changes: 9 additions & 8 deletions asyncpg/connection.py
Expand Up @@ -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.
Expand Down
14 changes: 1 addition & 13 deletions docs/conf.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3

import alabaster
import os
import sys

Expand Down Expand Up @@ -39,7 +38,7 @@
copyright = '2016-present, the asyncpg authors and contributors'
author = '<See AUTHORS file>'
release = version
language = None
language = "en"
exclude_patterns = ['_build']
pygments_style = 'sphinx'
todo_include_todos = False
Expand All @@ -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']
Expand All @@ -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'


Expand Down
5 changes: 3 additions & 2 deletions 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
Expand Down
63 changes: 62 additions & 1 deletion 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"
Expand Down
78 changes: 16 additions & 62 deletions setup.py
Expand Up @@ -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 = []

Expand Down Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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",
Expand All @@ -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,
)

0 comments on commit faa94d1

Please sign in to comment.