Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/SteveDoyle2/pyNastran
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveDoyle2 committed Jul 22, 2016
2 parents 11a4f10 + 559d54c commit b4d6339
Show file tree
Hide file tree
Showing 29 changed files with 978 additions and 267 deletions.
169 changes: 145 additions & 24 deletions dev/pyNastranGUI.spec
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
# -*- PyInstaller input file -*-
# -*- mode: python -*-

#pyInstaller_path = 'C:\\Users\\steve\\Desktop\\pyInstaller'
import pyinstaller
pyInstaller_path = os.path.dirname(pyinstaller.__file__)
print "pyInstaller_path = %r" % pyInstaller_path
#pyInstaller_path = ['C:\\Users\\steve\\Desktop\\pyInstaller']
try:
import pyinstaller
pyInstaller_path = [os.path.dirname(pyinstaller.__file__)]
print "pyInstaller_path = %r" % pyInstaller_path
except ImportError:
pyInstaller_path = []

#-------------------------------------------------------------------------
## this block gets/sets the version so it doesn't use git

#import pyNastran
#pyNastran.is_pynastrangui_exe = True
#pyNastran.__version__ = '%r' % pyNastran.__version__
#pyNastran.__releaseDate__ = '%r' % pyNastran.__releaseDate__
#pyNastran.__releaseDate2__ = '%r' % datei.strftime('%d %B %Y')

import os
import sys
import shutil
import datetime
import pyNastran

pkg_path = pyNastran.__path__[0]
from six import PY2

# get pyNastran location
import pkgutil
pkg_path = pkgutil.get_loader('pyNastran').filename
init_filename = os.path.join(pkg_path, '__init__.py')
assert os.path.exists(init_filename), init_filename


# getting pyNastran version without using the __init__.py file
# because we need to hack on it
import subprocess
try:
ghash = subprocess.check_output(['git', 'describe', '--always'], cwd=os.path.dirname(init_filename))
ghash = ghash.decode('utf-8').rstrip()
except:
# git isn't installed
ghash = 'no.checksum.error'
version = '0.8.0+dev.%s' % ghash

# hacking on the __init___.py file to set:
# is_pynastrangui_exe = True
init_filename_bkp = init_filename + '.bkp'
shutil.copyfile(init_filename, init_filename_bkp)
with open(init_filename, 'r') as init_file:
lines = init_file.readlines()
with open(init_filename, 'w') as init_file:
for line in lines:
if 'is_pynastrangui_exe = False' in line:
line = 'is_pynastrangui_exe = True\n'
init_file.write(line)

# write the version
version_filename = os.path.join(pkg_path, 'version.py')
print('version_filename =', version_filename)
with open(version_filename, 'w') as version_file:
datei = datetime.date.today()
version_file.write('# -*- coding: utf-8 -*-\n')
version_file.write('# this file is autogenerated by pyInstaller\n')
version_file.write('__version__ = %r\n' % pyNastran.__version__)
version_file.write('__version__ = %r\n' % version)
version_file.write('__releaseDate__ = %r\n' % str(datei)) # 2016-2-5
version_file.write('__releaseDate2__ = %r\n' % datei.strftime('%d %B %Y')) # 5 Feb 2016


#-------------------------------------------------------------------------

#a1 = os.path.join(pkg_path, 'bdf','bdf.py')
#a2 = os.path.join(pkg_path, 'op2','op2.py')
#a3 = os.path.join(pkg_path, 'f06','f06.py')
Expand Down Expand Up @@ -50,28 +95,99 @@ assert os.path.exists(icon_main), '%s doesnt exist' % icon_main
#-------------------------------------------------------------------------
# main code

#from PyInstaller import compat
#from os import listdir

##mkldir = compat.base_prefix + "/Lib/site-packages/numpy/core"
#logger = logging.getLogger(__name__)
#logger.info("MKL installed as part of numpy, importing that!")
#binaries = [(mkldir + "/" + mkl, '') for mkl in listdir(mkldir) if mkl.startswith('mkl_')]


python_path = 'F:\Anaconda'
if PY2:
mkl_dll = os.path.join(python_path, 'Library', 'bin', 'mkl_def.dll')
else:
mkl_dll = os.path.join(python_path, 'evns', 'py35', 'Library', 'bin', 'mkl_def3.dll')
mkl_dll_base = os.path.basename(mkl_dll)
assert os.path.exists(mkl_dll), '%s doesnt exist' % mlk_dll

binaries = []
if sys.platform == 'win32':
binaries = [('msvcp100.dll', 'C:\\Windows\\System32\\msvcp100.dll', 'BINARY'),
('msvcr100.dll', 'C:\\Windows\\System32\\msvcr100.dll', 'BINARY')]
('msvcr100.dll', 'C:\\Windows\\System32\\msvcr100.dll', 'BINARY'),
(mkl_dll_base, mkl_dll, 'BINARY'),
]

#python_path = 'C:\\Python27_x86'
python_path = 'C:\\Anaconda'
#python_path = 'C:\\Anaconda'


pathex = pyInstaller_path + [
python_path,
os.path.join(python_path, 'Lib'),
os.path.join(python_path, 'Lib', 'site-packages'),

pkg_path,
os.path.join(pkg_path, 'bdf'),
os.path.join(pkg_path, 'op2'),
os.path.join(pkg_path, 'f06'),
os.path.join(pkg_path, 'gui'),
]
excludes = [
#'unittest', # why can't I remove this?
'matplotlib', 'wx', 'nose', 'Tkinter', 'distutils',

'beautifulsoup4', 'bitarray', 'bottleneck', 'bzip2', 'cdecimal',
'cffi', 'comtypes', 'conda-build', 'configobj', 'console_shortcut',
'cryptography', 'cython', 'docutils', 'fastcache', 'flask',
'freetype', 'funcsigs', 'greenlet', 'grin', 'h5py', 'idna',
'ipaddress', 'ipython-notebook', 'ipython-qtconsole',
'ipython_genutils', 'itsdangerous', 'jedi', 'jinja2', 'jpeg',
'jsonschema', 'jupyter_client', 'jupyter_core', 'launcher',
'libsodium', 'markupsafe', 'mistune', 'multipledispatch',
'nbformat', 'nltk', 'node-webkit', 'nose', 'patsy', 'pickleshare',
'ply', 'pyasn1', 'pycosat', 'pycparser', 'pycrypto', 'pycurl',
'pyflakes', 'pyopenssl', 'pyparsing', 'pyreadline', 'pytables',
'python-dateutil', 'rope', 'scikit-image', 'simplegeneric',
'singledispatch', 'sockjs-tornado', 'ssl_match_hostname',
'statsmodels', 'sympy', 'tk', 'toolz', 'ujson', 'unicodecsv',
'xlrd', 'xlwt', 'zeromq', 'zlib', 'alabaster',
'anaconda-client', 'appdirs', 'astroid', 'astroid', 'astropy'
'babel', 'backports_abc', 'blackwidow', 'blaze-core', 'bokeh',
'boto', 'clyent', 'coverage',
'curl', 'cycler', 'cytoolz', 'datashape', 'decorator', 'freeimage',
'gl2ps', 'oce', 'pythonocc-core', 'tbb', 'enum34', 'et_xmlfile',
'futures', 'gevent', 'gevent-websocket', 'hdf5', 'ipykernel',
'ipython', 'ipywidgets', 'jdcal', 'jupyter', 'jupyter_console',
'lazy-object-proxy', 'libtiff', 'llvmlite', 'logilab-common',
'lxml', 'matplotlib', 'menuinst', 'MeshPy',
'msvc_runtime', 'nbconvert', 'networkx', 'notebook', 'numba',
'numexpr', 'numpydoc', 'odo', 'openmdao', 'openpyxl',
'openssl', 'pandas', 'path.py', 'pep8', 'pi', 'pip',
'psutil', 'py', 'pygments', 'pylint', 'pylint', 'pytest',
'pytools', 'pytz', 'pyyaml', 'pyzmq',
'qtconsole', 'requests', 'ruamel_yaml', 'RunSnakeRun',
'scikit-learn', 'setuptools',
'snowballstemmer', 'sphinx', 'sphinx_rtd_theme', 'spyder',
'spyder-app', 'sqlalchemy', 'sqlitedict', 'SquareMap', 'tornado',
'traitlets', 'werkzeug', 'wheel',
'wrapt', 'wxpython', 'xlsxwriter', 'xlwings',


# not required...strange...
'conda', 'conda-env', 'pywin32', 'python', 'vs2008_runtime',
'pyqt', 'anaconda',

# things we're using
'libpng',
#'sip', 'colorama', 'numpy', 'pillow', 'qt','scipy',
#'vtk', 'six', 'mkl', 'mkl-service',
]

a = Analysis(analyze_files,
pathex=[pyInstaller_path,
python_path,
os.path.join(python_path, 'Lib'),
os.path.join(python_path, 'Lib', 'site-packages'),

pkg_path,
os.path.join(pkg_path, 'bdf'),
os.path.join(pkg_path, 'op2'),
os.path.join(pkg_path, 'f06'),
os.path.join(pkg_path, 'gui'),
],
excludes=[#'unittest', # why can't I remove this?
'matplotlib', 'wx', 'nose', 'Tkinter', 'distutils',
],
pathex=pathex,
excludes=excludes,
hiddenimports=[
'vtk.vtkCommonPythonSIP', 'vtk.vtkFilteringPythonSIP',
'PyQt4.QtOpenGL', 'vtk.vtkRenderingPythonSIP'],
Expand Down Expand Up @@ -104,3 +220,8 @@ exe = EXE(pyz,
# upx=True,
# name=os.path.join('dist', 'pyNastranGUI'))

#-------------------------------------------------------------------------
# fix the __init__.py file

shutil.copyfile(init_filename_bkp, init_filename)
os.remove(init_filename_bkp)
5 changes: 2 additions & 3 deletions docs/html_docs/quick_start/Installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ If you want to most recent official release, either:
>>> pip install pyNastran
2. Downlad the most recent `release <https://github.com/SteveDoyle2/pyNastran/releases>_`
2. Download the most recent `release <https://github.com/SteveDoyle2/pyNastran/releases>`_
(**required if you don't want to install the GUI**).

If you don't want the gui, use ``setup_no_gui.py`` instead of ``setup.py``.
Expand Down Expand Up @@ -141,8 +141,7 @@ There are two ways to install the dev version of pyNastran

1. Download the most recent `zip version <https://github.com/SteveDoyle2/pynastran/archive/master.zip>`_

2. Clone pyNastran (see below). Using Git allows you to easily update to the
latest dev version when you want to as well as push any commits of your own.
2. Clone pyNastran (see below). Using Git allows you to easily update to the latest dev version when you want to as well as push any commits of your own.

If you don't want the gui for Python 2.7, use ``setup_no_gui.py`` instead of ``setup.py``.

Expand Down
2 changes: 2 additions & 0 deletions docs/html_docs/quick_start/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ Quick Start

op4_demo
gui
matlab
pandas

10 changes: 10 additions & 0 deletions docs/html_docs/quick_start/matlab.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Matlab
======

* pyNastran also supports Matlab through the Matlab/Python interface. [Information about setting up Matlab with Python can be found here.](http://www.mathworks.com/help/matlab/matlab-engine-for-python.html?s_tid=gn_loc_drop)


Example 1
=========
TODO...
10 changes: 10 additions & 0 deletions docs/html_docs/quick_start/pandas.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

Pandas
======

* pyNastran also supports Pandas dataframes. This is most useful from within iPython / Jupyter.


Example 1
=========
TODO...
4 changes: 3 additions & 1 deletion pyNastran/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import sys

if hasattr(sys, '_MEIPASS'):
# this variable is automatically set by the .spec file; should be False
is_pynastrangui_exe = False
if is_pynastrangui_exe:
# pyInstaller
from pyNastran.version import __version__, __releaseDate__
else:
Expand Down
2 changes: 1 addition & 1 deletion pyNastran/bdf/bdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ def _prepare_conv(self, card, card_obj, comment=''):

def _prepare_radm(self, card, card_obj, comment=''):
"""adds a RADM"""
boundary_condition = RADM(card_obj, comment=comment)
boundary_condition = RADM.add_card(comment=comment)
self.add_thermal_BC(boundary_condition, boundary_condition.radmid)

def _prepare_radbc(self, card, card_obj, comment=''):
Expand Down
29 changes: 29 additions & 0 deletions pyNastran/bdf/cards/bdf_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def add_card(cls, card, comment=''):
components.append(component)
return cls(ids, components, comment=comment)

@classmethod
def add_op2_data(cls, data, comment=''):
ids = [data[0]]
components = [data[1]]
return cls(ids, components, comment=comment)

def cross_reference(self, model):
"""
Cross links the card so referenced cards can be extracted directly
Expand Down Expand Up @@ -344,6 +350,17 @@ def add_card(cls, card, comment=''):
ids.append(idi)
return cls(components, ids, comment=comment)

@classmethod
def add_op2_data(cls, data, comment=''):
components = data[0]
thru_flag = data[1]
if thru_flag == 0:
ids = data[2:]
else:
assert len(data) == 4, data
ids = [data[2], 'THRU', data[3]]
return cls(components, ids, comment=comment)

def cross_reference(self, model):
"""
Cross links the card so referenced cards can be extracted directly
Expand Down Expand Up @@ -425,6 +442,18 @@ def add_card(cls, card, comment=''):
ids = expand_thru(ids)
return cls(seid, components, ids, comment=comment)

@classmethod
def add_op2_data(cls, data, comment=''):
seid = data[0]
components = data[1]
thru_flag = data[2]
if thru_flag == 0:
ids = data[3:]
else:
assert len(data) == 5, data
ids = [data[3], 'THRU', data[4]]
return cls(seid, components, ids, comment=comment)

def cross_reference(self, model):
"""
Cross links the card so referenced cards can be extracted directly
Expand Down
37 changes: 27 additions & 10 deletions pyNastran/bdf/cards/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,18 @@ def add_card(cls, card, comment=''):
n += 1
return SUPORT1(conid, IDs, Cs, comment=comment)

#@classmethod
#def add_op2_data(cls, data, comment=''):
#msg = '%s has not implemented data parsing' % cls.type
#raise NotImplementedError(msg)
#return SUPORT1(conid, IDs, Cs, commment=comment)
@classmethod
def add_op2_data(cls, data, comment=''):
conid = data[0]
assert (len(data) - 1) % 2 == 0, data
IDs = []
Cs = []
for i in range(1, len(data), 2):
ID = data[i]
C = data[i+1]
IDs.append(ID)
Cs.append(C)
return SUPORT1(conid, IDs, Cs, comment=comment)

def add_suport1_to_set(self, suport1):
assert self.conid == suport1.conid, 'SUPORT1 conid=%s new_conid=%s; they must be the same' % (self.conid, suport1.conid)
Expand Down Expand Up @@ -224,6 +231,15 @@ def __init__(self):


class MPC(Constraint):
"""
+-----+-----+----+----+-----+----+----+----+-----+
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
+=====+=====+====+====+=====+====+====+====+=====+
| MPC | SID | G1 | C1 | A1 | G2 | C2 | A2 | |
+-----+-----+----+----+-----+----+----+----+-----+
| | G3 | C3 | A3 | ... | | | | |
+-----+-----+----+----+-----+----+----+----+-----+
"""
type = 'MPC'

def __init__(self, conid, gids, constraints, enforced, comment=''):
Expand Down Expand Up @@ -278,11 +294,12 @@ def add_card(cls, card, comment=''):
i += 1
return MPC(conid, gids, constraints, enforced, comment=comment)

#@classmethod
#def add_op2_data(cls, data, comment=''):
#msg = '%s has not implemented data parsing' % cls.type
#raise NotImplementedError(msg)
#return MPC(conid, gids, constraints, enforced, comment=comment)
@classmethod
def add_op2_data(cls, data, comment=''):
sid,
msg = '%s has not implemented data parsing' % cls.type
raise NotImplementedError(msg)
return MPC(conid, gids, constraints, enforced, comment=comment)

def nodeIDs(self):
self.deprecated('self.nodeIDs()', 'self.node_ids', '0.8')
Expand Down
Loading

0 comments on commit b4d6339

Please sign in to comment.