Skip to content
Snippets Groups Projects
Commit f9995357 authored by Jochen Klar's avatar Jochen Klar
Browse files

Use setuptools.dist.Distribution instead of BuildExtCommand

parent 59fd74f8
Branches improve_setup
No related tags found
No related merge requests found
......@@ -22,9 +22,10 @@ email: gsell.matthias@gmail.com
date: 03-01-2020
"""
from distutils.command.build_ext import build_ext
from distutils.core import setup
from distutils.extension import Extension
from setuptools import Extension, dist, setup
# install numpy before main is called
dist.Distribution().fetch_build_eggs(['numpy~=1.18'])
MAJOR_VERSION = 1
MINOR_VERSION = 1
......@@ -34,6 +35,8 @@ VERSION = '{}.{}.{}'.format(MAJOR_VERSION, MINOR_VERSION, PATCH_LEVEL)
def main():
import numpy
macros = [('MAJOR_VERSION', str(MAJOR_VERSION)),
('MINOR_VERSION', str(MINOR_VERSION)),
('PATCH_LEVEL', str(PATCH_LEVEL)),
......@@ -46,18 +49,21 @@ def main():
mshread_ext = Extension('mshread',
sources=['src/mshread.c'],
define_macros=macros,
include_dirs=[numpy.get_include()],
extra_compile_args=compile_args,
extra_link_args=link_args)
mshwrite_ext = Extension('mshwrite',
sources=['src/mshwrite.c'],
define_macros=macros,
include_dirs=[numpy.get_include()],
extra_compile_args=compile_args,
extra_link_args=link_args)
mshutils_ext = Extension('mshutils',
sources=['src/mshutils.c'],
define_macros=macros,
include_dirs=[numpy.get_include()],
extra_compile_args=compile_args,
extra_link_args=link_args)
......@@ -68,23 +74,10 @@ def main():
author_email="gsell.matthias@gmail.com",
ext_package='carputils.mshext',
ext_modules=[mshread_ext, mshwrite_ext, mshutils_ext],
cmdclass={'build_ext': BuildExtCommand},
install_requires=[
'numpy'
])
class BuildExtCommand(build_ext):
'''
Custom BuildExtCommand to include numpy only at build time
see also: https://stackoverflow.com/a/54717012
'''
def run(self):
import numpy
self.include_dirs.append(numpy.get_include())
build_ext.run(self)
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment