forked from Pyroevil/Blender-Molecular-Script
-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
69 lines (54 loc) · 1.89 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
import os
import shutil
import distutils.extension
import distutils.core
DEBUG = False
env_path = 'BLENDER_USER_ADDON_PATH'
if os.path.exists('build'):
shutil.rmtree('build')
if DEBUG: # create *.pdb files
module = distutils.extension.Extension(
'core',
sources=['core\\simulation.c'],
extra_compile_args=['/O2', '/openmp:llvm', '/GT', '/Zi', '/MTd'],
extra_link_args=['/DEBUG']
)
else:
module = distutils.extension.Extension(
'core',
sources=['core\\simulation.c'],
extra_compile_args=['/Ox', '/openmp:llvm', '/GT', '/fp:fast', '/MT'],
extra_link_args=['/release']
)
distutils.core.setup(
name='Molecular Core',
version='1.0',
description='This is a core for molecular addon',
ext_modules=[module]
)
addon_path = os.environ.get(env_path, None)
if addon_path:
if addon_path[:-1] == '/':
addon_path = addon_path[:-1]
if not addon_path.endswith(os.path.join('scripts', 'addons')):
raise BaseException('Incorrect addons path')
molecular_path = os.path.join(addon_path, 'molecular')
if not os.path.exists(molecular_path):
os.makedirs(molecular_path)
core_name = 'core.cp310-win_amd64.pyd'
core_path = molecular_path + os.sep + core_name
shutil.copyfile(
'build\\lib.win-amd64-cpython-310\\'+core_name,
core_path
)
print('\n\n\tCore installed into:\n\n\t\t{}\n\n'.format(core_path))
else:
print('\n' * 4)
print('\tWarning:\n\n')
print('\t\tMolecular core is not installed in Blender addons.')
print('\t\tAdd an {} environment variable.'.format(env_path))
example_addon_path = 'C:\\Users\\Admin\\AppData\\Roaming\\Blender Foundation\\Blender\\2.90\\scripts\\addons\\'
print('\t\tFor example:')
print('\t\t\t{}'.format(example_addon_path))
print('\t\tOr copy the Molecular core file manually.')
print('\n' * 4)