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

Move Python examples to standard location #1352

Merged
merged 2 commits into from Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Expand Up @@ -301,7 +301,7 @@ jobs:
- name: Run the examples
# See https://unix.stackexchange.com/a/392973 for an explanation of the -exec part
run: |
find interfaces/cython/cantera/examples -type f -iname "*.py" \
find samples/python -type f -iname "*.py" \
-exec sh -c 'for n; do echo "$n" | tee -a results.txt && python3 "$n" >> results.txt || exit 1; done' sh {} +
env:
PYTHONPATH: build/python
Expand Down Expand Up @@ -364,6 +364,7 @@ jobs:
test -f ${CONDA_PREFIX}/bin/ck2yaml
test -f ${CONDA_PREFIX}/share/cantera/data/gri30.yaml
test -d ${CONDA_PREFIX}/share/cantera/samples
test -d ${CONDA_PREFIX}/share/cantera/samples/python
test -d ${CONDA_PREFIX}/lib/python${{ env.PYTHON_VERSION }}/site-packages/cantera
- name: Test Essentials
# ensure that Python package loads and converter scripts work
Expand Down Expand Up @@ -428,6 +429,7 @@ jobs:
test -f ${CONDA_PREFIX}/Scripts/ck2yaml
test -f ${CONDA_PREFIX}/share/cantera/data/gri30.yaml
test -d ${CONDA_PREFIX}/share/cantera/samples
test -d ${CONDA_PREFIX}/share/cantera/samples/python
test -d ${CONDA_PREFIX}/Lib/site-packages/cantera
- name: Test Essentials
# ensure that Python package loads and converter scripts work
Expand Down
2 changes: 1 addition & 1 deletion SConstruct
Expand Up @@ -2075,7 +2075,7 @@ def postInstallMessage(target, source, env):
))

if env["python_package"] == "full":
env["python_example_loc"] = pjoin(env["python_module_loc"], "cantera", "examples")
env["python_example_loc"] = pjoin(env["ct_sampledir"], "python")
install_message.append(locations_message.format(
name="Python package", location=env_dict["python_module_loc"]
))
Expand Down
2 changes: 1 addition & 1 deletion doc/example-keywords.py
Expand Up @@ -128,7 +128,7 @@ def get_all_keywords():
skip = set(text.splitlines())

all_keywords = Counter()
for d in (cantera_root / "interfaces/cython/cantera/examples").glob("**"):
for d in (cantera_root / "samples" / "python").glob("**"):
if d.is_dir():
for f in d.glob("*.py"):
if f.name.startswith("_") or f.name in skip:
Expand Down
6 changes: 5 additions & 1 deletion interfaces/cython/SConscript
Expand Up @@ -12,6 +12,9 @@ localenv = env.Clone()
dataFiles = localenv.RecursiveInstall("cantera/data", "#build/data")
build(dataFiles)

# Install Python samples
install(localenv.RecursiveInstall, "$inst_sampledir/python", "#samples/python")

# Get information needed to build the Python module
script = """\
from sysconfig import *
Expand Down Expand Up @@ -114,7 +117,8 @@ env['python_module'] = mod
env['python_extension'] = ext

localenv.Depends(mod, [ext, dataFiles, setup_cfg, readme, license,
"setup.py", "pyproject.toml", "cantera/test/README.txt"])
"setup.py", "pyproject.toml",
"cantera/test/README.txt", "cantera/examples/README.txt"])
localenv.Depends(ext, localenv['cantera_staticlib'])

for f in (multi_glob(localenv, 'cantera', 'py') +
Expand Down
5 changes: 5 additions & 0 deletions interfaces/cython/cantera/examples/README.txt
@@ -0,0 +1,5 @@
Starting with Cantera 3.0, Python examples are no longer packaged with the Python
module. Examples illustrating the usage of the Python module can be found on Cantera's
website (https://cantera.org). Alternatively, examples can be accessed in the directory
"samples/python" of the source code, which can be retrieved from the project's GitHub
repository (https://github.com/Cantera/cantera).
Empty file.
10 changes: 4 additions & 6 deletions interfaces/cython/setup.cfg.in
Expand Up @@ -47,15 +47,13 @@ python_requires = >=@py_min_ver_str@
packages =
cantera
cantera.data
cantera.examples

[options.package_data]
cantera.data = *.*, */*.*
cantera.examples = */*.*
# The module extension needs to be here since we don't want setuptools to
# compile the extension, so there are no `source` files in
# the setup.py extension.
cantera = *.pxd, *@module_ext@, test/*.txt
# The module extension needs to be here since we don't want setuptools to compile
# the extension, so there are no ``source`` files in the setup.py ``extension`` and
# we have to treat the module as package data.
cantera = *.pxd, *@module_ext@, test/*.txt, examples/*.txt

[options.extras_require]
hdf5 = h5py
Expand Down
4 changes: 1 addition & 3 deletions interfaces/python_sdist/setup.cfg.in
Expand Up @@ -47,15 +47,13 @@ python_requires = >=@py_min_ver_str@
packages =
cantera
cantera.data
cantera.examples

# These options include data in the sdist and wheel if the files are also listed in
# MANIFEST.in. Note that only files that are inside the "cantera" packages will be
# included in the wheel.
[options.package_data]
cantera.data = *.*, */*.*
cantera.examples = */*.*
cantera = *.pxd
cantera = *.pxd, test/*.txt, examples/*.txt

# These options exclude data from the wheel file but not from the sdist
[options.exclude_package_data]
Expand Down
3 changes: 0 additions & 3 deletions samples/README.txt

This file was deleted.

4 changes: 2 additions & 2 deletions test/python/test_reactor.py
Expand Up @@ -1565,7 +1565,7 @@ class CombustorTestImplementation:
"""
These tests are based on the sample:

interfaces/cython/cantera/examples/reactors/combustor.py
samples/python/reactors/combustor.py

with some simplifications so that they run faster and produce more
consistent output.
Expand Down Expand Up @@ -1671,7 +1671,7 @@ class WallTestImplementation:
"""
These tests are based on the sample:

interfaces/cython/cantera/examples/reactors/reactor2.py
samples/python/reactors/reactor2.py

with some simplifications so that they run faster and produce more
consistent output.
Expand Down