Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Backports:SLE-15-SP6:Update
pocketsphinx
use-python3.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File use-python3.patch of Package pocketsphinx
Index: pocketsphinx-0.8/python/Makefile.am =================================================================== --- pocketsphinx-0.8.orig/python/Makefile.am +++ pocketsphinx-0.8/python/Makefile.am @@ -13,7 +13,7 @@ noinst_HEADERS = bogus_pygobject.h if BUILD_PYTHON # Setuptools isn't really compatible with distutils, unfortunately -SETUPTOOLS_CRAP = `python -c 'import setuptools' 2>/dev/null \ +SETUPTOOLS_CRAP = `python3 -c 'import setuptools' 2>/dev/null \ && echo --single-version-externally-managed --record filelist.txt` all-local: pymod-build-stamp @@ -40,5 +40,5 @@ endif if BUILD_CYTHON $(srcdir)/pocketsphinx.c: $(srcdir)/pocketsphinx.pyx $(srcdir)/pocketsphinx.pxd - cython -o $@ $< $(CPPFLAGS) -I$(sphinxbase)/python + cython -3 -o $@ $< $(CPPFLAGS) -I$(sphinxbase)/python endif Index: pocketsphinx-0.8/python/Makefile.in =================================================================== --- pocketsphinx-0.8.orig/python/Makefile.in +++ pocketsphinx-0.8/python/Makefile.in @@ -217,7 +217,7 @@ pkginclude_HEADERS = pocketsphinx.pxd noinst_HEADERS = bogus_pygobject.h # Setuptools isn't really compatible with distutils, unfortunately -@BUILD_PYTHON_TRUE@SETUPTOOLS_CRAP = `python -c 'import setuptools' 2>/dev/null \ +@BUILD_PYTHON_TRUE@SETUPTOOLS_CRAP = `python3 -c 'import setuptools' 2>/dev/null \ @BUILD_PYTHON_TRUE@ && echo --single-version-externally-managed --record filelist.txt` all: all-am @@ -505,7 +505,7 @@ uninstall-am: uninstall-local uninstall- @BUILD_PYTHON_TRUE@ touch $@ @BUILD_CYTHON_TRUE@$(srcdir)/pocketsphinx.c: $(srcdir)/pocketsphinx.pyx $(srcdir)/pocketsphinx.pxd -@BUILD_CYTHON_TRUE@ cython -o $@ $< $(CPPFLAGS) -I$(sphinxbase)/python +@BUILD_CYTHON_TRUE@ cython -3 -o $@ $< $(CPPFLAGS) -I$(sphinxbase)/python # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. Index: pocketsphinx-0.8/python/pocketsphinx.pyx =================================================================== --- pocketsphinx-0.8.orig/python/pocketsphinx.pyx +++ pocketsphinx-0.8/python/pocketsphinx.pyx @@ -7,6 +7,8 @@ # # Author: David Huggins-Daines <dhuggins@cs.cmu.edu> +from libc.stdio cimport fdopen + cdef class LatNode: """ Node in a word lattice. @@ -265,7 +267,7 @@ cdef class Lattice: self.dag = ps_lattice_read(NULL, latfile) self.n_frames = ps_lattice_n_frames(self.dag) if self.dag == NULL: - raise RuntimeError, "Failed to read lattice from %s" % latfile + raise RuntimeError("Failed to read lattice from %s" % latfile) cdef set_dag(Lattice self, ps_lattice_t *dag): ps_lattice_retain(dag) @@ -366,7 +368,7 @@ cdef class Lattice: rv = ps_lattice_write(self.dag, outfile) if rv < 0: - raise RuntimeError, "Failed to write lattice to %s" % outfile + raise RuntimeError("Failed to write lattice to %s" % outfile) cdef class Segment: @@ -469,11 +471,11 @@ cdef class Decoder: i = i + 2 config = sb.cmd_ln_parse_r(NULL, ps_args(), self.argc, self.argv, 0) if config == NULL: - raise RuntimeError, "Failed to parse argument list" + raise RuntimeError("Failed to parse argument list") self.ps = ps_init(config) sb.cmd_ln_free_r(config) if self.ps == NULL: - raise RuntimeError, "Failed to initialize PocketSphinx" + raise RuntimeError("Failed to initialize PocketSphinx") cdef set_boxed(Decoder self, box): cdef ps_decoder_t *ps @@ -506,7 +508,7 @@ cdef class Decoder: cdef int nsamp cdef char *cuttid - cfh = PyFile_AsFile(fh) + cfh = fdopen(PyObject_AsFileDescriptor(fh), "rb") if uttid == None: cuttid = NULL else: @@ -525,7 +527,7 @@ cdef class Decoder: cdef FILE *cfh cdef char *cuttid - cfh = PyFile_AsFile(fh) + cfh = fdopen(PyObject_AsFileDescriptor(fh), "rb") if uttid == None: cuttid = NULL else: @@ -555,7 +557,7 @@ cdef class Decoder: @param data: Audio data to process. This is packed binary data, which consists of single-channel, 16-bit PCM audio, at the sample rate specified when the decoder was initialized. - @type data: str + @type data: bytes @param no_search: Buffer the data without actually processing it (default is to process the data as it is received). @type no_search: bool @@ -569,17 +571,17 @@ cdef class Decoder: cdef char* strdata cdef raw_data_ptr cdata - PyString_AsStringAndSize(data, &strdata, &len) + PyBytes_AsStringAndSize(data, &strdata, &len) cdata = strdata - if ps_process_raw(self.ps, cdata, len / 2, no_search, full_utt) < 0: - raise RuntimeError, "Failed to process %d samples of audio data" % len / 2 + if ps_process_raw(self.ps, cdata, len // 2, no_search, full_utt) < 0: + raise RuntimeError("Failed to process %d samples of audio data" % len // 2) def end_utt(self): """ Finish processing an utterance. """ if ps_end_utt(self.ps) < 0: - raise RuntimeError, "Failed to stop utterance processing" + raise RuntimeError("Failed to stop utterance processing") def get_hyp(self): """ @@ -633,7 +635,7 @@ cdef class Decoder: dag = ps_get_lattice(self.ps) if dag == NULL: - raise RuntimeError, "Failed to create word lattice" + raise RuntimeError("Failed to create word lattice") lat = Lattice() lat.set_dag(dag) return lat @@ -726,7 +728,7 @@ cdef class Decoder: cdef SegmentIterator itor first_seg = ps_seg_iter(self.ps, &score) if first_seg == NULL: - raise RuntimeError, "Failed to create best path word segment iterator" + raise RuntimeError("Failed to create best path word segment iterator") itor = SegmentIterator() itor.set_iter(first_seg) return (itor, score) Index: pocketsphinx-0.8/python/setup.py.in =================================================================== --- pocketsphinx-0.8.orig/python/setup.py.in +++ pocketsphinx-0.8/python/setup.py.in @@ -5,7 +5,7 @@ except: import distutils.command.install import os -import commands +import subprocess import sys class bogus_uninstall(distutils.command.install.install): @@ -29,7 +29,7 @@ class bogus_uninstall(distutils.command. if os.path.isdir(f): dirs[f] = 1 continue - print "Trying to remove file", f + print("Trying to remove file", f) try: os.unlink(f) except: @@ -38,11 +38,11 @@ class bogus_uninstall(distutils.command. # This is really not guaranteed to work!!! for d in dirs: while d != self.prefix: - print "Trying to remove dir", d + print("Trying to remove dir", d) try: if d.endswith(".egg-info"): files=[os.path.join(d,f) for f in os.listdir(d)] - print "Trying to remove:", " ".join(files) + print("Trying to remove:", " ".join(files)) for f in files: os.unlink(f) os.rmdir(d) except: @@ -51,7 +51,7 @@ class bogus_uninstall(distutils.command. def pkgconfig(*packages, **kw): flag_map = {'-I': 'include_dirs', '-L': 'library_dirs', '-l': 'libraries'} - for token in commands.getoutput("pkg-config --libs --cflags %s" % ' '.join(packages)).split(): + for token in subprocess.getoutput("pkg-config --libs --cflags %s" % ' '.join(packages)).split(): kw.setdefault(flag_map.get(token[:2]), []).append(token[2:]) return kw Index: pocketsphinx-0.8/python/pocketsphinx.pxd =================================================================== --- pocketsphinx-0.8.orig/python/pocketsphinx.pxd +++ pocketsphinx-0.8/python/pocketsphinx.pxd @@ -28,8 +28,8 @@ cdef extern from "stdio.h": ctypedef struct FILE # oh dear... cdef extern from "Python.h": - FILE *PyFile_AsFile(object p) - int PyString_AsStringAndSize(object p, char **buf, Py_ssize_t *len) except -1 + int PyObject_AsFileDescriptor(object) + int PyBytes_AsStringAndSize(object p, char **buf, Py_ssize_t *len) except -1 # Don't rely on having PyGTK actually installed cdef extern from "bogus_pygobject.h":
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor