Skip to content

Commit

Permalink
[Cython] Use setup.cfg to configure the package
Browse files Browse the repository at this point in the history
This change mirrors the one for the source distribution. This change
results in a non-executable template file
(setup.cfg.in), which makes edits easier.

This change
removes the requirement to template the Python extension into setup.py,
and adds a Setuptools extension module. This results in correct builds
when bdist_wheel is specified and uses package_data properly.
  • Loading branch information
bryanwweber committed Jul 16, 2021
1 parent 5fe8c9e commit bb094f5
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 113 deletions.
4 changes: 3 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ if "clean" in COMMAND_LINE_TARGETS:
remove_directory("include/cantera/ext")
remove_file("interfaces/cython/cantera/_cantera.cpp")
remove_file("interfaces/cython/cantera/_cantera.h")
remove_file("interfaces/cython/setup.py")
remove_file("interfaces/cython/setup.cfg")
remove_file("interfaces/cython/LICENSE.txt")
remove_file("interfaces/cython/README.rst")
remove_file("interfaces/python_minimal/setup.py")
remove_file("config.log")
remove_directory("doc/sphinx/matlab/examples")
Expand Down
8 changes: 3 additions & 5 deletions interfaces/cython/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ cantera/*.cpp
cantera/*.c
cantera/data
cantera/test/data
setup.py
scripts/ctml_writer.py
scripts/ctml_writer
scripts/ck2cti.py
scripts/ck2cti
Cantera.egg-info
dist
setup.cfg
LICENSE.txt
README.rst
11 changes: 7 additions & 4 deletions interfaces/cython/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,19 @@ ext = localenv.LoadableModule('#build/python/cantera/_cantera{}'.format(module_e
SHLIBPREFIX='', LIBSUFFIXES=[module_ext])
localenv['py_extension'] = ext[0].name

localenv.SubstFile('setup.py', 'setup.py.in')
setup_cfg = localenv.SubstFile("setup.cfg", "setup.cfg.in")
readme = localenv.Command("README.rst", "#README.rst", Copy("$TARGET", "$SOURCE"))
license = localenv.Command("LICENSE.txt", "#build/ext/LICENSE.txt",
Copy("$TARGET", "$SOURCE"))
localenv.Depends(license, localenv["license_target"])
build_cmd = ('cd interfaces/cython &&'
' $python_cmd_esc setup.py build --build-lib=../../build/python')
mod = build(localenv.Command('#build/python/cantera/__init__.py', 'setup.py',
mod = build(localenv.Command("#build/python/cantera/__init__.py", "setup.cfg",
build_cmd))
env['python_module'] = mod
env['python_extension'] = ext

localenv.Depends(mod, ext)
localenv.Depends(mod, dataFiles + testFiles)
localenv.Depends(mod, [ext, dataFiles, testFiles, setup_cfg, readme, license])
localenv.Depends(ext, localenv['cantera_staticlib'])

for f in (multi_glob(localenv, 'cantera', 'py') +
Expand Down
69 changes: 69 additions & 0 deletions interfaces/cython/setup.cfg.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[metadata]
name = Cantera
version = @cantera_version@
description = Cantera is an open-source suite of tools for problems involving chemical kinetics, thermodynamics, and transport processes.
long_description = file: README.rst
long_description_content_type = text/x-rst
license_files = LICENSE.txt
url = https://cantera.org
author = Cantera Developers
author_email = steering@cantera.org
keywords = chemistry physics
license = BSD 3-Clause License
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Education
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Operating System :: MacOS :: MacOS X
Operating System :: Microsoft :: Windows
Operating System :: POSIX :: Linux
Programming Language :: C
Programming Language :: C++
Programming Language :: Cython
Programming Language :: Fortran
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: Implementation :: CPython
Topic :: Scientific/Engineering :: Chemistry
Topic :: Scientific/Engineering :: Physics
project_urls =
Documentation = https://cantera.org/documentation
Funding = https://numfocus.org/donate-to-cantera
Source = https://github.com/Cantera/cantera
Tracker = https://github.com/Cantera/cantera/issues

[options]
zip_safe = False
include_package_data = True
install_requires =
numpy >= 1.12.0
ruamel.yaml >= 0.15.34
python_requires = ~=@py_min_ver_str@
packages =
cantera
cantera.data
cantera.test
cantera.test.data
cantera.examples

[options.package_data]
cantera.data = *.*, */*.*
cantera.test.data = *.*, */*.*
cantera.examples = */*.*
cantera = *.pxd

[options.extras_require]
hdf5 = h5py
pandas = pandas

[options.entry_points]
console_scripts =
ck2cti = cantera.ck2cti:script_entry_point
ctml_writer = cantera.ctml_writer:main
ck2yaml = cantera.ck2yaml:script_entry_point
cti2yaml = cantera.cti2yaml:main
ctml2yaml = cantera.ctml2yaml:main
7 changes: 7 additions & 0 deletions interfaces/cython/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from setuptools import setup, Extension

extension = Extension("cantera._cantera", sources=[])

setup(
ext_modules=[extension],
)
103 changes: 0 additions & 103 deletions interfaces/cython/setup.py.in

This file was deleted.

0 comments on commit bb094f5

Please sign in to comment.