-
Notifications
You must be signed in to change notification settings - Fork 29
/
setup.py
95 lines (80 loc) · 3.49 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from setuptools import setup
from setuptools import Extension
from setuptools import find_packages
import platform
from pkg_resources import get_build_platform
from Cython.Build import cythonize
import numpy as np
import os
import sys
description = "A Python interface to the electron microscopy simulation program QSTEM."
long_description = """\
QSTEM is a program for quantitative image simulation in electron microscopy, including TEM, STEM and CBED image simulation.
This project interfaces the QSTEM code with Python and the Atomic Simulation Environment (ASE) to provide a single environment for building models, simulating and analysing images.
This package requires that the FFTW library has already been installed.
"""
include_dirs = [
np.get_include(),
os.path.join(os.getcwd(), 'fftw'),
os.path.join(os.getcwd(), 'source/'),
]
# Detect Anaconda and use Anaconda's FFTW on Windows.
is_conda = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))
is_windows = get_build_platform() in ['win32', 'win-amd64']
is_mac = 'macosx' in get_build_platform()
if is_mac:
is_highsierra_or_older = platform.mac_ver()[0] < '10.14'
if not is_conda and get_build_platform() == 'win32':
# 32-bit Windows and not Anaconda: Use FFTW packaged with PyQSTEM
if sys.version_info[0] == 3:
library_dirs = ['fftw/win32']
elif sys.version_info[0] == 2:
library_dirs = ['fftw/win32/dll']
libraries = ['libfftw3-3', 'libfftw3f-3', 'libfftw3l-3']
elif not is_conda and get_build_platform() == 'win-amd64':
# 64-bit Windows and not Anaconda: Use FFTW packaged with PyQSTEM
if sys.version_info[0] == 3:
library_dirs = ['fftw/win64']
elif sys.version_info[0] == 2:
library_dirs = ['fftw/win64/dll']
libraries = ['libfftw3-3', 'libfftw3f-3', 'libfftw3l-3']
else:
# Linux, MacOS and Anaconda on Windows.
library_dirs = []
libraries = ['fftw3','fftw3f']
sources = ['memory_fftw3.cpp','data_containers.cpp','imagelib_fftw3.cpp',
'stemlib.cpp','stemutil.cpp','fileio_fftw3.cpp','matrixlib.cpp','readparams.cpp']
sources = ['source/' + x for x in sources]
sources += ['pyqstem/qstem_interface.pyx','pyqstem/QSTEM.cpp']
compargs = []
linkargs = []
if is_windows:
compargs += ['-D MS_WIN64']
else:
compargs += ['-std=c++11']
if is_mac and is_highsierra_or_older:
# These options are needed by the clang compiler on macOS X 10.13
# 'High Sierra' or older, it is default on 10.14 or newer.
compargs += ['-stdlib=libc++']
linkargs += ['-stdlib=libc++']
setup(name='pyqstem',
packages = find_packages(),
version = '1.0.3',
description=description,
long_description=long_description,
maintainer="Jacob Madsen",
maintainer_email="jacob.jma@gmail.com",
url="https://github.com/jacobjma/PyQSTEM",
license='GPLv3',
data_files = [("", ["License.txt"])],
platforms = ["Windows", "Linux", "Mac OS-X", "Unix"],
install_requires=['matplotlib!=3.0.0', 'ase', 'Cython', 'scikit-image', 'pillow'],
ext_modules=cythonize(Extension('pyqstem.qstem_interface',
sources=sources,
library_dirs=library_dirs,
libraries=libraries,
include_dirs=include_dirs,
extra_compile_args=compargs,
extra_link_args=linkargs,
language='c++')),
)