From bd5ee362fc4b4b8481f78c1b22fe4957839b347b Mon Sep 17 00:00:00 2001 From: vsnever Date: Fri, 30 Aug 2024 13:32:09 +0200 Subject: [PATCH 1/2] Add support for Cherab 1.5 and prepare for release. --- CHANGELOG.md | 15 +++++++++++ README.md | 16 ++++-------- cherab/edge2d/models/line_emitter.pyx | 2 +- pyproject.toml | 3 +++ requirements.txt | 4 ++- setup.py | 37 ++++++++++++++++++++++++++- 6 files changed, 63 insertions(+), 14 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 pyproject.toml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..1a96e70 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +Release 0.2.0 (TBD) +------------------- + +New: +* Support Cython 3 stable release +* Support Cherab 1.5 + +Bug fixes: +* Fix parsing of integer data from TRAN files in recent versions of EPROC. + + +Release 0.1.0 (7 Nov 2022) +-------------------------- + +Initial release. diff --git a/README.md b/README.md index ae858eb..3636d49 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Cherab add-on module for EDGE2D simulations. This module enables the creation of Cherab plasma objects from EDGE2D simulations. EDGE2D tran files are supported. -Please see the examples in the [demos](demos) directory for an illustration of how to use the module. +Please see the examples in the demos directory for an illustration of how to use the module. ## Installation @@ -27,18 +27,10 @@ source ~/venvs/cherab-venv/bin/activate This module depends on the core Cherab framework and Eproc EDGE2D processing library. Cherab core, and all of its dependencies, are available on PyPI and can be installed using `pip`. -However, the EDGE2D module will need to be installed from this repository. - -Note also that a [bug](https://github.com/cython/cython/issues/2918) in Cython prevents Cherab submodules from installing correctly. -This bug is fixed, but not yet released in the stable version of Cython. -As a result, you will need to install the latest alpha version of Cython before installing this package. - -First, clone this repository, then do: +However, the EDGE2D module will need to be installed from this repository: ```bash -pip install -U cython==3.0a5 -pip install cherab -pip install +pip install git@https://github.com/cherab/edge2d ``` This will pull in `cherab-core`, `raysect` `numpy` and other dependencies, then build and install the EDGE2D module. @@ -64,6 +56,8 @@ export PYTHONPATH=$PYTHONPATH:$EPROCDIR/python export PYTHONPATH=$PYTHONPATH:$EPROCDIR/python/eproc ``` +Demos are installed at `~/venvs/cherab-venv/share/cherab/demos/edge2d`. Please see the examples in this directory for an illustration of how to use the module. + ### Developers diff --git a/cherab/edge2d/models/line_emitter.pyx b/cherab/edge2d/models/line_emitter.pyx index fff6099..ef7f163 100755 --- a/cherab/edge2d/models/line_emitter.pyx +++ b/cherab/edge2d/models/line_emitter.pyx @@ -103,7 +103,7 @@ cdef class Edge2DLineEmitter(PlasmaModel): self._wavelength = self._atomic_data.wavelength(self._line.element, self._line.charge, self._line.transition) # instance line shape renderer - self._lineshape = self._lineshape_class(self._line, self._wavelength, self._target_species, self._plasma, + self._lineshape = self._lineshape_class(self._line, self._wavelength, self._target_species, self._plasma, self._atomic_data, *self._lineshape_args, **self._lineshape_kwargs) def _change(self): diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..3d17489 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools", "oldest-supported-numpy", "cython~=3.0", "raysect==0.8.1.*", "cherab==1.5.*"] +build-backend="setuptools.build_meta" diff --git a/requirements.txt b/requirements.txt index fdad365..27e2c31 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,3 @@ -cherab +cherab==1.5.* +raysect==0.8.1.* +cython~=3.0 diff --git a/setup.py b/setup.py index fc8d429..59a88b3 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,11 @@ +from collections import defaultdict from setuptools import setup, find_packages, Extension from Cython.Build import cythonize import sys import numpy import os import os.path as path +from pathlib import Path force = False profile = False @@ -34,13 +36,46 @@ else: directives = {} +# Include demos in a separate directory in the distribution as data_files. +demo_parent_path = Path("share/cherab/demos/edge2d") +data_files = defaultdict(list) +demos_source = Path("demos") +for item in demos_source.rglob("*"): + if item.is_file(): + install_dir = demo_parent_path / item.parent.relative_to(demos_source) + data_files[str(install_dir)].append(str(item)) +data_files = list(data_files.items()) + +with open("README.md") as f: + long_description = f.read() + setup( name="cherab-edge2d", - version="0.1.0", + version="0.2.0", license="EUPL 1.1", namespace_packages=['cherab'], + description="Cherab spectroscopy framework: EDGE2D submodule", + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Science/Research", + "Intended Audience :: Education", + "Intended Audience :: Developers", + "Natural Language :: English", + "Operating System :: POSIX :: Linux", + "Programming Language :: Cython", + "Programming Language :: Python :: 3", + "Topic :: Scientific/Engineering :: Physics", + ], + url="https://github.com/cherab", + project_urls=dict( + Tracker="https://github.com/cherab/edge2d/issues", + Documentation="https://cherab.github.io/documentation/", + ), + long_description=long_description, + long_description_content_type="text/markdown", packages=find_packages(), include_package_data=True, + install_requires=["raysect==0.8.1.*", "cherab==1.5.*"], ext_modules=cythonize(extensions, force=force, compiler_directives=directives) ) From 5683302647fbf26e8716987f508ac58d40dabcb0 Mon Sep 17 00:00:00 2001 From: vsnever Date: Wed, 11 Sep 2024 22:11:31 +0200 Subject: [PATCH 2/2] Specify package_data in setup.py and add missing data_files. --- setup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 59a88b3..35097f2 100644 --- a/setup.py +++ b/setup.py @@ -75,7 +75,11 @@ long_description=long_description, long_description_content_type="text/markdown", packages=find_packages(), - include_package_data=True, + package_data={"": [ + "**/*.pyx", "**/*.pxd", # Needed to build Cython extensions. + ], + }, + data_files=data_files, install_requires=["raysect==0.8.1.*", "cherab==1.5.*"], ext_modules=cythonize(extensions, force=force, compiler_directives=directives) )