Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 517 build support #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions source/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[build-system]
requires = ["setuptools>=61", "numpy"]
build-backend = "setuptools.build_meta"

[project]
name = "qlsc"
version = "1.0.6"
44 changes: 13 additions & 31 deletions source/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,22 @@
from distutils.core import setup, Extension
#from setuptools import setup, Extension
#from setuptools import find_packages
from setuptools.command.build_ext import build_ext as _build_ext
#from setuptools import dist

import numpy as np
#dist.Distribution().fetch_build_eggs(['numpy>=1.19'])

# directions on including NumPy in a C extension:
# Ref: https://numpy.org/doc/stable/reference/c-api/array.html#importing-the-api
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)

#copt = {}
#lopt = {}
import numpy as np
self.include_dirs.append(np.get_include())

#class build_ext_subclass( build_ext ):
# pass
# def build_extensions(self):
# c = self.compiler.compiler_type
# if c in copt:
# for e in self.extensions:
# e.extra_compile_args = copt[ c ]
# if c in lopt:
# for e in self.extensions:
# e.extra_link_args = lopt[ c ]
# build_ext.build_extensions(self)

def get_property(prop:str, project:str):
'''
Read the requested property (e.g. '__version__', '__author__') from the specified Python module.
Ref: https://stackoverflow.com/a/41110107/2712652
'''
result = re.search(r'{}\s*=\s*[\'"]([^\'"]*)[\'"]'.format(prop), open(project + '/__init__.py').read())
return result.group(1)

sources = ["qlsc/c_code/qlsc_c_module.c", "qlsc/c_code/q3c/q3cube.c", "qlsc/c_code/q3c/q3c_poly.c"]
data_files = []
include_dirs = ['q3c', np.get_include()] # -I directories
include_dirs = ['q3c'] # -I directories
library_dirs = [] # -L directories
libraries = [] # libraries to include
define_macros = [('Q3C_VERSION', '"2.0.0"'), # equivalent of a bare #define in C source
Expand Down Expand Up @@ -74,7 +58,6 @@ def get_property(prop:str, project:str):
setup(
name="qlsc",
version=__version__,
#version=get_property('__version__', 'qlsc'),
description=description,
long_description=long_description,
#long_description_content_type='text/markdown; charset=UTF-8; variant=GFM',
Expand All @@ -92,16 +75,15 @@ def get_property(prop:str, project:str):
# },
author="Demitri Muna",
author_email="[email protected]",
#setup_requires=['wheel'], # needed to package for distribution
#install_requires=[],
setup_requires=['wheel', 'numpy'], # needed to package for distribution
install_requires=['numpy'],
#packages=find_packages(),
data_files=data_files,
ext_package="qlsc", # will compile the methods from the extension to the namespace "qlsc"
ext_modules=[c_extension], # alternative: cythonize(etc), needs "from Cython.Build import cythonize"
include_dirs=['q3c'],
packages=setuptools.find_packages(), #['qlsc'],
include_package_data = True, # add files specified in MANIFEST.in, specifically header files
python_requires='>=3.6'
python_requires='>=3.6',
cmdclass={"build_ext": build_ext}
)
# cmdclass={"build_ext": build_ext_subclass}
#)