Skip to content

Commit c462fb8

Browse files
committed
Update setuptools resources
1 parent bac5971 commit c462fb8

File tree

3 files changed

+72
-101
lines changed

3 files changed

+72
-101
lines changed

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[build-system]
2+
requires = [
3+
"wheel",
4+
"setuptools>=45",
5+
"setuptools_scm[toml]>=6.0",
6+
"ninja",
7+
"cmake>=3.18.2",
8+
"cmake-build-extension",
9+
"pybind11",
10+
]
11+
build-backend = "setuptools.build_meta"
12+
13+
[tool.setuptools_scm]
14+
local_scheme = "dirty-tag"

setup.cfg

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
[metadata]
2+
name = manifpy
3+
description = A small library for Lie theory.
4+
long_description = file: README.md; charset=UTF-8
5+
long_description_content_type = text/markdown
6+
author = Jeremie Deray
7+
author_email = [email protected]
8+
license = MIT
9+
platforms = any
10+
url = https://github.com/artivis/manif
11+
project_urls =
12+
Source = https://github.com/artivis/manif
13+
Tracker = https://github.com/artivis/manif/issues
14+
keywords = geometry lie-theory state-estimation slam robotics computer-vision
15+
classifiers =
16+
Development Status :: 5 - Production/Stable
17+
Operating System :: OS Independent
18+
Operating System :: POSIX :: Linux
19+
Operating System :: MacOS
20+
Operating System :: Microsoft :: Windows
21+
Framework :: Robot Framework
22+
Intended Audience :: Science/Research
23+
Intended Audience :: Developers
24+
Intended Audience :: Education
25+
Programming Language :: C++
26+
Programming Language :: Python :: 3 :: Only
27+
Programming Language :: Python :: 3
28+
Programming Language :: Python :: 3.6
29+
Programming Language :: Python :: 3.7
30+
Programming Language :: Python :: 3.8
31+
Programming Language :: Python :: 3.9
32+
License :: OSI Approved :: MIT License
33+
34+
[options]
35+
zip_safe = False
36+
python_requires = >=3.6
37+
38+
[options.extras_require]
39+
testing =
40+
pytest
41+
numpy
42+
all =
43+
%(testing)s

setup.py

Lines changed: 15 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,21 @@
1-
import os
2-
import platform
3-
import subprocess
41
import sys
52

6-
import xml.etree.ElementTree as ET
7-
8-
import setuptools
9-
from setuptools import Extension, setup
10-
from setuptools.command.build_ext import build_ext
11-
12-
13-
"""
14-
Modified from https://www.benjack.io/2017/06/12/python-cpp-tests.html
15-
"""
16-
17-
18-
class CMakeExtension(Extension):
19-
20-
def __init__(self, name, sourcedir=''):
21-
Extension.__init__(self, name, sources=[])
22-
self.sourcedir = os.path.abspath(sourcedir)
23-
24-
25-
class CMakeBuild(build_ext):
26-
27-
def run(self):
28-
try:
29-
# out =
30-
subprocess.check_output(['cmake', '--version'])
31-
except OSError:
32-
raise RuntimeError(
33-
'CMake must be installed to build the following extensions: ' +
34-
', '.join(e.name for e in self.extensions))
35-
36-
# if platform.system() == "Windows":
37-
# cmake_version = LooseVersion(re.search(r'version\s*([\d.]+)',
38-
# out.decode()).group(1))
39-
# if cmake_version < '3.1.0':
40-
# raise RuntimeError("CMake >= 3.1.0 is required on Windows")
41-
42-
for ext in self.extensions:
43-
self.build_extension(ext)
44-
45-
def build_extension(self, ext):
46-
extdir = os.path.abspath(
47-
os.path.dirname(self.get_ext_fullpath(ext.name)))
48-
49-
cmake_args = ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=' + extdir,
50-
'-DPYTHON_EXECUTABLE=' + sys.executable]
51-
52-
cfg = 'Debug' if self.debug else 'Release'
53-
build_args = ['--config', cfg]
54-
55-
if platform.system() == 'Windows':
56-
cmake_args += ['-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_{}={}'.format(
57-
cfg.upper(),
58-
extdir)]
59-
if sys.maxsize > 2**32:
60-
cmake_args += ['-A', 'x64']
61-
build_args += ['--', '/m']
62-
else:
63-
cmake_args += ['-DCMAKE_BUILD_TYPE=' + cfg]
64-
cmake_args += ['-DBUILD_PYTHON_BINDINGS=ON']
65-
build_args += ['--', '-j6']
66-
67-
env = os.environ.copy()
68-
env['CXXFLAGS'] = '{} -DVERSION_INFO=\\"{}\\"'.format(
69-
env.get('CXXFLAGS', ''),
70-
self.distribution.get_version())
71-
if not os.path.exists(self.build_temp):
72-
os.makedirs(self.build_temp)
73-
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args,
74-
cwd=self.build_temp, env=env)
75-
subprocess.check_call(['cmake', '--build', '.'] + build_args,
76-
cwd=self.build_temp)
77-
78-
79-
def get_package_xml_version():
80-
tree = ET.parse('package.xml')
81-
return tree.find('version').text
82-
83-
84-
with open('README.md', 'r') as f:
85-
long_description = f.read()
3+
from cmake_build_extension import BuildExtension, CMakeExtension
4+
from setuptools import setup
865

876
setup(
88-
name='manifpy',
89-
version=get_package_xml_version(),
90-
author='Jeremie Deray',
91-
author_email='[email protected]',
92-
description='A small library for Lie theory.',
93-
long_description=long_description,
94-
long_description_content_type='text/markdown',
95-
url='https://github.com/artivis/manif',
96-
license='MIT',
97-
packages=setuptools.find_packages(),
98-
classifiers=[
99-
'Programming Language :: Python :: 3',
100-
'Operating System :: POSIX :: Linux'
7+
ext_modules=[
8+
CMakeExtension(
9+
name="CMakeProject",
10+
install_prefix="manifpy",
11+
cmake_depends_on=["pybind11"],
12+
disable_editable=True,
13+
cmake_configure_options=[
14+
"-DCALL_FROM_SETUP_PY:BOOL=ON",
15+
"-DBUILD_PYTHON_BINDINGS:BOOL=ON",
16+
f"-DPython3_EXECUTABLE:PATH={sys.executable}",
17+
],
18+
)
10119
],
102-
ext_modules=[CMakeExtension('manifpy')],
103-
python_requires='>=3.6',
104-
cmdclass=dict(build_ext=CMakeBuild),
105-
zip_safe=False,
106-
install_requires=['numpy']
20+
cmdclass=dict(build_ext=BuildExtension),
10721
)

0 commit comments

Comments
 (0)