forked from Photometrics/PyVCAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
117 lines (97 loc) · 4.54 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
110
111
112
113
114
115
116
117
import os
import pip
import platform
import shutil
from setuptools import setup, find_packages
from setuptools.extension import Extension
import numpy
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')
include_dirs = [numpy.get_include()]
if is_linux:
try:
pvcam_sdk_path = os.environ['PVCAM_SDK_PATH']
except KeyError:
pvcam_sdk_path = "/opt/pvcam/sdk"
extra_compile_args = ['-std=c++11']
include_dirs.append(f'{pvcam_sdk_path}/include/')
if is_arch_aarch64:
lib_dirs = [f'{pvcam_sdk_path}/library/aarch64']
elif is_arch_x86_64:
lib_dirs = [f'{pvcam_sdk_path}/library/x86_64']
elif is_arch_i686:
lib_dirs = [f'{pvcam_sdk_path}/library/i686']
libs = ['pvcam']
elif is_windows:
pvcam_sdk_path = os.environ['PVCAM_SDK_PATH']
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.0',
author='Teledyne Photometrics',
author_email='[email protected]',
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,
install_requires=['pyserial', 'opencv-python', 'numpy', 'libtiff'])
# 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')