-
-
Notifications
You must be signed in to change notification settings - Fork 154
/
packages.py
112 lines (93 loc) · 3.82 KB
/
packages.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
"""helper for setup.py"""
import os
import sys
from typing import List
EXCLUDE_WORDS = [
'pyNastran.f06.dev',
'pyNastran.op2.dev', 'pyNastran.op2.dev.original',
'pyNastran.converters.dev',
'pyNastran.dev',
'pyNastran.dev.xdb',
'pyNastran.dev.bdf_vectorized', 'pyNastran.dev.bdf_vectorized.cards',
'pyNastran.dev.bdf_vectorized3', 'pyNastran.dev.op2_vectorized3',
]
CONSOLE_SCRIPTS = [
#'run_nastran_double_precision = pyNastran.bdf.test.run_nastran_double_precision:cmd_line',
'test_bdf = pyNastran.bdf.test.test_bdf:main',
'test_op2 = pyNastran.op2.test.test_op2:main',
'test_op4 = pyNastran.op4.test.test_op4:main',
'pyNastranGUI = pyNastran.gui.gui:cmd_line',
'bdf = pyNastran.bdf.mesh_utils.utils:cmd_line',
'f06 = pyNastran.f06.utils:cmd_line',
'format_converter = pyNastran.converters.format_converter:cmd_line_format_converter',
'abaqus_to_nastran = pyNastran.converters.abaqus.abaqus_to_nastran:cmd_abaqus_to_nastran',
'test_pynastrangui = pyNastran.gui.test.test_gui:main',
'test_bdfv = pyNastran.dev.bdf_vectorized3.test.test_bdf:main',
#'pyNastranv = pyNastran.dev.bdf_vectorized.solver.solver:main',
#'test_bdfv2 = pyNastran.dev.bdf_vectorized2.test.test_bdf:main',
#'test_abaqus = pyNastran.converters.abaqus.test_abaqus:main',
#'nastran_to_code_aster = pyNastran.converters.dev.code_aster.nastran_to_code_aster:main',
]
def check_python_version() -> None:
"""verifies the python version"""
imajor, minor1, minor2 = sys.version_info[:3]
if sys.version_info < (3, 10, 0): # 3.10.4 used
sys.exit('Upgrade your Python to 3.10+; version=(%s.%s.%s)' % (
imajor, minor1, minor2))
def int_version(name: str, version: str) -> List[int]:
"""splits the version into a tuple of integers"""
sversion = version.split('-')[0]
#numpy
#scipy
#matplotlib
#qtpy
#vtk
#cpylog
#pyNastran
if 'rc' not in name:
# it's gotta be something...
# matplotlib3.1rc1
sversion = sversion.split('rc')[0]
try:
return [int(val) for val in sversion.split('.')]
except ValueError:
raise SyntaxError('cannot determine version for %s %s' % (name, sversion))
def str_version(version: str) -> str:
"""converts a tuple of integers to a version number"""
return '.'.join(str(versioni) for versioni in version)
def update_version_file():
"""
Creates the version.py file with the github string
to lock down the version when the user the following
on the dev version:
>>> python setup.py install
instead of:
>>> python setup.py develop
This is handy
"""
import pyNastran
args = sys.argv
# 'setup.py install' will not quit out
# 'setup.py install --user' will not quit out
# 'pip install .' ???
if 'develop' in args:
return
#if 'install' in args and len(args) >= 3: # don't care about dev
# args = ['setup.py', 'install', '--user']
# args = ['setup.py', 'install', '-home=<path>']
# args = ['setup.py', 'install', '--prefix=<path>']
#
#pass
pkg_path = pyNastran.__path__[0]
init_filename = os.path.join(pkg_path, '__init__.py')
version_filename = os.path.join(pkg_path, 'version.py')
with open(version_filename, 'w') as version_file:
version_file.write(f'__version__ = {pyNastran.__version__!r}\n')
version_file.write(f'__releaseDate__ = {pyNastran.__releaseDate__!r}\n')
version_file.write(f'__releaseDate2__ = {pyNastran.__releaseDate2__!r}\n')
with open(init_filename, 'r') as init_file:
data = init_file.read()
data2 = data.replace('is_installed = False', 'is_installed = True')
with open(init_filename, 'w') as init_file_out:
data = init_file_out.write(data2)
#__version__ = '1.3.0+%s' % revision