-
Notifications
You must be signed in to change notification settings - Fork 18
/
setup.py
109 lines (91 loc) · 4.36 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import os, platform
from setuptools import setup, find_packages
from setuptools.extension import Extension
import pip
import shutil
is_windows = 'win' in platform.system().lower()
is_linux = 'lin' in platform.system().lower()
print('Operating system: ' + platform.system())
print('Machine architecture: ' + platform.machine())
if not is_linux and not is_windows:
print(' Operating systems other than Windows or Linux are not supported.')
quit()
elif is_linux:
is_arch_aarch64 = 'aarch64' in platform.machine().lower()
is_arch_x86_64 = 'x86_64' in platform.machine().lower()
is_arch_i686 = 'i686' in platform.machine().lower()
if not is_arch_aarch64 and not is_arch_x86_64 and not is_arch_i686:
print(' Machine architecture is not supported, it must be aarch64, x86_64 or i686.')
quit()
elif is_windows:
is_arch_x86_64 = 'amd64' in platform.machine().lower()
is_32bit = 'x86' in platform.machine().lower()
if not is_arch_x86_64 and not is_32bit:
print(' Machine architecture is not supported, it must be amd64 or x86 32bit.')
quit()
if is_linux:
print('************************************************************\n')
print('Pre-install necessary packages \n')
print(' sudo apt-get install python3-pip \n')
print(' sudo pip3 install numpy \n')
print('************************************************************\n')
print('Build package: sudo -E python3 setup.py build \n')
print('Install package: sudo -E python3 setup.py install \n')
print('Create Wheel dist: sudo -E python3 setup.py sdist bdist_wheel \n')
print('Uninstall package: sudo pip3 uninstall pyvcam \n')
print('************************************************************\n')
elif is_windows:
print('************************************************************\n')
print('Pre-install necessary packages as admin \n')
print(' python -m pip install --upgrade pip setuptools wheel numpy \n')
print('************************************************************\n')
print('Build package: python setup.py build \n')
print('Install package: python setup.py install \n')
print('Create Wheel dist: python setup.py sdist bdist_wheel \n')
print('Uninstall package: pip uninstall pyvcam \n')
print('************************************************************\n')
pvcam_sdk_path = os.environ['PVCAM_SDK_PATH']
import numpy
include_dirs = [numpy.get_include()]
if is_linux:
extra_compile_args = ['-std=c++11']
include_dirs.append('{}/include/'.format(pvcam_sdk_path))
if is_arch_aarch64:
lib_dirs = ['{}/library/aarch64'.format(pvcam_sdk_path)]
elif is_arch_x86_64:
lib_dirs = ['{}/library/x86_64'.format(pvcam_sdk_path)]
elif is_arch_i686:
lib_dirs = ['{}/library/i686'.format(pvcam_sdk_path)]
libs = ['pvcam']
elif is_windows:
extra_compile_args = []
include_dirs.append('{}/inc/'.format(pvcam_sdk_path))
if is_arch_x86_64:
lib_dirs = ['{}/Lib/amd64'.format(pvcam_sdk_path)]
libs = ['pvcam64']
elif is_32bit:
lib_dirs = ['{}/Lib/i386'.format(pvcam_sdk_path)]
libs = ['pvcam32']
ext_modules = [Extension('pyvcam.pvc',
['src/pyvcam/pvcmodule.cpp'],
extra_compile_args=extra_compile_args,
include_dirs=include_dirs,
library_dirs=lib_dirs,
libraries=libs)]
setup(name='pyvcam',
version='2.1.6',
author='Teledyne Photometrics',
author_email='Steve.Bellinger@Teledyne.com',
url='https://github.com/Photometrics/PyVCAM',
description='Python wrapper for PVCAM functionality.',
packages=['pyvcam'],
package_dir={'pyvcam': 'src/pyvcam'},
py_modules=['pyvcam.constants'],
ext_modules=ext_modules)
# TODO add checks for if a package is already installed and if so don't install it, if it is installed and up to date give option to update or not
# pip.main(['install', 'wxPython'])
# pip.main(['install', 'pyserial'])
# pip.main(['install', 'opencv-python'])
# pip.main(['install', 'git+https://github.com/pearu/pylibtiff.git'])
# os.system('conda install -y -c conda-forge opencv=3.2.0')
print('\n\n*************** Finished ***************\n')