1#!/usr/bin/env python3 2 3# Copyright (C) 2007-2017 CAMd 4# Please see the accompanying LICENSE file for further information. 5 6import os 7import re 8import sys 9from setuptools import setup, find_packages 10from setuptools.command.build_py import build_py as _build_py 11from glob import glob 12from os.path import join 13 14python_min_version = (3, 6) 15python_requires = '>=' + '.'.join(str(num) for num in python_min_version) 16 17 18if sys.version_info < python_min_version: 19 raise SystemExit('Python 3.6 or later is required!') 20 21 22install_requires = [ 23 'numpy>=1.15.0', # July 2018 24 'scipy>=1.1.0', # May 2018 25 'matplotlib>=3.1.0', # May 2019 26] 27 28 29extras_require = { 30 'docs': [ 31 'sphinx', 32 'sphinx_rtd_theme', 33 'pillow', 34 ], 35 'test': [ 36 'pytest>=5.0.0', # required by pytest-mock 37 'pytest-mock>=3.3.0', 38 'pytest-xdist>=1.30.0', 39 ] 40} 41 42# Optional: spglib >= 1.9 43 44 45with open('README.rst') as fd: 46 long_description = fd.read() 47 48# Get the current version number: 49with open('ase/__init__.py') as fd: 50 version = re.search("__version__ = '(.*)'", fd.read()).group(1) 51 52 53package_data = {'ase': ['spacegroup/spacegroup.dat', 54 'collections/*.json', 55 'db/templates/*', 56 'db/static/*'], 57 'ase.test': ['pytest.ini', 58 'testdata/*']} 59 60 61class build_py(_build_py): 62 """Custom command to build translations.""" 63 def __init__(self, *args, **kwargs): 64 _build_py.__init__(self, *args, **kwargs) 65 # Keep list of files to appease bdist_rpm. We have to keep track of 66 # all the installed files for no particular reason. 67 self.mofiles = [] 68 69 def run(self): 70 """Compile translation files (requires gettext).""" 71 _build_py.run(self) 72 msgfmt = 'msgfmt' 73 status = os.system(msgfmt + ' -V') 74 if status == 0: 75 for pofile in sorted(glob('ase/gui/po/*/LC_MESSAGES/ag.po')): 76 dirname = join(self.build_lib, os.path.dirname(pofile)) 77 if not os.path.isdir(dirname): 78 os.makedirs(dirname) 79 mofile = join(dirname, 'ag.mo') 80 print() 81 print('Compile {}'.format(pofile)) 82 status = os.system('%s -cv %s --output-file=%s 2>&1' % 83 (msgfmt, pofile, mofile)) 84 assert status == 0, 'msgfmt failed!' 85 self.mofiles.append(mofile) 86 87 def get_outputs(self, *args, **kwargs): 88 return _build_py.get_outputs(self, *args, **kwargs) + self.mofiles 89 90 91setup(name='ase', 92 version=version, 93 description='Atomic Simulation Environment', 94 url='https://wiki.fysik.dtu.dk/ase', 95 maintainer='ASE-community', 96 maintainer_email='ase-users@listserv.fysik.dtu.dk', 97 license='LGPLv2.1+', 98 platforms=['unix'], 99 packages=find_packages(), 100 python_requires=python_requires, 101 install_requires=install_requires, 102 extras_require=extras_require, 103 package_data=package_data, 104 entry_points={'console_scripts': ['ase=ase.cli.main:main', 105 'ase-db=ase.cli.main:old', 106 'ase-gui=ase.cli.main:old', 107 'ase-run=ase.cli.main:old', 108 'ase-info=ase.cli.main:old', 109 'ase-build=ase.cli.main:old']}, 110 long_description=long_description, 111 cmdclass={'build_py': build_py}, 112 classifiers=[ 113 'Development Status :: 6 - Mature', 114 'License :: OSI Approved :: ' 115 'GNU Lesser General Public License v2 or later (LGPLv2+)', 116 'Operating System :: OS Independent', 117 'Programming Language :: Python :: 3', 118 'Programming Language :: Python :: 3.5', 119 'Programming Language :: Python :: 3.6', 120 'Programming Language :: Python :: 3.7', 121 'Topic :: Scientific/Engineering :: Physics']) 122