-
Notifications
You must be signed in to change notification settings - Fork 15
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
refactor(build): change setup.py to pyproject.toml and supress cython warning #293
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f9538b0
refactor(build): change setup.py to pyproject.toml and improve cython
hassec 5c2f0cb
upgrade python to 3.8
hassec 605a8c2
fix package data inclusion
hassec af38855
running test in place requires editable install to create omas_cython…
hassec 0620f56
Allow python >=3.7 & small plotting fix
hassec 2df9efe
ci: install hdf5 and netcdf
hassec d4b9e54
ci: ensure numpy is installed for pygacode
hassec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
[build-system] | ||
requires = ["setuptools", "Cython"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools.packages.find] | ||
where = ["."] | ||
exclude = ["sphinx*"] | ||
|
||
[tool.setuptools.package-data] | ||
"*" = ["*.json", "*.dat"] | ||
"omas.samples" = ["*"] | ||
"omas"=["*.pyx"] | ||
|
||
[tool.setuptools.dynamic] | ||
version = {file = "omas/version"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This automatically sets the version to what is found in |
||
|
||
[project] | ||
name = 'omas' | ||
dynamic = ["version"] | ||
description = 'Ordered Multidimensional Array Structures' | ||
authors = [ | ||
{name = 'Orso Meneghini', email = '[email protected]'}, | ||
] | ||
classifiers = [ | ||
'Development Status :: 5 - Production/Stable', | ||
'Programming Language :: Python', | ||
'Programming Language :: Python :: 3', | ||
'Programming Language :: Python :: 3 :: Only', | ||
'License :: OSI Approved :: MIT License', | ||
] | ||
keywords = ["integrated modeling", "OMFIT", "IMAS", "ITER"] | ||
|
||
requires-python = '>=3.7' | ||
dependencies = [ | ||
'numpy>=1.16.1', | ||
'uncertainties', | ||
'pint', | ||
'netCDF4', | ||
'boto3', | ||
'matplotlib', | ||
'scipy', | ||
'h5py', | ||
'pymongo', | ||
'dnspython', | ||
'xmltodict', | ||
'xarray', | ||
'tqdm', | ||
] | ||
readme="README.md" | ||
|
||
[project.urls] | ||
Homepage = 'https://gafusion.github.io/omas' | ||
Source = 'https://github.com/gafusion/omas' | ||
|
||
[project.optional-dependencies] | ||
machine = [ | ||
'omfit_classes', | ||
'pexpect', | ||
'fortranformat', | ||
'pygacode', | ||
] | ||
hdc = ['pyhdc'] | ||
imas = ['imas'] | ||
uda = ['pyuda'] | ||
build_sdist = ['build'] | ||
build_structures = ['bs4'] | ||
build_documentation = ['Sphinx', 'sphinx-bootstrap-theme', 'sphinx-gallery', 'Pillow'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,128 +1,6 @@ | ||
import os | ||
import sys | ||
import glob | ||
import subprocess | ||
|
||
install_requires = [ | ||
'numpy>=1.16.1', | ||
'uncertainties', | ||
'pint', | ||
'netCDF4', | ||
'boto3', | ||
'matplotlib', | ||
'scipy', | ||
'h5py', | ||
'pymongo', | ||
'dnspython', | ||
'xmltodict', | ||
'xarray', | ||
'setuptools>=41.2', | ||
'tqdm', | ||
'Cython', | ||
] | ||
|
||
extras_require = { | ||
'machine': [ | ||
'omfit_classes', | ||
'pexpect', | ||
'fortranformat', | ||
'pygacode', | ||
], | ||
'hdc': ['pyhdc'], | ||
'imas': ['imas'], | ||
'uda': ['pyuda'], | ||
'build_structures': ['bs4'], | ||
'build_documentation': ['Sphinx', 'sphinx-bootstrap-theme', 'sphinx-gallery', 'Pillow'], | ||
} | ||
|
||
# Add .json IMAS structure files to the package | ||
here = os.path.abspath(os.path.split(__file__)[0]) + os.sep | ||
|
||
# Automatically generate requirement.txt file if this is the OMAS repo and requirements.txt is missing | ||
if os.path.exists(here + '.git') and not os.path.exists(here + 'requirements.txt'): | ||
with open(here + 'requirements.txt', 'w') as f: | ||
f.write('# Do not edit this file by hand, operate on setup.py instead\n#\n') | ||
f.write('# usage: pip install -r requirements.txt\n\n') | ||
for item in install_requires: | ||
f.write(item.ljust(25) + '# required\n') | ||
for requirement in extras_require: | ||
f.write('\n') | ||
for item in extras_require[requirement]: | ||
f.write('# ' + item.ljust(25) + '# %s\n' % requirement) | ||
|
||
packages = ['omas', 'omas.examples', 'omas.samples', 'omas.tests', 'omas.utilities'] | ||
package_data = { | ||
'omas': ['*.py', '*.pyx', 'version'], | ||
'omas.examples': ['*.py'], | ||
'omas.samples': ['*'], | ||
'omas.tests': ['*.py'], | ||
'omas.utilities': ['*.py'], | ||
} | ||
|
||
machine_mappings_dir = here + os.sep + 'omas' + os.sep + 'machine_mappings' | ||
for item in glob.glob(os.sep.join([here, 'omas', 'imas_structures', '*'])): | ||
packages.append('omas.imas_structures.' + os.path.split(item)[1]) | ||
package_data['omas.imas_structures.' + os.path.split(item)[1]] = ['*.json'] | ||
for retry in [1, 2]: | ||
if os.path.exists(here + '.git') and retry == 1: | ||
try: | ||
tmp = f'pushd {machine_mappings_dir}; git ls-files; popd' | ||
machine_mappings_files = subprocess.check_output(tmp, shell=True).decode("utf-8").strip().split('\n')[2:-1] | ||
machine_mappings_files = ['omas' + os.sep + 'machine_mappings' + os.sep + k for k in machine_mappings_files] | ||
except subprocess.CalledProcessError: | ||
pass | ||
else: | ||
print("setup.py machine_mappings_files based on git") | ||
break | ||
else: | ||
machine_mappings_files = [] | ||
for root, subdirs, files in os.walk(machine_mappings_dir): | ||
root = root[len(machine_mappings_dir) + 1 :] | ||
for file in reversed(files): | ||
machine_mappings_files.append('omas' + os.sep + 'machine_mappings' + os.sep + root + os.sep + file) | ||
dirs = {os.path.dirname(file): [] for file in sorted(machine_mappings_files)} | ||
for file in machine_mappings_files: | ||
dirs[os.path.dirname(file)].append(os.path.basename(file)) | ||
for dir in dirs: | ||
packages.append(dir.replace('/', '.')) | ||
package_data[dir.replace('/', '.')] = dirs[dir] | ||
|
||
long_description = ''' | ||
OMAS is a Python library designed to simplify the interface of third-party codes with the `ITER <http://iter.org>`_ Integrated Modeling and Analysis Suite (`IMAS <https://confluence.iter.org/display/IMP>`_). | ||
|
||
* It provides a **convenient Python API** | ||
|
||
* capable of storing data with **different file/database formats** | ||
|
||
* in a form that is **always compatible with the IMAS data model** | ||
|
||
Mapping the physics codes I/O to the IMAS data model is done in third party Python codes such as the `OMFIT framework <https://omfit.io>`_. | ||
''' | ||
|
||
print() | ||
print('INFO: optional dependencies:') | ||
from pprint import pprint | ||
|
||
pprint(extras_require) | ||
print() | ||
print('INFO: run the `imports_check.py` script to quickly verify that all Python dependencies for OMAS are installed') | ||
print() | ||
|
||
from setuptools import setup | ||
from setuptools import Extension, setup | ||
from Cython.Build import cythonize | ||
|
||
setup( | ||
name='omas', | ||
version=open(here + 'omas/version', 'r').read().strip(), | ||
description='Ordered Multidimensional Array Structures', | ||
url='https://gafusion.github.io/omas', | ||
author='Orso Meneghini', | ||
license='MIT', | ||
classifiers=['License :: OSI Approved :: MIT License', 'Programming Language :: Python :: 3'], | ||
keywords='integrated modeling OMFIT IMAS ITER', | ||
long_description=long_description, | ||
long_description_content_type='text/markdown', | ||
packages=packages, | ||
package_data=package_data, | ||
install_requires=install_requires, | ||
extras_require=extras_require, | ||
ext_modules = cythonize("omas/omas_cython.pyx") | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this change the compiled version of
omas_cython
should be available to everyone. Also windows users.