[med-svn] [Git][med-team/python-dnaio][upstream] New upstream version 0.4.3

Nilesh Patra gitlab at salsa.debian.org
Sun Nov 8 07:51:13 GMT 2020



Nilesh Patra pushed to branch upstream at Debian Med / python-dnaio


Commits:
f3055552 by Nilesh Patra at 2020-11-08T13:16:36+05:30
New upstream version 0.4.3
- - - - -


10 changed files:

- .travis.yml
- README.md
- buildwheels.sh
- setup.py
- src/dnaio/__init__.py
- src/dnaio/readers.py
- src/dnaio/writers.py
- tests/test_internal.py
- tests/test_open.py
- tox.ini


Changes:

=====================================
.travis.yml
=====================================
@@ -7,7 +7,6 @@ cache:
     - $HOME/.cache/pip
 
 python:
-  - "3.4"
   - "3.5"
   - "3.6"
   - "3.7"


=====================================
README.md
=====================================
@@ -4,7 +4,7 @@
 
 # dnaio parses FASTQ and FASTA
 
-`dnaio` is a Python 3 library for fast parsing of FASTQ and also FASTA files. The code was previously part of the
+`dnaio` is a Python 3.5+ library for fast parsing of FASTQ and also FASTA files. The code was previously part of the
 [Cutadapt](https://cutadapt.readthedocs.io/) tool and has been improved since it has been split out.
 
 


=====================================
buildwheels.sh
=====================================
@@ -1,19 +1,30 @@
 #!/bin/bash
 #
-# Build manylinux1 wheels. Based on the example at
+# Build manylinux wheels. Based on the example at
 # <https://github.com/pypa/python-manylinux-demo>
 #
-# For interactive tests:
-#   docker run -it -v $(pwd):/io quay.io/pypa/manylinux1_x86_64 /bin/bash
+# It is best to run this in a fresh clone of the repository!
+#
+# Run this within the repository root:
+#   ./buildwheels.sh
+#
+# The wheels will be put into the dist/ subdirectory.
 
 set -xeuo pipefail
 
+manylinux=quay.io/pypa/manylinux2010_x86_64
+
 # For convenience, if this script is called from outside of a docker container,
 # it starts a container and runs itself inside of it.
 if ! grep -q docker /proc/1/cgroup; then
   # We are not inside a container
-  docker pull quay.io/pypa/manylinux1_x86_64
-  exec docker run --rm -v $(pwd):/io quay.io/pypa/manylinux1_x86_64 /io/$0
+  docker pull ${manylinux}
+  exec docker run --rm -v $(pwd):/io ${manylinux} /io/$0
+fi
+
+if ! test -d /io/dist; then
+  mkdir /io/dist
+  chown --reference=/io/setup.py /io/dist
 fi
 
 # Strip binaries (copied from multibuild)
@@ -21,21 +32,14 @@ STRIP_FLAGS=${STRIP_FLAGS:-"-Wl,-strip-all"}
 export CFLAGS="${CFLAGS:-$STRIP_FLAGS}"
 export CXXFLAGS="${CXXFLAGS:-$STRIP_FLAGS}"
 
-
-# We don’t support Python 2.7
-rm /opt/python/cp27*
-
-PYBINS="/opt/python/*/bin"
-HAS_CYTHON=0
-for PYBIN in ${PYBINS}; do
-    ${PYBIN}/pip install Cython
-#    ${PYBIN}/pip install -r /io/requirements.txt
-    ${PYBIN}/pip wheel /io/ -w wheelhouse/
+for PYBIN in /opt/python/cp3[5678]-*/bin; do
+    ${PYBIN}/pip wheel --no-deps /io/ -w wheelhouse/
 done
+ls wheelhouse/
 
 # Bundle external shared libraries into the wheels
-for whl in wheelhouse/dnaio-*.whl; do
-    auditwheel repair "$whl" -w repaired/
+for whl in wheelhouse/*.whl; do
+    auditwheel repair "$whl" --plat manylinux1_x86_64 -w repaired/
 done
 
 # Created files are owned by root, so fix permissions.


=====================================
setup.py
=====================================
@@ -4,8 +4,8 @@ from setuptools import setup, Extension, find_packages
 from distutils.command.sdist import sdist as _sdist
 from distutils.command.build_ext import build_ext as _build_ext
 
-if sys.version_info[:2] < (3, 4):
-    sys.stdout.write('Python 3.4 or later is required\n')
+if sys.version_info[:2] < (3, 5):
+    sys.stdout.write('Python 3.5 or later is required\n')
     sys.exit(1)
 
 
@@ -75,9 +75,9 @@ setup(
     ext_modules=extensions,
     cmdclass={'build_ext': BuildExt, 'sdist': SDist},
     install_requires=['xopen>=0.8.2'],
-    python_requires='>=3.4',
+    python_requires='>=3.5',
     classifiers=[
-            "Development Status :: 4 - Beta",
+            "Development Status :: 5 - Production/Stable",
             "Intended Audience :: Science/Research",
             "License :: OSI Approved :: MIT License",
             "Natural Language :: English",


=====================================
src/dnaio/__init__.py
=====================================
@@ -128,6 +128,21 @@ def _detect_format_from_name(name):
     return None
 
 
+def _is_path(obj):
+    """
+    Return whether the given object looks like a path (str, pathlib.Path or pathlib2.Path)
+    """
+    # pytest uses pathlib2.Path objects on Python 3.5 for its tmp_path fixture.
+    # On Python 3.6+, this function can be replaced with isinstance(obj, os.PathLike)
+    import sys
+    if "pathlib2" in sys.modules:
+        import pathlib2
+        path_classes = (str, pathlib.Path, pathlib2.Path)
+    else:
+        path_classes = (str, pathlib.Path)
+    return isinstance(obj, path_classes)
+
+
 def _open_single(file, opener, *, fileformat=None, mode="r", qualities=None):
     """
     Open a single sequence file. See description of open() above.
@@ -135,7 +150,7 @@ def _open_single(file, opener, *, fileformat=None, mode="r", qualities=None):
     if mode not in ("r", "w", "a"):
         raise ValueError("Mode must be 'r', 'w' or 'a'")
 
-    if isinstance(file, (str, pathlib.Path)):  # TODO Use os.PathLike in Python 3.6+
+    if _is_path(file):
         path = fspath(file)
         file = opener(path, mode + "b")
         close_file = True
@@ -200,7 +215,8 @@ def _detect_format_from_content(file):
     """
     if file.seekable():
         first_char = file.read(1)
-        file.seek(-1, 1)
+        if file.tell() > 0:
+            file.seek(-1, 1)
     else:
         first_char = file.peek(1)[0:1]
     formats = {
@@ -228,6 +244,9 @@ class PairedSequenceReader:
             self._close = stack.pop_all().close
         self.delivers_qualities = self.reader1.delivers_qualities
 
+    def __repr__(self):
+        return "PairedSequenceReader(file1={}, file2={})".format(self.reader1, self.reader2)
+
     def __iter__(self):
         """
         Iterate over the paired reads. Each item is a pair of Sequence objects.
@@ -279,6 +298,9 @@ class InterleavedSequenceReader:
         self.reader = _open_single(file, opener=opener, fileformat=fileformat)
         self.delivers_qualities = self.reader.delivers_qualities
 
+    def __repr__(self):
+        return "InterleavedSequenceReader({})".format(self.reader)
+
     def __iter__(self):
         it = iter(self.reader)
         for r1 in it:
@@ -317,6 +339,9 @@ class PairedSequenceWriter:
                     file2, opener=opener, fileformat=fileformat, mode=self._mode, qualities=qualities))
             self._close = stack.pop_all().close
 
+    def __repr__(self):
+        return "{}({}, {})".format(self.__class__.__name__, self._writer1, self._writer2)
+
     def write(self, read1, read2):
         self._writer1.write(read1)
         self._writer2.write(read2)
@@ -347,6 +372,9 @@ class InterleavedSequenceWriter:
         self._writer = _open_single(
             file, opener=opener, fileformat=fileformat, mode=self._mode, qualities=qualities)
 
+    def __repr__(self):
+        return "{}({})".format(self.__class__.__name__, self._writer)
+
     def write(self, read1, read2):
         self._writer.write(read1)
         self._writer.write(read2)


=====================================
src/dnaio/readers.py
=====================================
@@ -30,6 +30,9 @@ class BinaryFileReader:
             self._close_on_exit = True
         self._file = file
 
+    def __repr__(self):
+        return "{}({!r})".format(self.__class__.__name__, getattr(self._file, "name", self._file))
+
     def close(self):
         if self._close_on_exit and self._file is not None:
             self._file.close()


=====================================
src/dnaio/writers.py
=====================================
@@ -10,6 +10,9 @@ class FileWriter:
         else:
             self._close_on_exit = bool(_close_file)
 
+    def __repr__(self):
+        return "{}({!r})".format(self.__class__.__name__, getattr(self._file, "name", self._file))
+
     def close(self):
         if self._close_on_exit:
             self._file.close()
@@ -36,6 +39,9 @@ class FastaWriter(FileWriter):
         super().__init__(file, opener=opener, _close_file=_close_file)
         self.line_length = line_length if line_length != 0 else None
 
+    def __repr__(self):
+        return "FastaWriter({!r})".format(getattr(self._file, "name", self._file))
+
     def write(self, name_or_record, sequence=None):
         """Write an entry to the the FASTA file.
 


=====================================
tests/test_internal.py
=====================================
@@ -324,8 +324,6 @@ class TestInterleavedReader:
         ]
         with InterleavedSequenceReader("tests/data/interleaved.fastq") as isr:
             reads = list(isr)
-        for (r1, r2), (e1, e2) in zip(reads, expected):
-            print(r1, r2, e1, e2)
 
         assert reads == expected
         with dnaio.open("tests/data/interleaved.fastq", interleaved=True) as f:


=====================================
tests/test_open.py
=====================================
@@ -49,6 +49,20 @@ def test_version():
     _ = dnaio.__version__
 
 
+def test_open_nonexistent(tmp_path):
+    with pytest.raises(FileNotFoundError):
+        with dnaio.open(tmp_path / "nonexistent"):
+            pass
+
+
+def test_open_empty_file_with_unrecognized_extension(tmp_path):
+    path = tmp_path / "unrecognized-extension.tmp"
+    path.touch()
+    with dnaio.open(path) as f:
+        records = list(f)
+    assert records == []
+
+
 def test_read(fileformat, extension):
     with dnaio.open("tests/data/simple." + fileformat + extension) as f:
         records = list(f)


=====================================
tox.ini
=====================================
@@ -1,5 +1,5 @@
 [tox]
-envlist = flake8,py34,py35,py36,py37,py38
+envlist = flake8,py35,py36,py37,py38
 
 [testenv]
 deps =



View it on GitLab: https://salsa.debian.org/med-team/python-dnaio/-/commit/f30555526395dc7f296505f4fbe91e97bb4418b5

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-dnaio/-/commit/f30555526395dc7f296505f4fbe91e97bb4418b5
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20201108/079d594c/attachment-0001.html>


More information about the debian-med-commit mailing list