Skip to content

Commit

Permalink
Merge pull request #44 from Morisset/devel
Browse files Browse the repository at this point in the history
1.1.23
  • Loading branch information
Morisset authored Dec 4, 2024
2 parents b51d38e + 85a20a0 commit 2ad3f70
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 52 deletions.
4 changes: 4 additions & 0 deletions docs/CHANGES/1.1.22-1.1.23.txt
Original file line number Diff line number Diff line change
@@ -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).
7 changes: 5 additions & 2 deletions pyneb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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_
Expand Down Expand Up @@ -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')
Expand Down
6 changes: 2 additions & 4 deletions pyneb/core/pynebcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions pyneb/utils/Config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -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)

Expand Down
3 changes: 0 additions & 3 deletions pyneb/version.py

This file was deleted.

48 changes: 48 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = "[email protected]" },
{ 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']
55 changes: 21 additions & 34 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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='[email protected]',
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']
# }
# )

8 changes: 4 additions & 4 deletions updatePyNeb.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
==============================


Expand All @@ -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
Expand Down

0 comments on commit 2ad3f70

Please sign in to comment.