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 0000000..ca52b2a --- /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/pyneb/__init__.py b/pyneb/__init__.py index 225f2dd..29df76e 100644 --- a/pyneb/__init__.py +++ b/pyneb/__init__.py @@ -6,7 +6,10 @@ """ import sys -from .version import __version__ +#from .version import __version__ +from importlib.metadata import version +__version__ = version("PyNeb") + from .utils.Config import _Config config = _Config() log_ = config.log_ @@ -44,7 +47,7 @@ __pyversion__ = sys.version_info[0] -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 f9aa1d5..b18c96c 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 110f906..1f8a842 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/pyneb/version.py b/pyneb/version.py deleted file mode 100644 index 56f4af5..0000000 --- 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 0000000..d88046d --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "pyneb" +version = "1.1.23" +requires-python = ">= 3.8" +dependencies = [ +"numpy", +"matplotlib", +"scipy", +"h5py", +# astropy +] +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" + +[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 4742f31..f55fa22 100644 --- a/setup.py +++ b/setup.py @@ -1,41 +1,28 @@ #!/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__ -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', - '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'] - } - ) +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 b613d74..acb251e 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 ============================== @@ -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