# coding: utf-8 # vim: set fdm=indent ts=4 sw=4 sts=4 et tw=80 ai cc=+0 mouse=a nu : from setuptools import setup, Extension, find_packages from distutils.file_util import copy_file from distutils.command.build import build as _build from setuptools.command.build_ext import build_ext as _build_ext from setuptools.command.install import install as _install from distutils.command.clean import clean as _clean import subprocess import traceback import os import sys sys.path.insert(0, "msspec") from version import __version__ SETUP_REQUIRES = ['scons', 'setuptools_scm'] with open('requirements.txt', 'r') as fd: REQUIREMENTS = fd.read().strip().split('\n') subprocess.call(["pip", "install"] + SETUP_REQUIRES) class BuildExtCmd(_build_ext): def run(self): src_dir = "." subprocess.call(['scons']) for ext in self.extensions: fullname = self.get_ext_fullname(ext.name) filename = self.get_ext_filename(fullname) print("building ", filename) src_filename = filename dest_filename = os.path.join(self.build_lib, filename) os.makedirs(os.path.dirname(dest_filename), exist_ok=True) copy_file(src_filename, dest_filename, verbose=self.verbose, dry_run=self.dry_run) class BuildCmd(_build): def run(self): print("build_lib ", self.build_lib) self.run_command("build_ext") _build.run(self) class InstallCmd(_install): def run(self): self.run_command("build") _install.run(self) class CleanCmd(_clean): def run(self): subprocess.call(['scons', '-c']) _clean.run(self) if __name__ == "__main__": module_phagen = Extension('msspec.phagen.fortran.libphagen',['msspec/phagen/fortran/main.f']) module_spec_phd_mi = Extension('msspec.spec.fortran._phd_mi_noso_nosp_nosym',['msspec/spec/fortran/phd_mi_noso_nosp_nosym/main.f']) module_spec_phd_se = Extension('msspec.spec.fortran._phd_se_noso_nosp_nosym',['msspec/spec/fortran/phd_se_noso_nosp_nosym/main.f']) module_eig_mi = Extension('msspec.spec.fortran._eig_mi',['msspec/spec/fortran/eig/mi/main.f']) module_eig_pw = Extension('msspec.spec.fortran._eig_pw',['msspec/spec/fortran/eig/pw/main.f']) setup(name='msspec', version=__version__, include_package_data=True, ext_modules=[module_phagen, module_spec_phd_mi, module_spec_phd_se, module_eig_mi, module_eig_pw], cmdclass={'build' : BuildCmd, 'build_ext': BuildExtCmd, 'clean' : CleanCmd, 'install' : InstallCmd, }, packages=find_packages(include='msspec.*'), setup_requires=SETUP_REQUIRES, install_requires=REQUIREMENTS, author='Didier Sébilleau, Sylvain Tricot', author_email='sylvain.tricot@univ-rennes1.fr', maintainer='Sylvain Tricot', maintainer_email='sylvain.tricot@univ-rennes1.fr', url='https://msspec.cnrs.fr', description=('A multiple scattering package for sepectroscopies using ' 'electrons to probe materials'), long_description="""MsSpec is a Fortran package to compute the cross-section of several spectroscopies involving one (or more) electron(s) as the probe. This package provides a python interface to control all the steps of the calculation. Available spectroscopies: * Photoelectron diffraction * Auger electron diffraction * Low energy electron diffraction * X-Ray absorption spectroscopy * Auger Photoelectron coincidence spectroscopy * Computation of the spectral radius""", download_url='https://msspec.cnrs.fr/downloads.html', # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ 'Development Status :: 3 - Alpha', 'Environment :: Console', 'Intended Audience :: Science/Research', 'License :: OSI Approved :: GNU General Public License (GPL)', 'Natural Language :: English', 'Operating System :: Microsoft :: Windows :: Windows 10', 'Operating System :: POSIX :: Linux', 'Operating System :: MacOS :: MacOS X', 'Programming Language :: Fortran', 'Programming Language :: Python :: 3 :: Only', 'Topic :: Scientific/Engineering :: Physics', ], keywords='spectroscopy atom electron photon multiple scattering', license='GPL', )