Skip to content

Commit faa94d1

Browse files
authored
Move most metadata to pyproject.toml (#1045)
Catch up with the times.
1 parent 83c1159 commit faa94d1

File tree

7 files changed

+99
-95
lines changed

7 files changed

+99
-95
lines changed

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ jobs:
152152

153153
- name: Build docs
154154
run: |
155-
pip install -e .[dev]
155+
pip install -e .[docs]
156156
make htmldocs
157157
158158
- name: Checkout gh-pages

Makefile

+7-8
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,26 @@ clean:
2020

2121

2222
compile:
23-
$(PYTHON) setup.py build_ext --inplace --cython-always
23+
env ASYNCPG_BUILD_CYTHON_ALWAYS=1 $(PYTHON) -m pip install -e .
2424

2525

2626
debug:
27-
ASYNCPG_DEBUG=1 $(PYTHON) setup.py build_ext --inplace
28-
27+
env ASYNCPG_DEBUG=1 $(PYTHON) -m pip install -e .
2928

3029
test:
31-
PYTHONASYNCIODEBUG=1 $(PYTHON) setup.py test
32-
$(PYTHON) setup.py test
33-
USE_UVLOOP=1 $(PYTHON) setup.py test
30+
PYTHONASYNCIODEBUG=1 $(PYTHON) -m unittest -v tests.suite
31+
$(PYTHON) -m unittest -v tests.suite
32+
USE_UVLOOP=1 $(PYTHON) -m unittest -v tests.suite
3433

3534

3635
testinstalled:
3736
cd "$${HOME}" && $(PYTHON) $(ROOT)/tests/__init__.py
3837

3938

4039
quicktest:
41-
$(PYTHON) setup.py test
40+
$(PYTHON) -m unittest -v tests.suite
4241

4342

4443
htmldocs:
45-
$(PYTHON) setup.py build_ext --inplace
44+
$(PYTHON) -m pip install -e .[docs]
4645
$(MAKE) -C docs html

asyncpg/connection.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -2007,14 +2007,15 @@ async def connect(dsn=None, *,
20072007
:param SessionAttribute target_session_attrs:
20082008
If specified, check that the host has the correct attribute.
20092009
Can be one of:
2010-
"any": the first successfully connected host
2011-
"primary": the host must NOT be in hot standby mode
2012-
"standby": the host must be in hot standby mode
2013-
"read-write": the host must allow writes
2014-
"read-only": the host most NOT allow writes
2015-
"prefer-standby": first try to find a standby host, but if
2016-
none of the listed hosts is a standby server,
2017-
return any of them.
2010+
2011+
"any": the first successfully connected host
2012+
"primary": the host must NOT be in hot standby mode
2013+
"standby": the host must be in hot standby mode
2014+
"read-write": the host must allow writes
2015+
"read-only": the host most NOT allow writes
2016+
"prefer-standby": first try to find a standby host, but if
2017+
none of the listed hosts is a standby server,
2018+
return any of them.
20182019
20192020
If not specified will try to use PGTARGETSESSIONATTRS
20202021
from the environment.

docs/conf.py

+1-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python3
22

3-
import alabaster
43
import os
54
import sys
65

@@ -39,7 +38,7 @@
3938
copyright = '2016-present, the asyncpg authors and contributors'
4039
author = '<See AUTHORS file>'
4140
release = version
42-
language = None
41+
language = "en"
4342
exclude_patterns = ['_build']
4443
pygments_style = 'sphinx'
4544
todo_include_todos = False
@@ -48,12 +47,6 @@
4847
# -- Options for HTML output ----------------------------------------------
4948

5049
html_theme = 'sphinx_rtd_theme'
51-
# html_theme_options = {
52-
# 'description': 'asyncpg is a fast PostgreSQL client library for the '
53-
# 'Python asyncio framework',
54-
# 'show_powered_by': False,
55-
# }
56-
html_theme_path = [alabaster.get_path()]
5750
html_title = 'asyncpg Documentation'
5851
html_short_title = 'asyncpg'
5952
html_static_path = ['_static']
@@ -66,11 +59,6 @@
6659
html_show_sourcelink = False
6760
html_show_sphinx = False
6861
html_show_copyright = True
69-
html_context = {
70-
'css_files': [
71-
'_static/theme_overrides.css',
72-
],
73-
}
7462
htmlhelp_basename = 'asyncpgdoc'
7563

7664

docs/index.rst

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
.. image:: https://travis-ci.org/MagicStack/asyncpg.svg?branch=master
2-
:target: https://travis-ci.org/MagicStack/asyncpg
1+
.. image:: https://github.com/MagicStack/asyncpg/workflows/Tests/badge.svg
2+
:target: https://github.com/MagicStack/asyncpg/actions?query=workflow%3ATests+branch%3Amaster
3+
:alt: GitHub Actions status
34

45
.. image:: https://img.shields.io/pypi/status/asyncpg.svg?maxAge=2592000?style=plastic
56
:target: https://pypi.python.org/pypi/asyncpg

pyproject.toml

+62-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,68 @@
1+
[project]
2+
name = "asyncpg"
3+
description = "An asyncio PostgreSQL driver"
4+
authors = [{name = "MagicStack Inc", email = "[email protected]"}]
5+
requires-python = '>=3.7.0'
6+
readme = "README.rst"
7+
license = {text = "Apache License, Version 2.0"}
8+
dynamic = ["version"]
9+
keywords = [
10+
"database",
11+
"postgres",
12+
]
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
"Framework :: AsyncIO",
16+
"Intended Audience :: Developers",
17+
"License :: OSI Approved :: Apache Software License",
18+
"Operating System :: POSIX",
19+
"Operating System :: MacOS :: MacOS X",
20+
"Operating System :: Microsoft :: Windows",
21+
"Programming Language :: Python :: 3 :: Only",
22+
"Programming Language :: Python :: 3.7",
23+
"Programming Language :: Python :: 3.8",
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10",
26+
"Programming Language :: Python :: 3.11",
27+
"Programming Language :: Python :: Implementation :: CPython",
28+
"Topic :: Database :: Front-Ends",
29+
]
30+
dependencies = [
31+
'typing-extensions>=3.7.4.3;python_version<"3.8"',
32+
]
33+
34+
[project.urls]
35+
github = "https://github.com/MagicStack/asyncpg"
36+
37+
[project.optional-dependencies]
38+
test = [
39+
'flake8~=5.0.4',
40+
'uvloop>=0.15.3; platform_system != "Windows"',
41+
]
42+
docs = [
43+
'Sphinx~=5.3.0',
44+
'sphinxcontrib-asyncio~=0.3.0',
45+
'sphinx_rtd_theme>=1.2.2',
46+
]
47+
148
[build-system]
2-
requires = ["setuptools>=42", "wheel"]
49+
requires = [
50+
"setuptools>=60",
51+
"wheel",
52+
53+
"Cython(>=0.29.24,<0.30.0)"
54+
]
355
build-backend = "setuptools.build_meta"
456

57+
[tool.setuptools]
58+
zip-safe = false
59+
60+
[tool.setuptools.packages.find]
61+
include = ["asyncpg", "asyncpg.*"]
62+
63+
[tool.setuptools.exclude-package-data]
64+
"*" = ["*.c", "*.h"]
65+
566
[tool.cibuildwheel]
667
build-frontend = "build"
768
test-extras = "test"

setup.py

+16-62
Original file line numberDiff line numberDiff line change
@@ -27,30 +27,6 @@
2727

2828
CYTHON_DEPENDENCY = 'Cython(>=0.29.24,<0.30.0)'
2929

30-
# Minimal dependencies required to test asyncpg.
31-
TEST_DEPENDENCIES = [
32-
'flake8~=5.0.4',
33-
'uvloop>=0.15.3; platform_system != "Windows"',
34-
]
35-
36-
# Dependencies required to build documentation.
37-
DOC_DEPENDENCIES = [
38-
'Sphinx~=4.1.2',
39-
'sphinxcontrib-asyncio~=0.3.0',
40-
'sphinx_rtd_theme~=0.5.2',
41-
]
42-
43-
EXTRA_DEPENDENCIES = {
44-
'docs': DOC_DEPENDENCIES,
45-
'test': TEST_DEPENDENCIES,
46-
# Dependencies required to develop asyncpg.
47-
'dev': [
48-
CYTHON_DEPENDENCY,
49-
'pytest>=6.0',
50-
] + DOC_DEPENDENCIES + TEST_DEPENDENCIES
51-
}
52-
53-
5430
CFLAGS = ['-O2']
5531
LDFLAGS = []
5632

@@ -170,6 +146,18 @@ def finalize_options(self):
170146
if getattr(self, '_initialized', False):
171147
return
172148

149+
if not self.cython_always:
150+
self.cython_always = bool(os.environ.get(
151+
"ASYNCPG_BUILD_CYTHON_ALWAYS"))
152+
153+
if self.cython_annotate is None:
154+
self.cython_annotate = os.environ.get(
155+
"ASYNCPG_BUILD_CYTHON_ANNOTATE")
156+
157+
if self.cython_directives is None:
158+
self.cython_directives = os.environ.get(
159+
"ASYNCPG_BUILD_CYTHON_DIRECTIVES")
160+
173161
need_cythonize = self.cython_always
174162
cfiles = {}
175163

@@ -235,47 +223,16 @@ def finalize_options(self):
235223

236224
setup_requires = []
237225

238-
if (not (_ROOT / 'asyncpg' / 'protocol' / 'protocol.c').exists() or
239-
'--cython-always' in sys.argv):
226+
if (
227+
not (_ROOT / 'asyncpg' / 'protocol' / 'protocol.c').exists()
228+
or os.environ.get("ASYNCPG_BUILD_CYTHON_ALWAYS")
229+
):
240230
# No Cython output, require Cython to build.
241231
setup_requires.append(CYTHON_DEPENDENCY)
242232

243233

244234
setuptools.setup(
245-
name='asyncpg',
246235
version=VERSION,
247-
description='An asyncio PostgreSQL driver',
248-
long_description=readme,
249-
classifiers=[
250-
'Development Status :: 5 - Production/Stable',
251-
'Framework :: AsyncIO',
252-
'Intended Audience :: Developers',
253-
'License :: OSI Approved :: Apache Software License',
254-
'Operating System :: POSIX',
255-
'Operating System :: MacOS :: MacOS X',
256-
'Operating System :: Microsoft :: Windows',
257-
'Programming Language :: Python :: 3 :: Only',
258-
'Programming Language :: Python :: 3.7',
259-
'Programming Language :: Python :: 3.8',
260-
'Programming Language :: Python :: 3.9',
261-
'Programming Language :: Python :: 3.10',
262-
'Programming Language :: Python :: Implementation :: CPython',
263-
'Topic :: Database :: Front-Ends',
264-
],
265-
platforms=['macOS', 'POSIX', 'Windows'],
266-
python_requires='>=3.7.0',
267-
zip_safe=False,
268-
author='MagicStack Inc',
269-
author_email='[email protected]',
270-
url='https://github.com/MagicStack/asyncpg',
271-
license='Apache License, Version 2.0',
272-
packages=setuptools.find_packages(
273-
exclude=['tests', 'tools'],
274-
),
275-
package_data={
276-
# Cython sources needed for tracebacks
277-
"": ["*.pyx", "*.pxd", "*.pxi"],
278-
},
279236
ext_modules=[
280237
setuptools.extension.Extension(
281238
"asyncpg.pgproto.pgproto",
@@ -291,9 +248,6 @@ def finalize_options(self):
291248
extra_compile_args=CFLAGS,
292249
extra_link_args=LDFLAGS),
293250
],
294-
install_requires=['typing-extensions>=3.7.4.3;python_version<"3.8"'],
295251
cmdclass={'build_ext': build_ext, 'build_py': build_py, 'sdist': sdist},
296-
test_suite='tests.suite',
297-
extras_require=EXTRA_DEPENDENCIES,
298252
setup_requires=setup_requires,
299253
)

0 commit comments

Comments
 (0)