Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed support for Python <= 3.7 #265

Merged
merged 9 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,13 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest]
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10", "3.11"]
gromacs-version: ["2021.1"]
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10", "3.11"]
gromacs-version: ["2023.1"]
# Test other GROMACS versions selectively on a recent Python.
# On macOS only test one GROMACS version and two Python versions
# to keep the testing matrix manageable.
exclude:
- os: macOS-latest
python-version: "3.6"
- os: macOS-latest
python-version: "3.7"
- os: macOS-latest
python-version: "3.8"
- os: macOS-latest
python-version: "3.9"
- os: macOS-latest
python-version: "3.10"
include:
- os: ubuntu-latest
python-version: "2.7"
gromacs-version: "4.6.5"
- os: ubuntu-latest
python-version: "3.11"
gromacs-version: "4.6.5"
Expand All @@ -60,10 +46,18 @@ jobs:
gromacs-version: "2020.6"
- os: ubuntu-latest
python-version: "3.11"
gromacs-version: "2022.4"
gromacs-version: "2021.1"
- os: ubuntu-latest
python-version: "3.11"
gromacs-version: "2023.1"
gromacs-version: "2022.4"
# explicitly include a few macOS runners
# (conda-forge GROMACS >= 2021 is compiled to use rdtscp CPU instruction but these
# are not available in the macOS GitHub runner so we need to use a different GROMACS
# version. Try 2018.5 from bioconda. (2021.5 worked previously but not anymore.)
# Locally 2023.1 was successfully tested on Intel macOS 13.5.)
- os: macOS-latest
python-version: "3.11"
gromacs-version: "2018.6"


env:
Expand Down Expand Up @@ -95,6 +89,7 @@ jobs:
run: |
micromamba info
micromamba list
cat /proc/cpuinfo || (/usr/sbin/system_profiler SPHardwareDataType; /usr/sbin/sysctl -a | grep machdep.cpu)

- name: Install pytest and plugins
run: |
Expand All @@ -103,7 +98,6 @@ jobs:
- name: Install GROMACS (${{ matrix.gromacs-version }})
# UGLY HACK/FIX (probably to issues with bioconda packages)
# - For 3.9, micromamba insists on using pypy 3.9 (and --py-pin does not help).
# - For 2.7 macOS, numkit would get uninstalled.
# We can't freeze because then it's not possible to install older GROMACS versions from bioconda.
run: |
micromamba install 'gromacs==${{ matrix.gromacs-version }}' pocl numkit python=${{ matrix.python-version }}.*=*_cpython
Expand Down
6 changes: 6 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
CHANGELOG for GromacsWrapper
==============================

2023-xx-xx 0.9.0
orbeckst

* removed support for legacy Python (<= 3.7) (#259)


2023-09-16 0.8.5
orbeckst

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

A primitive Python wrapper around the Gromacs_ tools. The library is
tested with GROMACS 4.6.5, 2018.x, 2019.x, 2020.x, 2021.x, 2022.x,
2023.x (and 5.x and 2016.x should also work). It supports Python 2.7
and 3.6--3.11 on Linux and macOS.
2023.x (and 5.x and 2016.x should also work). It supports Python
3.8--3.11 on Linux and macOS.

GromacsWrapper also provides a small library (cook book) of often-used
recipes and helper functions to set up MD simulations.
Expand Down
11 changes: 4 additions & 7 deletions doc/sphinx/source/installation.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
Installation
==============


This document should help you to install the **GromacsWrapper**
package. Please raise and issue in the `Issue Tracker`_ if problems
occur or if you have suggestions on how to improve the package or
Expand Down Expand Up @@ -103,19 +102,17 @@ formatting so please install black_ and run it on your code.
Requirements
============

Python_ 2.7.x or Python >= 3.6 and GROMACS_ (4.6.x, 2016, 2018, 2019,
2020, 2021, 2022) must be installed. ipython_ is very much
recommended.
Python_ >= 3.8 and GROMACS_ (4.6.x, 2016, 2018, 2019, 2020, 2021,
2022, 2023) must be installed.

.. _Python: http://www.python.org
.. _ipython: http://ipython.scipy.org


System requirements
-------------------

Tested with Python 2.7.x and Python 3.6--3.11 on Linux and Mac
OS X. Earlier Python versions are not supported.
Tested with Python 3.8--3.11 on Linux and Mac OS X. Earlier Python
versions were only supported until release 0.8.5.


Required Python modules
Expand Down
2 changes: 0 additions & 2 deletions gromacs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,6 @@
.. autodata:: __version__

"""
from __future__ import absolute_import

__docformat__ = "restructuredtext en"

import os
Expand Down
3 changes: 0 additions & 3 deletions gromacs/cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,6 @@
# new class and set arguments explicitly in init (using kwargs['flag'] =
# default) ... or I can write some meta(??) class to do this nicely

from __future__ import absolute_import, with_statement

__docformat__ = "restructuredtext en"

import sys
Expand All @@ -136,7 +134,6 @@
import tempfile
import shutil
import glob
import six

import logging

Expand Down
8 changes: 4 additions & 4 deletions gromacs/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""

import os.path
from six.moves import cPickle
import pickle
from numpy import all, any


Expand Down Expand Up @@ -50,10 +50,10 @@ def save(self, filename):

If no extension is provided, ".collection" is appended.
"""
cPickle.dump(
pickle.dump(
self,
open(self._canonicalize(filename), "wb"),
protocol=cPickle.HIGHEST_PROTOCOL,
protocol=pickle.HIGHEST_PROTOCOL,
)

def load(self, filename, append=False):
Expand All @@ -64,7 +64,7 @@ def load(self, filename, append=False):

If no extension is provided, ".collection" is appended.
"""
tmp = cPickle.load(open(self._canonicalize(filename), "rb"))
tmp = pickle.load(open(self._canonicalize(filename), "rb"))
if append:
self.extend(tmp)
else:
Expand Down
32 changes: 1 addition & 31 deletions gromacs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,43 +225,13 @@
.. autodata:: qscript_template

"""
from __future__ import absolute_import, with_statement, print_function

import os
import logging
import re
import subprocess
import sys

if sys.version_info[0] < 3: # several differences for Python 2
from ConfigParser import SafeConfigParser as ConfigParser
from ConfigParser import NoSectionError, NoOptionError

# Define read_file to point to the (deprecated in Python 3) readfp
# in order to have consistent, non-deprecated syntax
ConfigParser.read_file = ConfigParser.readfp

# Implement the new `fallback` kwarg based on the Python 3.7 implementation
# https://github.com/python/cpython/blob/3.7/Lib/configparser.py#L804
# This should ensure backwards compatibility.
_cf_getbool = ConfigParser.getboolean
_UNSET = object()

def _getboolean(self, section, option, fallback=_UNSET, **kwargs):
"""Return a boolean for the specified config option

If *fallback* is used, it will be returned if there if the
option is not specified anywhere (defaults, config file)."""
try: # Try using the Python 2 function
return _cf_getbool(self, section, option, **kwargs)
except (NoSectionError, NoOptionError):
if fallback is _UNSET:
raise
return fallback # If fallback is given, use that value

ConfigParser.getboolean = _getboolean
else:
from configparser import ConfigParser
from configparser import ConfigParser

from pkg_resources import resource_filename, resource_listdir

Expand Down
12 changes: 3 additions & 9 deletions gromacs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@
.. autoclass:: PopenWithInput
:members:
"""
from __future__ import absolute_import, with_statement, print_function
import six

__docformat__ = "restructuredtext en"

import sys
Expand Down Expand Up @@ -277,13 +274,13 @@ def Popen(self, *args, **kwargs):
use_shell = kwargs.pop("use_shell", False)
if input:
stdin = PIPE
if isinstance(input, six.string_types) and not input.endswith("\n"):
if isinstance(input, str) and not input.endswith("\n"):
# make sure that input is a simple string with \n line endings
input = six.text_type(input) + "\n"
input = str(input) + "\n"
else:
try:
# make sure that input is a simple string with \n line endings
input = "\n".join(map(six.text_type, input)) + "\n"
input = "\n".join(map(str, input)) + "\n"
except TypeError:
# so maybe we are a file or something ... and hope for the best
pass
Expand Down Expand Up @@ -733,9 +730,6 @@ def __init__(self, *args, **kwargs):
"""
kwargs.setdefault("close_fds", True) # fixes 'Too many open fds' with 2.6
self.input = kwargs.pop("input", None)
if six.PY2 and self.input is not None:
# in Python 2, subprocess.Popen uses os.write(chunk) with default ASCII encoding
self.input = self.input.encode("utf-8")
self.command = args[0]
try:
input_string = (
Expand Down
3 changes: 1 addition & 2 deletions gromacs/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
:members:

"""
import six


# set up flags for core routines (more convoluted than strictly necessary but should
Expand Down Expand Up @@ -87,7 +86,7 @@ def __setitem__(self, name, value):
self.get_flag(name).set(value)

def _itervalues(self):
return six.itervalues(super(Flags, self))
return super(Flags, self).values()

def _items(self):
return super(Flags, self).items()
Expand Down
1 change: 0 additions & 1 deletion gromacs/fileformats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# See the file COPYING for details.

# file formats
from __future__ import absolute_import

__all__ = ["XVG", "MDP", "NDX", "uniqueNDX", "XPM", "TOP"]

Expand Down
7 changes: 3 additions & 4 deletions gromacs/fileformats/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
.. autofunction:: to_unicode

"""
import six

import re

Expand All @@ -47,17 +46,17 @@ def to_unicode(obj):
"""Convert obj to unicode (if it can be be converted).

Conversion is only attempted if `obj` is a string type (as
determined by :data:`six.string_types`).
determined by :class:`str`).

.. versionchanged:: 0.7.0
removed *encoding* keyword argument

"""
if not isinstance(obj, six.string_types):
if not isinstance(obj, str):
return obj

try:
obj = six.text_type(obj)
obj = str(obj)
except TypeError:
pass
return obj
Expand Down
5 changes: 1 addition & 4 deletions gromacs/fileformats/mdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@
"""


from __future__ import absolute_import, with_statement

import os, errno
import re
import warnings
import six
import numpy


Expand Down Expand Up @@ -163,7 +160,7 @@ def write(self, filename=None, skipempty=False):
else: # parameter = value
if skipempty and (v == "" or v is None):
continue
if isinstance(v, six.string_types) or not hasattr(v, "__iter__"):
if isinstance(v, str) or not hasattr(v, "__iter__"):
mdp.write("{k!s} = {v!s}\n".format(**vars()))
else:
mdp.write("{} = {}\n".format(k, " ".join(map(str, v))))
4 changes: 0 additions & 4 deletions gromacs/fileformats/ndx.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
.. autoclass:: IndexSet
"""

from __future__ import absolute_import, with_statement

from six.moves import range

import os, errno
import re
import warnings
Expand Down
1 change: 0 additions & 1 deletion gromacs/fileformats/top.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
Exchange (HREX) simulations. See ``scripts/gw-partial_tempering.py`` for an example.

"""
from __future__ import absolute_import

import textwrap
import logging
Expand Down
4 changes: 0 additions & 4 deletions gromacs/fileformats/xpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@

"""

from __future__ import absolute_import, with_statement

from six.moves import range

import os, errno
import re
import warnings
Expand Down
3 changes: 0 additions & 3 deletions gromacs/fileformats/xvg.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,6 @@
.. autofunction:: break_array

"""
from __future__ import with_statement, absolute_import

from six.moves import zip, range

import os
import errno
Expand Down
2 changes: 0 additions & 2 deletions gromacs/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@
:members:

"""
from __future__ import absolute_import

__docformat__ = "restructuredtext en"

__all__ = ["XVG", "MDP", "NDX", "uniqueNDX", "XPM", "TOP"]
Expand Down
1 change: 0 additions & 1 deletion gromacs/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
.. autogenerated, see Online Docs

"""
from __future__ import absolute_import

import logging

Expand Down
Loading