Skip to content

Commit fe581fe

Browse files
committed
BLD Move packaging metadata into pyproject.toml
1 parent ce58622 commit fe581fe

File tree

4 files changed

+129
-145
lines changed

4 files changed

+129
-145
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ include INSTALL
1212
include Makefile
1313
include mahotas/tests/data/*
1414
include mahotas/demos/data/*
15-
include *requirements.txt
1615
graft docs/source
1716
include docs/Makefile

pyproject.toml

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,75 @@
11
[build-system]
2-
requires = ["setuptools", "numpy"]
3-
# When build with numpy>=1.25 the resulted binary wheel is compatybile with numpy >=1.16
2+
requires = ["setuptools>=64", "numpy"]
43
build-backend = "setuptools.build_meta"
54

5+
[project]
6+
name = "mahotas"
7+
dynamic = ["version"]
8+
description = "Mahotas: Computer Vision Library"
9+
readme = "README.md"
10+
requires-python = ">=3.7"
11+
license = {text = "MIT"}
12+
authors = [
13+
{name = "Luis Pedro Coelho", email = "luis@luispedro.org"},
14+
]
15+
classifiers = [
16+
"Development Status :: 5 - Production/Stable",
17+
"Intended Audience :: Developers",
18+
"Intended Audience :: Science/Research",
19+
"Topic :: Scientific/Engineering :: Image Recognition",
20+
"Topic :: Software Development :: Libraries",
21+
"Programming Language :: Python",
22+
"Programming Language :: Python :: 3",
23+
"Programming Language :: Python :: 3.7",
24+
"Programming Language :: Python :: 3.8",
25+
"Programming Language :: Python :: 3.9",
26+
"Programming Language :: Python :: 3.10",
27+
"Programming Language :: Python :: 3.11",
28+
"Programming Language :: Python :: 3.12",
29+
"Programming Language :: Python :: 3.13",
30+
"Programming Language :: C++",
31+
"Operating System :: OS Independent",
32+
"License :: OSI Approved :: MIT License",
33+
]
34+
dependencies = [
35+
"numpy",
36+
]
37+
38+
[project.urls]
39+
Homepage = "https://luispedro.org/software/mahotas"
40+
Documentation = "https://mahotas.readthedocs.io/"
41+
Repository = "https://github.com/luispedro/mahotas"
42+
Issues = "https://github.com/luispedro/mahotas/issues"
43+
44+
[project.optional-dependencies]
45+
tests = [
46+
"matplotlib",
47+
"pip",
48+
"coveralls",
49+
"pytest<=8.1.1",
50+
"scipy",
51+
"pillow",
52+
]
53+
54+
[project.scripts]
55+
mahotas-features = "mahotas.features_cli:main"
56+
57+
[tool.setuptools]
58+
include-package-data = false
59+
60+
[tool.setuptools.dynamic]
61+
version = {attr = "mahotas.mahotas_version.__version__"}
62+
63+
[tool.setuptools.packages.find]
64+
include = ["mahotas*"]
65+
66+
[tool.setuptools.package-data]
67+
"mahotas.tests" = ["data/*"]
68+
"mahotas.demos" = ["data/*"]
69+
670
[tool.cibuildwheel]
771
test-command = "pytest --import-mode=importlib {project}/mahotas/tests"
872
test-extras = ["tests"]
9-
test-skip = ["pp*", "cp31*-win32"] # there are no scipy weels for this version
10-
skip= ["pp37*", "pp310*", "*musllinux*", "*manylinux*i686"] # there are no numpy wheels for this version
11-
environment = { PIP_PREFER_BINARY="1"}
73+
test-skip = ["pp*", "cp31*-win32"] # there are no scipy wheels for this version
74+
skip = ["pp37*", "pp310*", "*musllinux*", "*manylinux*i686"] # there are no numpy wheels for this version
75+
environment = {PIP_PREFER_BINARY = "1"}

requirements.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 60 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -1,164 +1,86 @@
1-
# -*- coding: utf-8 -*-
21
# Copyright (C) 2009-2025, Luis Pedro Coelho <luis@luispedro.org>
3-
# vim: set ts=4 sts=4 sw=4 expandtab smartindent:
4-
#
5-
# Permission is hereby granted, free of charge, to any person obtaining a copy
6-
# of this software and associated documentation files (the "Software"), to deal
7-
# in the Software without restriction, including without limitation the rights
8-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
# copies of the Software, and to permit persons to whom the Software is
10-
# furnished to do so, subject to the following conditions:
11-
#
12-
# The above copyright notice and this permission notice shall be included in
13-
# all copies or substantial portions of the Software.
14-
#
15-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
# THE SOFTWARE.
22-
23-
from __future__ import division
24-
try:
25-
import setuptools
26-
except ImportError:
27-
print('''
28-
setuptools not found.
29-
30-
On linux, the package is often called python-setuptools''')
31-
from sys import exit
32-
exit(1)
2+
333
import os
4+
5+
from setuptools import Extension, setup
6+
from setuptools.command.build_ext import build_ext
7+
348
try:
359
import numpy
3610
except ImportError as e:
37-
print('''
11+
print(
12+
"""
3813
Could not import numpy ({}).
3914
4015
It is possible that building will fail.
41-
'''.format(e))
42-
class FakeNumpy(object):
43-
def get_include(self):
44-
return []
45-
numpy = FakeNumpy()
46-
16+
""".format(e)
17+
)
4718

48-
from distutils.command.build_ext import build_ext
19+
class FakeNumpy:
20+
@staticmethod
21+
def get_include():
22+
return []
4923

50-
exec(compile(open('mahotas/mahotas_version.py').read(),
51-
'mahotas/mahotas_version.py', 'exec'))
24+
numpy = FakeNumpy()
5225

53-
long_description = open('README.md', encoding='utf-8').read()
5426

5527
undef_macros = []
5628
define_macros = []
57-
if os.environ.get('DEBUG'):
58-
undef_macros = ['NDEBUG']
59-
if os.environ.get('DEBUG') == '2':
60-
define_macros = [('_GLIBCXX_DEBUG','1')]
29+
if os.environ.get("DEBUG"):
30+
undef_macros = ["NDEBUG"]
31+
if os.environ.get("DEBUG") == "2":
32+
define_macros = [("_GLIBCXX_DEBUG", "1")]
6133

62-
define_macros.append(('NPY_NO_DEPRECATED_API','NPY_1_7_API_VERSION'))
63-
define_macros.append(('PY_ARRAY_UNIQUE_SYMBOL','Mahotas_PyArray_API_Symbol'))
34+
define_macros.append(("NPY_NO_DEPRECATED_API", "NPY_1_7_API_VERSION"))
35+
define_macros.append(("PY_ARRAY_UNIQUE_SYMBOL", "Mahotas_PyArray_API_Symbol"))
6436

6537
extensions = {
66-
'mahotas._bbox': ['mahotas/_bbox.cpp'],
67-
'mahotas._center_of_mass': ['mahotas/_center_of_mass.cpp'],
68-
'mahotas._convex': ['mahotas/_convex.cpp'],
69-
'mahotas._convolve': ['mahotas/_convolve.cpp', 'mahotas/_filters.cpp'],
70-
'mahotas._distance': ['mahotas/_distance.cpp'],
71-
'mahotas._histogram': ['mahotas/_histogram.cpp'],
72-
'mahotas._interpolate': ['mahotas/_interpolate.cpp', 'mahotas/_filters.cpp'],
73-
'mahotas._labeled': ['mahotas/_labeled.cpp', 'mahotas/_filters.cpp'],
74-
'mahotas._morph': ['mahotas/_morph.cpp', 'mahotas/_filters.cpp'],
75-
'mahotas._thin': ['mahotas/_thin.cpp'],
76-
77-
'mahotas.features._lbp': ['mahotas/features/_lbp.cpp'],
78-
'mahotas.features._surf': ['mahotas/features/_surf.cpp'],
79-
'mahotas.features._texture': ['mahotas/features/_texture.cpp', 'mahotas/_filters.cpp'],
80-
'mahotas.features._zernike': ['mahotas/features/_zernike.cpp'],
38+
"mahotas._bbox": ["mahotas/_bbox.cpp"],
39+
"mahotas._center_of_mass": ["mahotas/_center_of_mass.cpp"],
40+
"mahotas._convex": ["mahotas/_convex.cpp"],
41+
"mahotas._convolve": ["mahotas/_convolve.cpp", "mahotas/_filters.cpp"],
42+
"mahotas._distance": ["mahotas/_distance.cpp"],
43+
"mahotas._histogram": ["mahotas/_histogram.cpp"],
44+
"mahotas._interpolate": ["mahotas/_interpolate.cpp", "mahotas/_filters.cpp"],
45+
"mahotas._labeled": ["mahotas/_labeled.cpp", "mahotas/_filters.cpp"],
46+
"mahotas._morph": ["mahotas/_morph.cpp", "mahotas/_filters.cpp"],
47+
"mahotas._thin": ["mahotas/_thin.cpp"],
48+
"mahotas.features._lbp": ["mahotas/features/_lbp.cpp"],
49+
"mahotas.features._surf": ["mahotas/features/_surf.cpp"],
50+
"mahotas.features._texture": [
51+
"mahotas/features/_texture.cpp",
52+
"mahotas/_filters.cpp",
53+
],
54+
"mahotas.features._zernike": ["mahotas/features/_zernike.cpp"],
8155
}
8256

8357
ext_modules = [
84-
setuptools.Extension(key, sources=sources, undef_macros=undef_macros, define_macros=define_macros, include_dirs=[numpy.get_include()])
85-
for key,sources in extensions.items()]
86-
87-
packages = setuptools.find_packages()
88-
89-
package_dir = {
90-
'mahotas.tests': 'mahotas/tests',
91-
'mahotas.demos': 'mahotas/demos',
92-
}
93-
package_data = {
94-
'mahotas.tests': ['data/*'],
95-
'mahotas.demos': ['data/*'],
96-
}
97-
98-
install_requires = open('requirements.txt').read().strip().split('\n')
99-
100-
tests_require = open('tests-requirements.txt').read().strip().split('\n')
101-
if "freeimage" in tests_require:
102-
tests_require.pop(tests_require.index("freeimage"))
58+
Extension(
59+
key,
60+
sources=sources,
61+
undef_macros=undef_macros,
62+
define_macros=define_macros,
63+
include_dirs=[numpy.get_include()],
64+
)
65+
for key, sources in extensions.items()
66+
]
10367

104-
copt={
105-
'msvc': ['/EHsc'],
106-
'intelw': ['/EHsc']
68+
copt = {
69+
"msvc": ["/EHsc"],
70+
"intelw": ["/EHsc"],
10771
}
10872

73+
10974
class build_ext_subclass(build_ext):
11075
def build_extensions(self):
111-
c = self.compiler.compiler_type
112-
if c in copt:
113-
for e in self.extensions:
114-
e.extra_compile_args = copt[c]
115-
build_ext.build_extensions(self)
116-
117-
classifiers = [
118-
'Development Status :: 5 - Production/Stable',
119-
'Intended Audience :: Developers',
120-
'Intended Audience :: Science/Research',
121-
'Topic :: Scientific/Engineering :: Image Recognition',
122-
'Topic :: Software Development :: Libraries',
123-
'Programming Language :: Python',
124-
'Programming Language :: Python :: 3',
125-
'Programming Language :: Python :: 3.7',
126-
'Programming Language :: Python :: 3.8',
127-
'Programming Language :: Python :: 3.9',
128-
'Programming Language :: Python :: 3.10',
129-
'Programming Language :: Python :: 3.11',
130-
'Programming Language :: Python :: 3.12',
131-
'Programming Language :: Python :: 3.13',
132-
'Programming Language :: C++',
133-
'Operating System :: OS Independent',
134-
'License :: OSI Approved :: MIT License',
135-
]
76+
compiler_type = self.compiler.compiler_type
77+
if compiler_type in copt:
78+
for extension in self.extensions:
79+
extension.extra_compile_args = copt[compiler_type]
80+
super().build_extensions()
81+
13682

137-
setuptools.setup(name = 'mahotas',
138-
version = __version__,
139-
description = 'Mahotas: Computer Vision Library',
140-
long_description = long_description,
141-
long_description_content_type = 'text/markdown',
142-
author = 'Luis Pedro Coelho',
143-
author_email = 'luis@luispedro.org',
144-
license = 'MIT',
145-
python_requires = '>=3.7',
146-
platforms = ['Any'],
147-
classifiers = classifiers,
148-
url = 'https://luispedro.org/software/mahotas',
149-
packages = packages,
150-
ext_modules = ext_modules,
151-
package_dir = package_dir,
152-
package_data = package_data,
153-
entry_points={
154-
'console_scripts': [
155-
'mahotas-features = mahotas.features_cli:main',
156-
],
157-
},
158-
install_requires = install_requires,
159-
tests_require = tests_require,
160-
cmdclass = {'build_ext': build_ext_subclass},
161-
extras_require = {
162-
"tests": tests_require,
163-
},
164-
)
83+
setup(
84+
ext_modules=ext_modules,
85+
cmdclass={"build_ext": build_ext_subclass},
86+
)

0 commit comments

Comments
 (0)