Skip to content

Commit 9b587ec

Browse files
committed
Migrate to pyproject.toml
1 parent d0e1752 commit 9b587ec

File tree

6 files changed

+115
-125
lines changed

6 files changed

+115
-125
lines changed

README.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ binary extension for your Python.
3131

3232
If it is unable to build a binary extension, it will use cffi ABI mode
3333
instead and only needs the libvips shared library. This takes longer to
34-
start up and is typically ~20% slower in execution. You can find out how
35-
pyvips installed with ``pip show pyvips``.
34+
start up and is typically ~20% slower in execution. You can find out if
35+
API mode is being used with:
36+
37+
.. code-block:: python
38+
39+
import pyvips
40+
41+
print(pyvips.API_mode)
3642
3743
This binding passes the vips test suite cleanly and with no leaks under
3844
python3 and pypy3 on Windows, macOS and Linux.
@@ -246,7 +252,7 @@ Update pypi package:
246252

247253
.. code-block:: shell
248254
249-
$ python3 setup.py sdist
255+
$ python3 -m build --sdist
250256
$ twine upload --repository pyvips dist/*
251257
$ git tag -a v2.2.0 -m "as uploaded to pypi"
252258
$ git push origin v2.2.0

pyproject.toml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[build-system]
2+
requires = [
3+
# First version of setuptools to support pyproject.toml configuration
4+
"setuptools>=61.0.0",
5+
"wheel",
6+
# Must be kept in sync with `project.dependencies`
7+
"cffi>=1.0.0",
8+
"pkgconfig>=1.5",
9+
]
10+
build-backend = "setuptools.build_meta"
11+
12+
[project]
13+
name = "pyvips"
14+
authors = [
15+
{name = "John Cupitt", email = "[email protected]"},
16+
]
17+
description = "binding for the libvips image processing library"
18+
readme = "README.rst"
19+
keywords = [
20+
"image processing",
21+
]
22+
license = {text = "MIT"}
23+
requires-python = ">=3.3"
24+
classifiers = [
25+
"Development Status :: 5 - Production/Stable",
26+
"Environment :: Console",
27+
"Intended Audience :: Developers",
28+
"Intended Audience :: Science/Research",
29+
"Topic :: Multimedia :: Graphics",
30+
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
31+
"License :: OSI Approved :: MIT License",
32+
"Programming Language :: Python",
33+
"Programming Language :: Python :: 3",
34+
"Programming Language :: Python :: 3 :: Only",
35+
"Programming Language :: Python :: 3.3",
36+
"Programming Language :: Python :: 3.4",
37+
"Programming Language :: Python :: 3.5",
38+
"Programming Language :: Python :: 3.6",
39+
"Programming Language :: Python :: 3.7",
40+
"Programming Language :: Python :: 3.8",
41+
"Programming Language :: Python :: 3.9",
42+
"Programming Language :: Python :: 3.10",
43+
"Programming Language :: Python :: 3.11",
44+
"Programming Language :: Python :: 3.12",
45+
"Programming Language :: Python :: Implementation :: CPython",
46+
"Programming Language :: Python :: Implementation :: PyPy",
47+
]
48+
dependencies = [
49+
# Must be kept in sync with `build-system.requires`
50+
"cffi>=1.0.0",
51+
]
52+
dynamic = [
53+
"version",
54+
]
55+
56+
[project.urls]
57+
changelog = "https://github.com/libvips/pyvips/blob/master/CHANGELOG.rst"
58+
documentation = "https://libvips.github.io/pyvips/"
59+
funding = "https://opencollective.com/libvips"
60+
homepage = "https://github.com/libvips/pyvips"
61+
issues = "https://github.com/libvips/pyvips/issues"
62+
source = "https://github.com/libvips/pyvips"
63+
64+
[tool.setuptools]
65+
# We try to compile as part of install, so we can't run in a ZIP
66+
zip-safe = false
67+
include-package-data = false
68+
69+
[tool.setuptools.dynamic]
70+
version = {attr = "pyvips.version.__version__"}
71+
72+
[tool.setuptools.packages.find]
73+
exclude = [
74+
"doc*",
75+
"examples*",
76+
"tests*",
77+
]
78+
79+
[project.optional-dependencies]
80+
# All the following are used for our own testing
81+
tox = ["tox"]
82+
test = [
83+
"pytest",
84+
"pyperf",
85+
]
86+
sdist = ["build"]
87+
doc = [
88+
"sphinx",
89+
"sphinx_rtd_theme",
90+
]
91+
92+
[tool.pytest.ini_options]
93+
norecursedirs = ["tests/helpers"]

pyvips/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# user code can override this null handler
1111
logger.addHandler(logging.NullHandler())
1212

13-
# pull in our module version number, see also setup.py
13+
# pull in our module version number
1414
from .version import __version__
1515

1616
# try to import our binary interface ... if that works, we are in API mode

pyvips/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# this is execfile()d into setup.py imported into __init__.py
1+
# this is used in pyproject.toml and imported into __init__.py
22
__version__ = '2.2.3'
33

44
__all__ = ['__version__']

setup.cfg

Lines changed: 0 additions & 5 deletions
This file was deleted.

setup.py

Lines changed: 11 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,22 @@
1-
"""a binding for the libvips image processing library
2-
3-
See:
4-
https://github.com/libvips/pyvips
5-
"""
6-
7-
# flake8: noqa
8-
91
import sys
10-
from codecs import open
11-
from os import path
12-
13-
from setuptools import setup, find_packages
14-
from distutils import log
15-
16-
here = path.abspath(path.dirname(__file__))
17-
18-
info = {}
19-
with open(path.join(here, 'pyvips', 'version.py'), encoding='utf-8') as f:
20-
exec(f.read(), info)
21-
22-
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
23-
long_description = f.read()
24-
25-
# See https://pypi.python.org/pypi?%3Aaction=list_classifiers
26-
pyvips_classifiers = [
27-
'Development Status :: 5 - Production/Stable',
28-
'Environment :: Console',
29-
'Intended Audience :: Developers',
30-
'Intended Audience :: Science/Research',
31-
'Topic :: Multimedia :: Graphics',
32-
'Topic :: Multimedia :: Graphics :: Graphics Conversion',
33-
'License :: OSI Approved :: MIT License',
34-
'Programming Language :: Python :: 3'
35-
'Programming Language :: Python :: 3 :: Only',
36-
'Programming Language :: Python :: 3.3',
37-
'Programming Language :: Python :: 3.4',
38-
'Programming Language :: Python :: 3.5',
39-
'Programming Language :: Python :: 3.6',
40-
'Programming Language :: Python :: 3.7',
41-
'Programming Language :: Python :: 3.8',
42-
'Programming Language :: Python :: 3.9',
43-
'Programming Language :: Python :: 3.10',
44-
'Programming Language :: Python :: 3.11',
45-
'Programming Language :: Python :: 3.12',
46-
'Programming Language :: Python :: Implementation :: CPython',
47-
'Programming Language :: Python :: Implementation :: PyPy',
48-
]
492

50-
setup_deps = [
51-
'cffi>=1.0.0',
52-
]
53-
54-
install_deps = [
55-
'cffi>=1.0.0',
56-
]
57-
58-
test_deps = [
59-
'cffi>=1.0.0',
60-
'pytest',
61-
'pyperf',
62-
]
63-
64-
extras = {
65-
'test': test_deps,
66-
'doc': ['sphinx', 'sphinx_rtd_theme'],
67-
}
68-
69-
pyvips_packages = find_packages(exclude=['docs', 'tests', 'examples'])
70-
71-
sys.path.append(path.join(here, 'pyvips'))
72-
73-
def setup_API():
74-
setup(
75-
name='pyvips',
76-
version=info['__version__'],
77-
description='binding for the libvips image processing library, API mode',
78-
long_description=long_description,
79-
url='https://github.com/libvips/pyvips',
80-
author='John Cupitt',
81-
author_email='[email protected]',
82-
license='MIT',
83-
classifiers=pyvips_classifiers,
84-
keywords='image processing',
85-
86-
packages=pyvips_packages,
87-
setup_requires=setup_deps + ['pkgconfig>=1.5'],
88-
cffi_modules=['pyvips/pyvips_build.py:ffibuilder'],
89-
install_requires=install_deps + ['pkgconfig>=1.5'],
90-
tests_require=test_deps,
91-
extras_require=extras,
92-
93-
# we will try to compile as part of install, so we can't run in a zip
94-
zip_safe=False,
95-
)
3+
from os import path
4+
from setuptools import setup
965

97-
def setup_ABI():
98-
setup(
99-
name='pyvips',
100-
version=info['__version__'],
101-
description='binding for the libvips image processing library, ABI mode',
102-
long_description=long_description,
103-
url='https://github.com/libvips/pyvips',
104-
author='John Cupitt',
105-
author_email='[email protected]',
106-
license='MIT',
107-
classifiers=pyvips_classifiers,
108-
keywords='image processing',
6+
base_dir = path.dirname(__file__)
7+
src_dir = path.join(base_dir, 'pyvips')
1098

110-
packages=pyvips_packages,
111-
setup_requires=setup_deps,
112-
install_requires=install_deps,
113-
tests_require=test_deps,
114-
extras_require=extras,
115-
)
9+
# When executing the setup.py, we need to be able to import ourselves, this
10+
# means that we need to add the pyvips/ directory to the sys.path.
11+
sys.path.insert(0, src_dir)
11612

117-
# try to install in API mode first, then if that fails, fall back to ABI
13+
# Try to install in API mode first, then if that fails, fall back to ABI
11814

11915
# API mode requires a working C compiler plus all the libvips headers whereas
12016
# ABI only needs the libvips shared library to be on the system
12117

12218
try:
123-
setup_API()
19+
setup(cffi_modules=['pyvips/pyvips_build.py:ffibuilder'])
12420
except Exception as e:
125-
log.warn('Falling back to ABI mode. Details: {0}'.format(e))
126-
setup_ABI()
21+
print('Falling back to ABI mode. Details: {0}'.format(e))
22+
setup()

0 commit comments

Comments
 (0)