From a86e7fc1a120ccf609c44fee52b48cf0180051f1 Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Tue, 3 Dec 2024 17:46:45 -0600 Subject: [PATCH 1/7] add pyproject.toml remove version.py change PyNeb to pyneb in setup.py --- pyneb/__init__.py | 3 ++- pyneb/version.py | 3 --- pyproject.toml | 50 +++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 2 +- 4 files changed, 53 insertions(+), 5 deletions(-) delete mode 100644 pyneb/version.py create mode 100644 pyproject.toml diff --git a/pyneb/__init__.py b/pyneb/__init__.py index 225f2ddc..2e990da0 100644 --- a/pyneb/__init__.py +++ b/pyneb/__init__.py @@ -5,8 +5,8 @@ PyNeb - python package for the analysis of emission lines """ import sys +import importlib.metadata -from .version import __version__ from .utils.Config import _Config config = _Config() log_ = config.log_ @@ -44,6 +44,7 @@ __pyversion__ = sys.version_info[0] +__version__ = importlib.metadata.version("pyneb") log_.message('Starting PyNeb version %s' % __version__, calling='PyNeb') if sys.version_info[:2] < (2, 6): diff --git a/pyneb/version.py b/pyneb/version.py deleted file mode 100644 index 56f4af50..00000000 --- a/pyneb/version.py +++ /dev/null @@ -1,3 +0,0 @@ -# PyNeb version -__version__ = '1.1.22' - diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..b4d262d5 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,50 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "pyneb" +"version" = "1.1.23" +requires-python = ">= 3.8" +dependencies = [ +"numpy", +"matplotlib", +"scipy", +# astropy +# hdf5 +] +description = "A Python package for nebular analysis" +authors = [ + { name = "Christophe Morisset", email = "chris.morisset@gmail.com" }, + { name = "Valentina Luridiana"} +] +license = { file = "LICENCE.md" } +readme = "README.rst" +keywords = ["nebular", "analysis", "astronomy"] + +[project.urls] +Homepage = "http://www.iac.es/proyecto/PyNeb/" +Repository = "https://github.com/Morisset/PyNeb_devel" +Documentation = "http://morisset.github.io/PyNeb_devel/" +Changelog = "https://github.com/Morisset/PyNeb_devel/tree/master/docs/CHANGES" + +[project.optional-dependencies] + +[tool.setuptools] +packages = ['pyneb', + 'pyneb.core', + 'pyneb.plot', + 'pyneb.utils', + 'pyneb.extinction'] + +[tool.setuptools.package-data] +pyneb = ['atomic_data_fits/*.fits', + 'atomic_data_fits/*.hdf5', + 'atomic_data_fits/old_fits/*.fits', + 'atomic_data/*.dat', + 'atomic_data/*.func', + 'atomic_data/*.txt', + 'atomic_data/levels/*.dat', + 'atomic_data/deprecated/*.dat'] +pyneb.extinction = ['*.txt'] +pyneb.plot = ['level_diagrams/*.png'] diff --git a/setup.py b/setup.py index 4742f317..37f256f6 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ from pyneb.version import __version__ -setup(name='PyNeb', +setup(name='pyneb', version=__version__, description='Nebular tools', author='Christophe Morisset, Valentina Luridiana', From d4dd54a76c0390a046b3a8da08c96b7790ddc5a3 Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Tue, 3 Dec 2024 17:52:10 -0600 Subject: [PATCH 2/7] rename setup.py to avoid its use --- setup.py => OLD_setup.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename setup.py => OLD_setup.py (100%) diff --git a/setup.py b/OLD_setup.py similarity index 100% rename from setup.py rename to OLD_setup.py From 325efb35dd1f6bfa3311dbc0acbe663a1c19401f Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Tue, 3 Dec 2024 17:57:46 -0600 Subject: [PATCH 3/7] 1.1.23b1 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b4d262d5..b698b350 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pyneb" -"version" = "1.1.23" +"version" = "1.1.23b1" requires-python = ">= 3.8" dependencies = [ "numpy", From c13a695bcfdc2eb4ea5390cde444b21cb4474a8c Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Tue, 3 Dec 2024 19:17:13 -0600 Subject: [PATCH 4/7] setup.py comes back --- pyproject.toml | 18 ------------------ OLD_setup.py => setup.py | 18 +----------------- 2 files changed, 1 insertion(+), 35 deletions(-) rename OLD_setup.py => setup.py (51%) diff --git a/pyproject.toml b/pyproject.toml index b698b350..cdb32356 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,21 +30,3 @@ Changelog = "https://github.com/Morisset/PyNeb_devel/tree/master/docs/CHANGES" [project.optional-dependencies] -[tool.setuptools] -packages = ['pyneb', - 'pyneb.core', - 'pyneb.plot', - 'pyneb.utils', - 'pyneb.extinction'] - -[tool.setuptools.package-data] -pyneb = ['atomic_data_fits/*.fits', - 'atomic_data_fits/*.hdf5', - 'atomic_data_fits/old_fits/*.fits', - 'atomic_data/*.dat', - 'atomic_data/*.func', - 'atomic_data/*.txt', - 'atomic_data/levels/*.dat', - 'atomic_data/deprecated/*.dat'] -pyneb.extinction = ['*.txt'] -pyneb.plot = ['level_diagrams/*.png'] diff --git a/OLD_setup.py b/setup.py similarity index 51% rename from OLD_setup.py rename to setup.py index 37f256f6..21c13336 100644 --- a/OLD_setup.py +++ b/setup.py @@ -1,26 +1,10 @@ #!/usr/bin/env python # Always prefer setuptools over distutils -from setuptools import setup, find_packages +from setuptools import setup # To use a consistent encoding -from codecs import open -from os import path - -here = path.abspath(path.dirname(__file__)) -# Get the long description from the README file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: - long_description = f.read() - -from pyneb.version import __version__ setup(name='pyneb', - version=__version__, - description='Nebular tools', - author='Christophe Morisset, Valentina Luridiana', - long_description=long_description, - author_email='chris.morisset@gmail.com', - url='http://www.iac.es/proyecto/PyNeb/', - py_modules=['pyneb.test.test_pyneb'], packages=['pyneb', 'pyneb.core', 'pyneb.plot', From db0c6a6a8a8955b828435390d4678b404cba8072 Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Wed, 4 Dec 2024 14:40:15 -0600 Subject: [PATCH 5/7] update for use of pyproject.toml --- pyneb/__init__.py | 8 +++++--- pyneb/core/pynebcore.py | 6 ++---- pyneb/utils/Config.py | 14 +++++++++----- pyproject.toml | 22 ++++++++++++++++++++-- setup.py | 39 +++++++++++++++++++++------------------ updatePyNeb.md | 4 ++-- 6 files changed, 59 insertions(+), 34 deletions(-) diff --git a/pyneb/__init__.py b/pyneb/__init__.py index 2e990da0..29df76e2 100644 --- a/pyneb/__init__.py +++ b/pyneb/__init__.py @@ -5,7 +5,10 @@ PyNeb - python package for the analysis of emission lines """ import sys -import importlib.metadata + +#from .version import __version__ +from importlib.metadata import version +__version__ = version("PyNeb") from .utils.Config import _Config config = _Config() @@ -44,8 +47,7 @@ __pyversion__ = sys.version_info[0] -__version__ = importlib.metadata.version("pyneb") -log_.message('Starting PyNeb version %s' % __version__, calling='PyNeb') +log_.message('Starting PyNeb version %s' % __version__, calling='pyneb') if sys.version_info[:2] < (2, 6): log_.warn('Python version >= 2.6 needed, seems you have {0}'.format(sys.version_info), calling='PyNeb') diff --git a/pyneb/core/pynebcore.py b/pyneb/core/pynebcore.py index f9aa1d5d..b18c96cb 100644 --- a/pyneb/core/pynebcore.py +++ b/pyneb/core/pynebcore.py @@ -47,8 +47,6 @@ if config.INSTALLED['ai4neb']: from ai4neb import manage_RM - - # Change the profiler to 'cpu', 'mem' or None to profile the execution of Atom. profiler = None #profiler = 'cpu' @@ -1685,7 +1683,7 @@ def _getPopulations_ANN(self, tem, den, product=True, NLevels=None): Private method to obtain level population using Artificial Neuron Network. """ if not config.INSTALLED['ai4neb']: - self.log_.error('_getPopulations_ANN cannot be used in absence of ai4neb package', + self.log_.error('_getPopulations_ANN cannot be used if ai4neb is not imported. Try to run pn.config.import_AI4Neb().', calling=self.calling) return None @@ -2338,7 +2336,7 @@ def _getTemDen_ANN(self, int_ratio, tem= -1, den= -1, lev_i1= -1, lev_j1= -1, le wave1= -1, wave2= -1, log=True, start_x= -1, end_x= -1, to_eval=None): if not config.INSTALLED['ai4neb']: - self.log_.error('_getTemDen_ANN cannot be used in absence of ai4neb package', + self.log_.error('_getTemDen_ANN cannot be used if ai4neb is not imported. Try to run pn.config.import_AI4Neb().', calling=self.calling) return None diff --git a/pyneb/utils/Config.py b/pyneb/utils/Config.py index 110f906c..1f8a8426 100644 --- a/pyneb/utils/Config.py +++ b/pyneb/utils/Config.py @@ -100,11 +100,8 @@ def __init__(self): self.INSTALLED['cvxopt'] = True except: self.INSTALLED['cvxopt'] = False - try: - from ai4neb import manage_RM - self.INSTALLED['ai4neb'] = True - except: - self.INSTALLED['ai4neb'] = False + + self.INSTALLED['ai4neb'] = False self.DataFiles = {} @@ -118,6 +115,13 @@ def __init__(self): self.vactoair_low_wl = 2000. # UV in vacuum self.vactoair_high_wl = 1e30 # no upper limit, IR in air!!! + def import_AI4Neb(self): + try: + from ai4neb import manage_RM + self.INSTALLED['ai4neb'] = True + except: + self.INSTALLED['ai4neb'] = False + def set_noExtrapol(self, value): self._noExtrapol = bool(value) diff --git a/pyproject.toml b/pyproject.toml index cdb32356..8f5f796c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools", "wheel"] +requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "pyneb" -"version" = "1.1.23b1" +version = "1.1.23b9" requires-python = ">= 3.8" dependencies = [ "numpy", @@ -30,3 +30,21 @@ Changelog = "https://github.com/Morisset/PyNeb_devel/tree/master/docs/CHANGES" [project.optional-dependencies] +[tool.setuptools] +packages=['pyneb', + 'pyneb.core', + 'pyneb.plot', + 'pyneb.utils', + 'pyneb.extinction'] + +[tool.setuptools.package-data] +'pyneb'=['atomic_data_fits/*.fits', + 'atomic_data_fits/*.hdf5', + 'atomic_data_fits/old_fits/*.fits', + 'atomic_data/*.dat', + 'atomic_data/*.func', + 'atomic_data/*.txt', + 'atomic_data/levels/*.dat', + 'atomic_data/deprecated/*.dat'] +'pyneb.extinction'=['*.txt'] +'pyneb.plot'=['level_diagrams/*.png'] diff --git a/setup.py b/setup.py index 21c13336..f55fa223 100644 --- a/setup.py +++ b/setup.py @@ -4,22 +4,25 @@ from setuptools import setup # To use a consistent encoding -setup(name='pyneb', - packages=['pyneb', - 'pyneb.core', - 'pyneb.plot', - 'pyneb.utils', - 'pyneb.extinction'], - package_data={'pyneb':['atomic_data_fits/*.fits', - 'atomic_data_fits/*.hdf5', - 'atomic_data_fits/old_fits/*.fits', - 'atomic_data/*.dat', - 'atomic_data/*.func', - 'atomic_data/*.txt', - 'atomic_data/levels/*.dat', - 'atomic_data/deprecated/*.dat'], - 'pyneb.extinction':['*.txt'], - 'pyneb.plot':['level_diagrams/*.png'] - } - ) +#from pyneb.version import __version__ + +setup() +#name='PyNeb', +# packages=['pyneb', +# 'pyneb.core', +# 'pyneb.plot', +# 'pyneb.utils', +# 'pyneb.extinction'], +# package_data={'pyneb':['atomic_data_fits/*.fits', +# 'atomic_data_fits/*.hdf5', +# 'atomic_data_fits/old_fits/*.fits', +# 'atomic_data/*.dat', +# 'atomic_data/*.func', +# 'atomic_data/*.txt', +# 'atomic_data/levels/*.dat', +# 'atomic_data/deprecated/*.dat'], +# 'pyneb.extinction':['*.txt'], +# 'pyneb.plot':['level_diagrams/*.png'] +# } +# ) diff --git a/updatePyNeb.md b/updatePyNeb.md index b613d743..1d155790 100644 --- a/updatePyNeb.md +++ b/updatePyNeb.md @@ -29,9 +29,9 @@ Publish the new version on the pypi server * Switch to master branch * synchronize with repository: git pull * Run the following from the root directory (where dist is) and check the tar file is created in dist: - `python setup.py sdist` + `python -m build` * Run the following to upload the tar file to pypi server. **Update the value of the distribution in {0}:** - `twine upload dist/PyNeb-{0}.tar.gz` + `twine upload dist/pyneb-{0}*` * Check that the new relase is the current one on pypi server: https://pypi.org/project/PyNeb/ Publish the new release on the Google group From 7de41de6232863b9997b19d368fd244339153ebf Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Wed, 4 Dec 2024 14:58:54 -0600 Subject: [PATCH 6/7] add h5py to dependencies --- pyproject.toml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 8f5f796c..8a6ba3fb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,8 +10,8 @@ dependencies = [ "numpy", "matplotlib", "scipy", +"h5py", # astropy -# hdf5 ] description = "A Python package for nebular analysis" authors = [ @@ -28,8 +28,6 @@ Repository = "https://github.com/Morisset/PyNeb_devel" Documentation = "http://morisset.github.io/PyNeb_devel/" Changelog = "https://github.com/Morisset/PyNeb_devel/tree/master/docs/CHANGES" -[project.optional-dependencies] - [tool.setuptools] packages=['pyneb', 'pyneb.core', From c0a73abf1ad5f0656e09a0ace23cca0fd47db8be Mon Sep 17 00:00:00 2001 From: Christophe Morisset Date: Wed, 4 Dec 2024 15:05:56 -0600 Subject: [PATCH 7/7] prepare release 1.1.23 --- docs/CHANGES/1.1.22-1.1.23.txt | 4 ++++ pyproject.toml | 2 +- updatePyNeb.md | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 docs/CHANGES/1.1.22-1.1.23.txt diff --git a/docs/CHANGES/1.1.22-1.1.23.txt b/docs/CHANGES/1.1.22-1.1.23.txt new file mode 100644 index 00000000..ca52b2a0 --- /dev/null +++ b/docs/CHANGES/1.1.22-1.1.23.txt @@ -0,0 +1,4 @@ +* Migrate the setup to pyproject.toml. Minimalist version of setup.py is kept. +* Remove the version.py file, the version is now in pyproject.toml +* Move the import ai4neb into a specific config method: pn.config.import_AI4Neb() before using the Machine Learning tools. This avoid annoying message about Tensorflow to appear and speedup the import of pyneb when not using ML facilities. +* Change the name of the package to pyneb instead of PyNeb (seems to be mandatory soon). diff --git a/pyproject.toml b/pyproject.toml index 8a6ba3fb..d88046d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "pyneb" -version = "1.1.23b9" +version = "1.1.23" requires-python = ">= 3.8" dependencies = [ "numpy", diff --git a/updatePyNeb.md b/updatePyNeb.md index 1d155790..acb251e8 100644 --- a/updatePyNeb.md +++ b/updatePyNeb.md @@ -16,10 +16,10 @@ Pool request to master Once the devel branch is validated and passed all the tests: -* update the version removing the beta indices +* update the version in pyproject.toml removing the beta indices * Merge it to the master branch -Make a new release tab on the github server +Make a new release tag on the github server ==============================