Skip to content

Commit

Permalink
packaging update to actually have requirements in version
Browse files Browse the repository at this point in the history
updating gui arg_handling.py to make error handling better
  • Loading branch information
SteveDoyle2 committed May 31, 2019
1 parent 34c9d66 commit bc15404
Show file tree
Hide file tree
Showing 17 changed files with 108 additions and 101 deletions.
88 changes: 34 additions & 54 deletions packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def str_version(version):
return '.'.join(str(versioni) for versioni in version)


def get_package_requirements(is_gui=True, python_version=None):
def get_package_requirements(is_gui=True, add_vtk_qt=True, python_version=None):
"""gets the requirements for setup.py"""
if python_version is None:
python_version = '%s.%s' % sys.version_info[:2]
Expand All @@ -98,9 +98,6 @@ def get_package_requirements(is_gui=True, python_version=None):
vreqs = REQS[python_version]

all_reqs = {}
py2_packages = []
py3_packages = []


is_dev = (
'TRAVIS' in os.environ or
Expand All @@ -110,32 +107,23 @@ def get_package_requirements(is_gui=True, python_version=None):
is_travis = 'TRAVIS' in os.environ
is_rtd = 'READTHEDOCS' in os.environ

if is_dev or is_gui:
if is_dev or (is_gui and add_vtk_qt):
try:
import vtk
vtk_version = '.'.join(vtk.VTK_VERSION.split('.'))
all_reqs['vtk'] = vtk_version
if vtk_version < '7.0.0':
print("vtk.VTK_VERSION = %r < '7.0.0'" % vtk.VTK_VERSION)
py2_packages.append('vtk >= 7.0.0')
install_requires.append('vtk >= 7.0.0')
except ImportError:
py2_packages.append('vtk >= 7.0.0') # 8.x used

py2_packages += [
##'dill'
]

py3_packages += [
#'pillow >= 2.7.0',
##'dill'
]
install_requires.append('vtk >= 7.0.0') # 8.x used

py_packages = []
install_requires = []

if is_rtd:
py_packages.append('numpy')
install_requires.append('numpy')
else:
version_check, required_version = vreqs['scipy']
version_check, required_version = vreqs['numpy']
try:
import numpy as np
sver = np.lib.NumpyVersion(np.__version__)
Expand All @@ -147,15 +135,15 @@ def get_package_requirements(is_gui=True, python_version=None):
#print('numpy %r %r' % (sver, iversion_check))
if iver < iversion_check:
print("numpy.__version__ = %r < %s" % (np.__version__, version_check))
py_packages.append('numpy %s' % required_version)
install_requires.append('numpy %s' % required_version)
all_reqs['numpy'] = version_check
py_packages.append('numpy %s' % required_version) # was 1.11; ,<1.13.0
install_requires.append('numpy %s' % required_version) # was 1.11; ,<1.13.0
except ImportError:
all_reqs['numpy'] = required_version
py_packages.append('numpy %s' % required_version) # ,<1.13.0; 1.15.1 used
install_requires.append('numpy %s' % required_version) # ,<1.13.0; 1.15.1 used

if is_rtd:
py_packages.append('scipy')
install_requires.append('scipy')
else:
version_check, required_version = vreqs['scipy']
try:
Expand All @@ -171,9 +159,9 @@ def get_package_requirements(is_gui=True, python_version=None):
print("scipy.version.short_version = %r < %r" % (
scipy.version.short_version, version_check))
all_reqs['scipy'] = required_version
py_packages.append('scipy %s' % required_version)
install_requires.append('scipy %s' % required_version)
except ImportError:
py_packages.append('scipy %s' % required_version) # 1.1.0 used
install_requires.append('scipy %s' % required_version) # 1.1.0 used

try:
import six
Expand All @@ -182,9 +170,9 @@ def get_package_requirements(is_gui=True, python_version=None):
if iver < [1, 9, 0]:
print("six.__version__ = %r < '1.9.0'" % six.__version__)
all_reqs['six'] = '>= 1.9.0'
py_packages.append('six >= 1.9.0')
install_requires.append('six >= 1.9.0')
except ImportError:
py_packages.append('six >= 1.9.0') # 1.12.0 used
install_requires.append('six >= 1.9.0') # 1.12.0 used

if is_gui:
version_check, required_version = vreqs['matplotlib']
Expand All @@ -197,9 +185,9 @@ def get_package_requirements(is_gui=True, python_version=None):
print("matplotlib.__version__ = %r < %r" % (matplotlib.__version__, version_check))
#matplotlib.__version__, str_version(iversion_check)))
all_reqs['matplotlib'] = required_version # '>= 2.1.2'
py_packages.append('matplotlib %s' % required_version)
install_requires.append('matplotlib %s' % required_version)
except ImportError:
py_packages.append('matplotlib %s' % required_version) # was 2.1.2; 2.2.3 used
install_requires.append('matplotlib %s' % required_version) # was 2.1.2; 2.2.3 used


try:
Expand All @@ -209,9 +197,9 @@ def get_package_requirements(is_gui=True, python_version=None):
if iver <= [1, 0, 2]:
print("cpylog.__version__ = %r != '1.0.2'" % cpylog.__version__)
all_reqs['cpylog'] = '>= 1.0.2'
py_packages.append('cpylog >= 1.0.2')
install_requires.append('cpylog >= 1.0.2')
except ImportError:
py_packages.append('cpylog >= 1.0.2') # 1.0.2 used
install_requires.append('cpylog >= 1.0.2') # 1.0.2 used


try:
Expand All @@ -222,9 +210,9 @@ def get_package_requirements(is_gui=True, python_version=None):
#if docopt.__version__ != '0.6.2':
print("docopt.__version__ = %r != '0.6.2'" % docopt.__version__)
all_reqs['docopt'] = '== 0.6.2'
py_packages.append('docopt == 0.6.2')
install_requires.append('docopt == 0.6.2')
except ImportError:
py_packages.append('docopt == 0.6.2') # 0.6.2 used
install_requires.append('docopt == 0.6.2') # 0.6.2 used

if is_rtd:
pass
Expand All @@ -236,23 +224,23 @@ def get_package_requirements(is_gui=True, python_version=None):
if iver < [1, 4, 0]:
print("qtpy.__version__ = %r < '1.4.0'" % qtpy.__version__)
all_reqs['qtpy'] = '>= 1.4.0'
py_packages.append('qtpy >= 1.4.0')
install_requires.append('qtpy >= 1.4.0')
except ImportError:
py_packages.append('qtpy >= 1.4.0') # 1.5.0 used
install_requires.append('qtpy >= 1.4.0') # 1.5.0 used

if PY2:
try:
import typing
except ImportError:
# PY2
all_reqs['typing'] = '>= 3.6.4'
py_packages.append('typing >= 3.6.4') # 3.6.6 used
install_requires.append('typing >= 3.6.4') # 3.6.6 used

try:
import pathlib2
except ImportError:
all_reqs['pathlib2'] = '>= 2.3.0'
py_packages.append('pathlib2 >= 2.3.0') # 2.3.2 used
install_requires.append('pathlib2 >= 2.3.0') # 2.3.2 used

#try:
#import scandir
Expand All @@ -261,9 +249,9 @@ def get_package_requirements(is_gui=True, python_version=None):
#if sver < [1, 7, 0]:
#print("scandir.__version__ = %r < '1.7.0'" % scandir.__version__)
#all_reqs['scandir'] = '>= 1.7.0'
#py_packages.append('scandir >= 1.7.0')
#install_requires.append('scandir >= 1.7.0')
#except ImportError:
#py_packages.append('scandir >= 1.7.0') # 1.9.0 used
#install_requires.append('scandir >= 1.7.0') # 1.9.0 used

if is_rtd:
pass
Expand All @@ -273,27 +261,19 @@ def get_package_requirements(is_gui=True, python_version=None):
if imageio.__version__ < '2.2.0':
#print("imageio.version = %r < '2.2.0'" % imageio.__version__)
all_reqs['imageio'] = '>= 2.2.0'
py_packages.append('imageio >= 2.2.0')
install_requires.append('imageio >= 2.2.0')
else:
all_reqs['imageio'] = imageio.__version__
except ImportError:
py_packages.append('imageio >= 2.2.0')
install_requires.append('imageio >= 2.2.0')

#py_packages = [
# 'numpy >= 1.9.2',
# 'scipy >= 0.16.0, scipy < 0.18.0',
#]

is_windows = 'nt' in os.name
if is_travis and not is_windows:
py_packages.append('python-coveralls')
#py_packages.append('codecov')
#py_packages.append('coverage')

install_requires = py_packages + [
# -*- Extra requirements: -*-
##'cython',
] + py2_packages + py3_packages,
install_requires.append('python-coveralls')
#install_requires.append('codecov')
#install_requires.append('coverage')

#print(all_reqs)
#print(install_requires)
print('install_requires =', install_requires)
return all_reqs, install_requires
6 changes: 3 additions & 3 deletions pyNastran/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
# pyInstaller
from pyNastran.version import __version__, __releaseDate__
else:
__version__ = '1.2.1'
__releaseDate__ = '2019/5/24'
__releaseDate2__ = 'MAY 24, 2019'
__version__ = '1.2.2'
__releaseDate__ = '2019/6/x'
__releaseDate2__ = 'JUNE x, 2019'

__author__ = 'Steven Doyle, Michael Redmond, Saullo Castro, hurlei, Paul Blelloch, Nikita Kalutsky'
__email__ = 'mesheb82@gmail.com'
Expand Down
24 changes: 21 additions & 3 deletions pyNastran/bdf/bdf_interface/assign_type.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Parses Nastran fields
"""
"""Parses Nastran fields"""
from __future__ import print_function
import re
from typing import Union, Optional
Expand Down Expand Up @@ -60,6 +58,7 @@ def parse_components(card, ifield, fieldname):
-------
components : str
a string of the dofs '0' or '123456' (not all are required)
"""
assert isinstance(card, BDFCard), type(card)
assert isinstance(ifield, int), type(ifield)
Expand Down Expand Up @@ -202,6 +201,7 @@ def integer_double_string_or_blank(card, ifield, fieldname, default=None):
-------
value : int, float, str, None
the field value
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -266,6 +266,7 @@ def modal_components(card, ifield, fieldname):
field number
fieldname : str
name of field
"""
value = integer(card, ifield, fieldname)
if not(-1 <= value <= 6):
Expand All @@ -287,6 +288,7 @@ def modal_components_or_blank(card, ifield, fieldname, default=None):
field number
fieldname : str
name of field
"""
value = integer_or_blank(card, ifield, fieldname, default=default)
if not(-1 <= value <= 6):
Expand All @@ -306,6 +308,7 @@ def integer(card, ifield, fieldname):
field number
fieldname : str
name of field
"""
svalue = card.field(ifield)
if isinstance(svalue, float_types):
Expand Down Expand Up @@ -379,6 +382,7 @@ def double(card, ifield, fieldname):
-------
value : float
the value from the desired field
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -446,6 +450,7 @@ def double_or_blank(card, ifield, fieldname, default=None):
name of field
default : double, None
the default value for the field (default=None)
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -482,6 +487,7 @@ def double_or_string(card, ifield, fieldname):
field number
fieldname : str
name of field
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -543,6 +549,7 @@ def double_string_or_blank(card, ifield, fieldname, default=None):
the typed value
:raises SyntaxError: if there is an invalid type
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -599,6 +606,7 @@ def integer_or_double(card, ifield, fieldname):
the value with the proper type
:raises SyntaxError: if there's an invalid type
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -643,6 +651,7 @@ def integer_double_or_blank(card, ifield, fieldname, default=None):
name of field
default : int / float / None
the default value for the field (default=None)
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -676,6 +685,7 @@ def integer_or_string(card, ifield, fieldname):
name of field
default : int / str
the default value for the field (default=None)
"""
svalue = card.field(ifield)

Expand Down Expand Up @@ -733,6 +743,7 @@ def integer_string_or_blank(card, ifield, fieldname, default=None):
name of field
default : int, str, None
the default value for the field (default=None)
"""
svalue = card.field(ifield)
if isinstance(svalue, integer_types):
Expand Down Expand Up @@ -769,6 +780,7 @@ def _get_dtype(value):
-------
dtype : str
the type of the value
"""
try:
value = interpret_value(value)
Expand Down Expand Up @@ -804,6 +816,7 @@ def integer_double_or_string(card, ifield, fieldname):
-------
value : varies
the value of the field
"""
svalue = card.field(ifield)
if isinstance(svalue, integer_float_types):
Expand Down Expand Up @@ -859,6 +872,7 @@ def string(card, ifield, fieldname):
-------
value : str
the value of the field
"""
svalue = card.field(ifield)
if isinstance(svalue, string_types):
Expand Down Expand Up @@ -902,6 +916,7 @@ def string_or_blank(card, ifield, fieldname, default=None):
-------
value : varies
the value of the field
"""
svalue = card.field(ifield)
if svalue is None:
Expand Down Expand Up @@ -949,6 +964,7 @@ def loose_string_or_blank(card, ifield, fieldname, default=None):
-------
value : varies
the value of the field
"""
svalue = card.field(ifield)
if svalue is None:
Expand Down Expand Up @@ -996,6 +1012,7 @@ def exact_string_or_blank(card, ifield, fieldname, default=None):
-------
value : varies
the value of the field
"""
svalue = card.field(ifield)
if svalue is None:
Expand Down Expand Up @@ -1039,6 +1056,7 @@ def interpret_value(value_raw, card=''):
-------
value : varies
the Nastran reprentation of the value
"""
if value_raw is None:
return None
Expand Down

0 comments on commit bc15404

Please sign in to comment.