Received: from mail.cmpwn.com (mail.cmpwn.com [45.56.77.53]) by nld3-dev1.alpinelinux.org (Postfix) with ESMTPS id 01388782B12 for <~alpine/aports@lists.alpinelinux.org>; Tue, 13 Aug 2019 01:45:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=cmpwn.com; s=cmpwn; t=1565660743; bh=a4V+KZOpQf/vGZiwqq6seAyGuKg6nIyrlvmL/o+v8oA=; h=From:To:Cc:Subject:Date; b=iwGW3IGMyeXOwLHd7Dekiqje78kYvjhHblbCcIm6Ym1mDKPCc0aW3LzEuVig40jok 7PbatjADd3zVxh6H/nel38QcxXTEcRzx//VpmF1cmSgBDLESTC+GXVszSjF//2KWFk tpFapqXM3eRpBDqKPEvu3ED6xbtjf7M+zObM/Z/g= From: Drew DeVault To: ~alpine/aports@lists.alpinelinux.org Cc: Drew DeVault Subject: [PATCH] testing/py3-pycdio: import tests patch Date: Tue, 13 Aug 2019 10:45:33 +0900 Message-Id: <20190813014533.13936-1-sir@cmpwn.com> X-Mailer: git-send-email 2.22.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Upstream provided a fix for the broken tests on py3. --- testing/py3-pycdio/APKBUILD | 13 +- testing/py3-pycdio/py3-tests.patch | 275 +++++++++++++++++++++++++++++ 2 files changed, 283 insertions(+), 5 deletions(-) create mode 100644 testing/py3-pycdio/py3-tests.patch diff --git a/testing/py3-pycdio/APKBUILD b/testing/py3-pycdio/APKBUILD index 858232ccf1..13f1a01060 100644 --- a/testing/py3-pycdio/APKBUILD +++ b/testing/py3-pycdio/APKBUILD @@ -2,7 +2,7 @@ pkgname=py3-pycdio _pyname=pycdio pkgver=2.0.0 -pkgrel=0 +pkgrel=1 pkgdesc="Python interface to libcdio (CD Input and Control library)" url="https://pypi.org/project/pycdio/" arch="all" @@ -11,9 +11,11 @@ depends="python3" makedepends="python3-dev libcdio-dev swig" checkdepends="py3-nose" _pypiprefix="${_pyname%${_pyname#?}}" -source="https://files.pythonhosted.org/packages/source/$_pypiprefix/$_pyname/$_pyname-$pkgver.tar.gz" -builddir="$srcdir/$_pyname-$pkgver" -options="!check" # https://savannah.gnu.org/bugs/index.php?56739 +source=" + http://git.savannah.gnu.org/cgit/libcdio/$_pyname.git/snapshot/$_pyname-release-$pkgver.tar.gz + py3-tests.patch +" +builddir="$srcdir/$_pyname-release-$pkgver" build() { python3 setup.py build @@ -27,4 +29,5 @@ package() { python3 setup.py install --prefix=/usr --root="$pkgdir" } -sha512sums="b73d49e143e4b5ebf5e8514d526a57f71d004b9ce4298743bb109902ee9551fa586384a236b26da9cd86284b2aa8c31fb02a324a1cebc03f2071d06fbd3e3285 pycdio-2.0.0.tar.gz" +sha512sums="5056de8b9226801576acf82ee4db7482b79749ff30e0d13e95ad89f60ef1b23994c8f5365e41db94c80577fde485b6fee1fcbb8d095a20bbd2f0ada841335b66 pycdio-release-2.0.0.tar.gz +87164912b4a63fe017022e113c855405f53ccd001d64a150d755381be950753f77e696cec57c589e75b5ff7d7cfa5200490a4a5050bdb506d913dbd0a34d18f1 py3-tests.patch" diff --git a/testing/py3-pycdio/py3-tests.patch b/testing/py3-pycdio/py3-tests.patch new file mode 100644 index 0000000000..f7ea3d6adc --- /dev/null +++ b/testing/py3-pycdio/py3-tests.patch @@ -0,0 +1,275 @@ +From 4c68c5a44f98a7cf3fa388ca66c7d312e44e78df Mon Sep 17 00:00:00 2001 +From: rocky +Date: Sun, 11 Aug 2019 16:54:52 -0400 +Subject: Adjust for Python 3. + +See https://savannah.gnu.org/bugs/?56739 +--- + .gitignore | 1 + + README.rst | 11 ++--- + cdio.py | 8 +++- + setup.py | 135 ++++++++++++++++++++++++++++++++++++------------------------- + 4 files changed, 92 insertions(+), 63 deletions(-) + +diff --git a/.gitignore b/.gitignore +index 252e696..caa3623 100644 +--- a/.gitignore ++++ b/.gitignore +@@ -13,4 +13,5 @@ + /pycdio.py + /pyiso9660.py + /pytracer.egg-info ++/tmp + __pycache__ +diff --git a/README.rst b/README.rst +index 5acd1a9..3643f32 100644 +--- a/README.rst ++++ b/README.rst +@@ -67,11 +67,12 @@ To build on Debian (e.g. Ubuntu): + + :: + +- apt-get install python-dev +- apt-get install libcdio-dev +- apt-get install libiso9660-dev +- apt-get install swig pkg-config +- ++ $ apt-get install python-dev ++ $ apt-get install libcdio-dev ++ $ apt-get install libiso9660-dev ++ $ apt-get install swig pkg-config ++ $ pip install -e . ++ $ make check + + Completeness + ============ +diff --git a/cdio.py b/cdio.py +index 9fb7cc8..63843cd 100644 +--- a/cdio.py ++++ b/cdio.py +@@ -19,8 +19,11 @@ and device-dependent properties of a CD-ROM can use this library.""" + + import pycdio + import _pycdio ++import sys + import types + ++PYTHON2 = sys.version_info[0] <= 2 ++ + class DeviceException(Exception): + """General device or driver exceptions""" + +@@ -182,9 +185,10 @@ def have_driver(driver_id): + + Return True if we have driver driver_id. + """ +- if isinstance(driver_id, long) or isinstance(driver_id, int): ++ if (isinstance(driver_id, int) or ++ (PYTHON2 and isinstance(driver_id, long))) : + return pycdio.have_driver(driver_id) +- elif type(driver_id)==bytes and driver_id in drivers: ++ elif type(driver_id) in (bytes, str) and driver_id in drivers: + ret = pycdio.have_driver(drivers[driver_id]) + if ret == 0: return False + if ret == 1: return True +diff --git a/setup.py b/setup.py +index 86101b7..63a5cb9 100755 +--- a/setup.py ++++ b/setup.py +@@ -1,5 +1,5 @@ + #!/usr/bin/env python +-# Copyright (C) 2015, 2018 Rocky Bernstein ++# Copyright (C) 2015, 2018-2019 Rocky Bernstein + # + # This program is free software: you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by +@@ -20,8 +20,16 @@ This gets a bit of package info from __pkginfo__.py file + """ + + # Get the required package information +-from __pkginfo__ import modname, VERSION, license, short_desc, \ +- web, author, author_email, classifiers ++from __pkginfo__ import ( ++ modname, ++ VERSION, ++ license, ++ short_desc, ++ web, ++ author, ++ author_email, ++ classifiers, ++) + + from setuptools import setup + from distutils.core import Extension +@@ -32,51 +40,57 @@ import os + import shutil + + top_dir = os.path.dirname(os.path.abspath(__file__)) +-README = os.path.join(top_dir, 'README.rst') +-pkg_config = os.getenv('PKG_CONFIG') or 'pkg-config' ++README = os.path.join(top_dir, "README.rst") ++pkg_config = os.getenv("PKG_CONFIG") or "pkg-config" ++ + + def rm_file(*paths): +- global top_dir +- toast = os.path.join(top_dir, *paths) +- try: +- os.remove(toast) +- except: +- pass +- return ++ global top_dir ++ toast = os.path.join(top_dir, *paths) ++ try: ++ os.remove(toast) ++ except: ++ pass ++ return ++ + + # Description in package will come from the README file. +-long_description = open(README).read() + '\n\n' ++long_description = open(README).read() + "\n\n" + + # We store swig sources in ./swig, but we want the generated python + # module not to appear in that directory, but instead in the top-level + # directory where we have the other modules. I'd move *all* of the modules + # to their own directory if I knew how to do that in distutils. +-swig_opts = ['-outdir', top_dir] ++swig_opts = ["-outdir", top_dir] ++ + + class custom_build(build): + # Reorder build commands such that swig generated files are also copied. +- sub_commands = [('build_ext', build.has_ext_modules), +- ('build_py', build.has_pure_modules), +- ('build_clib', build.has_c_libraries), +- ('build_scripts', build.has_scripts)] ++ sub_commands = [ ++ ("build_ext", build.has_ext_modules), ++ ("build_py", build.has_pure_modules), ++ ("build_clib", build.has_c_libraries), ++ ("build_scripts", build.has_scripts), ++ ] + + def run(self): + # Account for API change after 0.83 +- ge_2 = call([pkg_config,'--atleast-version=2.0.0','libcdio']) ++ ge_2 = call([pkg_config, "--atleast-version=2.0.0", "libcdio"]) + assert ge_2 == 0, "Need at least libcdio 2.0.0 to use this" + print("libcdio version >= 2.0.0") + build.run(self) + ++ + # Find runtime library directories for libcdio and libiso9660 using + # pkg-config. Then create the right Extension object lists which later + # get fed into setup()'s list of ext_modules. + modules = [] +-for lib_name in ('libcdio', 'libiso9660'): +- short_libname = lib_name[3:] # Strip off "lib" from name ++for lib_name in ("libcdio", "libiso9660"): ++ short_libname = lib_name[3:] # Strip off "lib" from name + + # FIXME: DRY this code. + try: +- p = Popen([pkg_config, '--libs-only-L', lib_name], stdout=PIPE) ++ p = Popen([pkg_config, "--libs-only-L", lib_name], stdout=PIPE) + except: + print("** Error trying to run pkg-config. Is it installed?") + print("** If not, see http://pkg-config.freedesktop.org") +@@ -85,47 +99,56 @@ for lib_name in ('libcdio', 'libiso9660'): + + if p.returncode is None: + # Strip off blanks and initial '-L' +- dirs = p.communicate()[0].split(b'-L')[1:] ++ dirs = p.communicate()[0].split(b"-L")[1:] + runtime_lib_dirs = [d.strip() for d in dirs] + else: +- print(("** Didn't the normal return code running pkg-config," + +- "on %s. got:\n\t%s" % [lib_name, p.returncode])) ++ print( ++ ( ++ "** Didn't the normal return code running pkg-config," ++ + "on %s. got:\n\t%s" % [lib_name, p.returncode] ++ ) ++ ) + print("** Will try to add %s anyway." % short_libname) + runtime_lib_dirs = None + library_dirs = runtime_lib_dirs +- p = Popen([pkg_config, '--cflags-only-I', lib_name], stdout=PIPE) ++ p = Popen([pkg_config, "--cflags-only-I", lib_name], stdout=PIPE) + if p.returncode is None: +- # String starts '-I' so the first entry is ''; Discard that, +- # the others we want. +- dirs = p.communicate()[0].split(b'-I')[1:] ++ # String starts '-I' so the first entry is ''; Discard that, ++ # the others we want. ++ dirs = p.communicate()[0].split(b"-I")[1:] + include_dirs = [d.strip() for d in dirs] +- p = Popen([pkg_config, '--libs-only-l', lib_name], stdout=PIPE) ++ p = Popen([pkg_config, "--libs-only-l", lib_name], stdout=PIPE) + if p.returncode is None: +- # String starts '-l' so the first entry is ''; Discard that, +- # the others we want. +- dirs = p.communicate()[0].split(b'-l')[1:] ++ # String starts '-l' so the first entry is ''; Discard that, ++ # the others we want. ++ dirs = p.communicate()[0].split(b"-l")[1:] + libraries = [d.strip().decode("utf-8") for d in dirs] + pass +- py_shortname = 'py' + short_libname +- modules.append(Extension('_' + py_shortname, +- libraries = libraries, +- swig_opts = swig_opts, +- include_dirs=include_dirs, +- library_dirs=library_dirs, +- runtime_library_dirs=runtime_lib_dirs, +- sources=['swig/%s.i' % py_shortname])) +- +-setup (author = author, +- author_email = author_email, +- classifiers = classifiers, +- cmdclass = {'build': custom_build}, +- description = short_desc, +- ext_modules = modules, +- license = license, +- long_description = long_description, +- name = modname, +- py_modules = ['cdio', 'iso9660', 'pycdio', 'pyiso9660'], +- test_suite = 'nose.collector', +- url = web, +- version = VERSION, +- ) ++ py_shortname = "py" + short_libname ++ modules.append( ++ Extension( ++ "_" + py_shortname, ++ libraries=libraries, ++ swig_opts=swig_opts, ++ include_dirs=include_dirs, ++ library_dirs=library_dirs, ++ runtime_library_dirs=runtime_lib_dirs, ++ sources=["swig/%s.i" % py_shortname], ++ ) ++ ) ++ ++setup( ++ author=author, ++ author_email=author_email, ++ classifiers=classifiers, ++ cmdclass={"build": custom_build}, ++ description=short_desc, ++ ext_modules=modules, ++ license=license, ++ long_description=long_description, ++ name=modname, ++ py_modules=["cdio", "iso9660", "pycdio", "pyiso9660"], ++ test_suite="nose.collector", ++ url=web, ++ version=VERSION, ++) +-- +cgit v1.0-41-gc330 + -- 2.22.0