refactor(setup/ci): require and test Python 3.5, 3.6, 3.7 and 3.8 (#728)
parent
84b133cb16
commit
abccfb755c
12
.travis.yml
12
.travis.yml
|
@ -6,21 +6,19 @@ services:
|
|||
- xvfb
|
||||
matrix:
|
||||
include:
|
||||
- env: RUN_TYPE=test
|
||||
python: 2.7
|
||||
- env: RUN_TYPE=misc
|
||||
python: 3.7
|
||||
- env: RUN_TYPE=test
|
||||
python: 3.5
|
||||
- env: RUN_TYPE=test
|
||||
python: 3.6
|
||||
- env: RUN_TYPE=test
|
||||
python: 3.7
|
||||
- env: RUN_TYPE=misc
|
||||
python: 3.7
|
||||
# - env: RUN_TYPE=test
|
||||
# python: 3.8-dev
|
||||
- env: RUN_TYPE=test
|
||||
python: 3.8
|
||||
# allow_failures:
|
||||
# - env: RUN_TYPE=test
|
||||
# python: 3.8-dev
|
||||
# python: 3.8
|
||||
cache:
|
||||
pip: true
|
||||
directories:
|
||||
|
|
|
@ -117,7 +117,7 @@ FloPy requires **Python** 3.5 (or higher).
|
|||
|
||||
**Dependencies:**
|
||||
|
||||
FloPy requires **NumPy** 1.9 (or higher) and **enum34** for **Python** 3.5 (or higher).
|
||||
FloPy requires **NumPy** 1.9 (or higher).
|
||||
|
||||
|
||||
**For base and Anaconda Python distributions:**
|
||||
|
|
|
@ -926,8 +926,10 @@ def test_sr_with_Map():
|
|||
model=mf, line={'line': verts},
|
||||
xul=mf.dis.sr.xul, yul=mf.dis.sr.yul)
|
||||
|
||||
# for wn in w:
|
||||
# print(str(wn))
|
||||
for wn in w:
|
||||
print(str(wn))
|
||||
if len(w) > 5:
|
||||
w = w[0:5]
|
||||
assert len(w) in (3, 5), len(w)
|
||||
if len(w) == 5:
|
||||
assert w[0].category == DeprecationWarning, w[0]
|
||||
|
@ -1061,17 +1063,15 @@ def test_vertex_model_dot_plot():
|
|||
exe_name="mf6",
|
||||
sim_ws=sim_path)
|
||||
disv_ml = disv_sim.get_model('gwf_1')
|
||||
if sys.version_info[0] > 2:
|
||||
ax = disv_ml.plot()
|
||||
assert ax
|
||||
ax = disv_ml.plot()
|
||||
assert ax
|
||||
|
||||
|
||||
def test_model_dot_plot():
|
||||
loadpth = os.path.join('..', 'examples', 'data', 'secp')
|
||||
ml = flopy.modflow.Modflow.load('secp.nam', model_ws=loadpth)
|
||||
if sys.version_info[0] > 2:
|
||||
ax = ml.plot()
|
||||
assert ax
|
||||
ax = ml.plot()
|
||||
assert ax
|
||||
|
||||
|
||||
def test_get_rc_from_node_coordinates():
|
||||
|
|
|
@ -4,14 +4,10 @@ Some basic tests for mflistfile.py module (not super rigorous)
|
|||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import flopy
|
||||
import numpy as np
|
||||
from nose.tools import raises
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
FileNotFoundError = IOError
|
||||
|
||||
|
||||
def test_mflistfile():
|
||||
pth = os.path.join('..', 'examples', 'data', 'freyberg')
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
# Test binary and formatted data readers
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import numpy as np
|
||||
import flopy
|
||||
from nose.tools import assert_raises
|
||||
|
@ -12,11 +11,6 @@ if os.path.isdir(cpth):
|
|||
shutil.rmtree(cpth)
|
||||
os.makedirs(cpth)
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
closed_file_error_msg = 'I/O operation on closed file'
|
||||
else:
|
||||
closed_file_error_msg = 'seek of closed file'
|
||||
|
||||
|
||||
def test_formattedfile_read():
|
||||
|
||||
|
@ -102,7 +96,7 @@ def test_binaryfile_read_context():
|
|||
|
||||
with assert_raises(ValueError) as e:
|
||||
h.get_data()
|
||||
assert str(e.exception) == closed_file_error_msg, str(e.exception)
|
||||
assert str(e.exception) == 'seek of closed file', str(e.exception)
|
||||
|
||||
|
||||
def test_cellbudgetfile_read_context():
|
||||
|
@ -116,7 +110,7 @@ def test_cellbudgetfile_read_context():
|
|||
|
||||
with assert_raises(ValueError) as e:
|
||||
v.get_data(text='DRAINS')
|
||||
assert str(e.exception) == closed_file_error_msg, str(e.exception)
|
||||
assert str(e.exception) == 'seek of closed file', str(e.exception)
|
||||
|
||||
|
||||
def test_cellbudgetfile_read():
|
||||
|
|
|
@ -86,8 +86,6 @@ def test_epsgreference():
|
|||
if prjtxt is None:
|
||||
print("unable to retrieve CRS prj txt")
|
||||
return
|
||||
if sys.version_info[0] == 2:
|
||||
prjtxt = prjtxt.encode('ascii')
|
||||
assert isinstance(prjtxt, str),type(prjtxt)
|
||||
prj = ep.to_dict()
|
||||
assert 32614 in prj
|
||||
|
|
|
@ -219,10 +219,7 @@ def test_uzf_surfk():
|
|||
|
||||
|
||||
def test_read_write_nwt_options():
|
||||
if sys.version_info[0] > 2:
|
||||
from io import StringIO
|
||||
else:
|
||||
from cStringIO import StringIO
|
||||
from io import StringIO
|
||||
|
||||
from flopy.modflow import ModflowWel, ModflowUzf1, ModflowSfr2
|
||||
from flopy.utils.optionblock import OptionBlock
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
Test the observation process load and write
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
import numpy as np
|
||||
import flopy
|
||||
|
@ -276,10 +275,7 @@ def test_multilayerhob_prfail():
|
|||
|
||||
|
||||
def test_multilayerhob_pr_multiline():
|
||||
if sys.version_info[0] > 2:
|
||||
from io import StringIO
|
||||
else:
|
||||
from cStringIO import StringIO
|
||||
from io import StringIO
|
||||
|
||||
problem_hob = ["2 4 7",
|
||||
"1 1",
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
"""Test copying of flopy objects.
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
import copy
|
||||
import inspect
|
||||
|
@ -190,8 +189,6 @@ def list_is_copy(mflist1, mflist2):
|
|||
|
||||
|
||||
def test_mf2005_copy():
|
||||
if sys.version_info[0] < 3:
|
||||
return
|
||||
path = '../examples/data/freyberg_multilayer_transient/freyberg.nam'
|
||||
model_ws, namefile = os.path.split(path)
|
||||
m = fm.Modflow.load(namefile, model_ws=model_ws)
|
||||
|
@ -202,8 +199,6 @@ def test_mf2005_copy():
|
|||
|
||||
|
||||
def test_mf6_copy():
|
||||
if sys.version_info[0] < 3:
|
||||
return
|
||||
sim_ws = '../examples/data/mf6/test045_lake2tr'
|
||||
sim = mf6.MFSimulation.load('mfsim.nam', 'mf6', sim_ws=sim_ws)
|
||||
m = sim.get_model('lakeex2a')
|
||||
|
|
|
@ -12,12 +12,10 @@ import os
|
|||
import shutil
|
||||
import threading
|
||||
import warnings
|
||||
import queue as Queue
|
||||
|
||||
if sys.version_info > (3, 0):
|
||||
import queue as Queue
|
||||
else:
|
||||
import Queue
|
||||
from datetime import datetime
|
||||
from shutil import which
|
||||
from subprocess import Popen, PIPE, STDOUT
|
||||
import copy
|
||||
import numpy as np
|
||||
|
@ -26,10 +24,6 @@ from .version import __version__
|
|||
from .discretization.modeltime import ModelTime
|
||||
from .discretization.grid import Grid
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
from shutil import which
|
||||
else:
|
||||
from distutils.spawn import find_executable as which
|
||||
|
||||
# Global variables
|
||||
iconst = 1 # Multiplier for individual array elements in integer and real arrays read by MODFLOW's U2DREL, U1DREL and U2DINT.
|
||||
|
@ -1603,15 +1597,8 @@ def run_model(exe_name, namefile, model_ws='./',
|
|||
for t in cargs:
|
||||
argv.append(t)
|
||||
|
||||
if sys.version_info[0:2] == (2, 7) and sys.platform != 'win32':
|
||||
# Python 2.7 workaround for non-Windows
|
||||
close_fds = True
|
||||
else:
|
||||
close_fds = False # default
|
||||
|
||||
# run the model with Popen
|
||||
proc = Popen(argv, stdout=PIPE, stderr=STDOUT, cwd=model_ws,
|
||||
close_fds=close_fds)
|
||||
proc = Popen(argv, stdout=PIPE, stderr=STDOUT, cwd=model_ws)
|
||||
|
||||
if not use_async:
|
||||
while True:
|
||||
|
|
|
@ -6,11 +6,7 @@ mf module. Contains the ModflowGlobal, ModflowList, and Modflow classes.
|
|||
|
||||
import os
|
||||
import flopy
|
||||
import sys
|
||||
if sys.version_info[0] == 2:
|
||||
from inspect import getargspec as getfullargspec
|
||||
else:
|
||||
from inspect import getfullargspec
|
||||
from inspect import getfullargspec
|
||||
from ..mbase import BaseModel
|
||||
from ..pakbase import Package
|
||||
from ..utils import mfreadnam
|
||||
|
|
|
@ -297,10 +297,7 @@ class ModflowGage(Package):
|
|||
openfile = not hasattr(f, 'read')
|
||||
if openfile:
|
||||
filename = f
|
||||
if sys.version_info[0] == 2:
|
||||
f = open(filename, 'r')
|
||||
elif sys.version_info[0] == 3:
|
||||
f = open(filename, 'r', errors='replace')
|
||||
f = open(filename, 'r', errors='replace')
|
||||
|
||||
# dataset 0 -- header
|
||||
while True:
|
||||
|
|
|
@ -228,22 +228,13 @@ class ModflowHyd(Package):
|
|||
|
||||
# write dataset 2
|
||||
for idx in range(self.nhyd):
|
||||
if sys.version_info[0] == 3:
|
||||
f.write('{} '.format(self.obsdata['pckg'][idx].decode()))
|
||||
f.write('{} '.format(self.obsdata['arr'][idx].decode()))
|
||||
f.write('{} '.format(self.obsdata['intyp'][idx].decode()))
|
||||
f.write('{} '.format(self.obsdata['klay'][idx] + 1))
|
||||
f.write('{} '.format(self.obsdata['xl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['yl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['hydlbl'][idx].decode()))
|
||||
else:
|
||||
f.write('{} '.format(self.obsdata['pckg'][idx]))
|
||||
f.write('{} '.format(self.obsdata['arr'][idx]))
|
||||
f.write('{} '.format(self.obsdata['intyp'][idx]))
|
||||
f.write('{} '.format(self.obsdata['klay'][idx] + 1))
|
||||
f.write('{} '.format(self.obsdata['xl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['yl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['hydlbl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['pckg'][idx].decode()))
|
||||
f.write('{} '.format(self.obsdata['arr'][idx].decode()))
|
||||
f.write('{} '.format(self.obsdata['intyp'][idx].decode()))
|
||||
f.write('{} '.format(self.obsdata['klay'][idx] + 1))
|
||||
f.write('{} '.format(self.obsdata['xl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['yl'][idx]))
|
||||
f.write('{} '.format(self.obsdata['hydlbl'][idx].decode()))
|
||||
f.write('\n')
|
||||
|
||||
# close hydmod file
|
||||
|
|
|
@ -614,10 +614,7 @@ class ModflowLak(Package):
|
|||
openfile = not hasattr(f, 'read')
|
||||
if openfile:
|
||||
filename = f
|
||||
if sys.version_info[0] == 2:
|
||||
f = open(filename, 'r')
|
||||
elif sys.version_info[0] == 3:
|
||||
f = open(filename, 'r', errors='replace')
|
||||
f = open(filename, 'r', errors='replace')
|
||||
|
||||
# dataset 0 -- header
|
||||
while True:
|
||||
|
|
|
@ -776,9 +776,7 @@ class ModflowUzf1(Package):
|
|||
|
||||
# dataset 0 -- header
|
||||
while True:
|
||||
# can't use next() because util2d uses readline()
|
||||
line = f.readline()
|
||||
# (can't mix iteration types in python 2)
|
||||
if line[0] != '#':
|
||||
break
|
||||
# determine problem dimensions
|
||||
|
|
|
@ -9,8 +9,6 @@ from __future__ import print_function
|
|||
|
||||
import abc
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import webbrowser as wb
|
||||
|
||||
import numpy as np
|
||||
|
@ -680,12 +678,7 @@ class Package(PackageInterface):
|
|||
openfile = not hasattr(f, 'read')
|
||||
if openfile:
|
||||
filename = f
|
||||
if platform.system().lower() == 'windows' and \
|
||||
sys.version_info[0] < 3:
|
||||
import io
|
||||
f = io.open(filename, 'r')
|
||||
else:
|
||||
f = open(filename, 'r')
|
||||
f = open(filename, 'r')
|
||||
elif hasattr(f, 'name'):
|
||||
filename = f.name
|
||||
else:
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import numpy as np
|
||||
import sys
|
||||
from ..discretization import StructuredGrid, UnstructuredGrid
|
||||
from ..utils import geometry
|
||||
|
||||
|
@ -899,9 +898,8 @@ class PlotMapView(object):
|
|||
|
||||
if 'layer' in kwargs:
|
||||
kon = kwargs.pop('layer')
|
||||
if sys.version_info[0] > 2:
|
||||
if isinstance(kon, bytes):
|
||||
kon = kon.decode()
|
||||
if isinstance(kon, bytes):
|
||||
kon = kon.decode()
|
||||
if isinstance(kon, str):
|
||||
if kon.lower() == 'all':
|
||||
kon = -1
|
||||
|
@ -1046,9 +1044,8 @@ class PlotMapView(object):
|
|||
if 'layer' in kwargs:
|
||||
kon = kwargs.pop('layer')
|
||||
|
||||
if sys.version_info[0] > 2:
|
||||
if isinstance(kon, bytes):
|
||||
kon = kon.decode()
|
||||
if isinstance(kon, bytes):
|
||||
kon = kon.decode()
|
||||
|
||||
if isinstance(kon, str):
|
||||
if kon.lower() == 'all':
|
||||
|
|
|
@ -306,14 +306,9 @@ def loadtxt(file, delimiter=' ', dtype=None, skiprows=0, use_pandas=True,
|
|||
|
||||
def get_url_text(url, error_msg=None):
|
||||
"""
|
||||
Get text from a url, using either python 3 or 2.
|
||||
Get text from a url.
|
||||
"""
|
||||
try:
|
||||
# For Python 3.0 and later
|
||||
from urllib.request import urlopen
|
||||
except ImportError:
|
||||
# Fall back to Python 2's urllib2
|
||||
from urllib2 import urlopen
|
||||
from urllib.request import urlopen
|
||||
try:
|
||||
urlobj = urlopen(url)
|
||||
text = urlobj.read().decode()
|
||||
|
|
|
@ -8,16 +8,12 @@ recarrays, which can then be easily plotted.
|
|||
import collections
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
import numpy as np
|
||||
import errno
|
||||
|
||||
from ..utils.utils_def import totim_to_datetime
|
||||
|
||||
if sys.version_info[0] == 2:
|
||||
FileNotFoundError = IOError
|
||||
|
||||
|
||||
class ListBudget(object):
|
||||
"""
|
||||
|
@ -52,10 +48,7 @@ class ListBudget(object):
|
|||
assert os.path.exists(file_name), "file_name {0} not found".format(
|
||||
file_name)
|
||||
self.file_name = file_name
|
||||
if sys.version_info[0] == 2:
|
||||
self.f = open(file_name, 'r')
|
||||
elif sys.version_info[0] == 3:
|
||||
self.f = open(file_name, 'r', encoding='ascii', errors='replace')
|
||||
self.f = open(file_name, 'r', encoding='ascii', errors='replace')
|
||||
|
||||
self.tssp_lines = 0
|
||||
|
||||
|
@ -281,11 +274,7 @@ class ListBudget(object):
|
|||
return None
|
||||
|
||||
# reopen the file
|
||||
if sys.version_info[0] == 2:
|
||||
self.f = open(self.file_name, 'r')
|
||||
elif sys.version_info[0] == 3:
|
||||
self.f = open(self.file_name, 'r', encoding='ascii',
|
||||
errors='replace')
|
||||
self.f = open(self.file_name, 'r', encoding='ascii', errors='replace')
|
||||
units = units.lower()
|
||||
if not units == 'seconds' and not units == 'minutes' and not units == 'hours':
|
||||
raise (
|
||||
|
|
|
@ -184,8 +184,7 @@ def parsenamefile(namfilename, packages, verbose=True):
|
|||
openmode = 'rb'
|
||||
else:
|
||||
openmode = 'r'
|
||||
if sys.version_info[0] > 2:
|
||||
kwargs['errors'] = 'replace'
|
||||
kwargs['errors'] = 'replace'
|
||||
try:
|
||||
filehandle = open(fname, openmode, **kwargs)
|
||||
except IOError:
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
appdirs
|
||||
matplotlib
|
||||
netcdf4
|
||||
fiona
|
||||
fiona ; python_version < '3.8'
|
||||
descartes
|
||||
pyproj
|
||||
pyshp
|
||||
pandas
|
||||
scipy
|
||||
rasterio
|
||||
affine
|
||||
affine
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
appdirs
|
||||
matplotlib
|
||||
netcdf4<1.2.8
|
||||
fiona
|
||||
descartes
|
||||
pyproj
|
||||
pyshp
|
||||
enum34
|
||||
pandas
|
||||
requests
|
||||
scipy
|
||||
rasterio
|
||||
affine
|
|
@ -1,27 +1,19 @@
|
|||
import os
|
||||
import sys
|
||||
from setuptools import setup
|
||||
# To use:
|
||||
# python setup.py bdist --format=wininst
|
||||
|
||||
from flopy import __version__, __name__, __author__
|
||||
|
||||
# trap someone trying to install flopy with something other
|
||||
# than python 2 or 3
|
||||
if not sys.version_info[0] in [2, 3]:
|
||||
print('Sorry, Flopy not supported in your Python version')
|
||||
print(' Supported versions: 2 and 3')
|
||||
print(' Your version of Python: {}'.format(sys.version_info[0]))
|
||||
sys.exit(1) # return non-zero value for failure
|
||||
|
||||
long_description = ''
|
||||
# ensure minimum version of Python is running
|
||||
if sys.version_info[0:2] < (3, 5):
|
||||
raise RuntimeError('Flopy requires Python >= 3.5')
|
||||
|
||||
try:
|
||||
import pypandoc
|
||||
fpth = os.path.join('docs', 'PyPi_release.md')
|
||||
long_description = pypandoc.convert(fpth, 'rst')
|
||||
except:
|
||||
pass
|
||||
except ImportError:
|
||||
long_description = ''
|
||||
|
||||
setup(name=__name__,
|
||||
description='FloPy is a Python package to create, run, and post-process MODFLOW-based models.',
|
||||
|
@ -37,8 +29,7 @@ setup(name=__name__,
|
|||
url='https://github.com/modflowpy/flopy/',
|
||||
license='CC0',
|
||||
platforms='Windows, Mac OS-X, Linux',
|
||||
install_requires=['enum34;python_version<"3.4"',
|
||||
'numpy>=1.9'],
|
||||
install_requires=['numpy>=1.9'],
|
||||
packages=['flopy', 'flopy.modflow', 'flopy.modflowlgr', 'flopy.modpath',
|
||||
'flopy.mt3d', 'flopy.seawat', 'flopy.utils', 'flopy.plot',
|
||||
'flopy.pest', 'flopy.export', 'flopy.discretization',
|
||||
|
|
|
@ -3,13 +3,9 @@ set -e
|
|||
|
||||
echo "Installing pip for Python ${TRAVIS_PYTHON_VERSION} ${RUN_TYPE} run"
|
||||
pip install --upgrade pip
|
||||
if [ "${TRAVIS_PYTHON_VERSION}" = "2.7" ]; then
|
||||
pip install -r requirements27.travis.txt
|
||||
else
|
||||
pip install -r requirements.travis.txt
|
||||
pip install rasterio
|
||||
pip install --upgrade numpy
|
||||
fi
|
||||
pip install -r requirements.travis.txt
|
||||
pip install rasterio
|
||||
pip install --upgrade numpy
|
||||
if [ "${RUN_TYPE}" = "misc" ]; then
|
||||
pip install flake8 pylint pylint-exit
|
||||
pip install jupyter nbconvert
|
||||
|
|
Loading…
Reference in New Issue