wharris / esmre Goto Github PK
View Code? Open in Web Editor NEWPython extension module for accelerating regular expressions using libesm
License: GNU Lesser General Public License v2.1
Python extension module for accelerating regular expressions using libesm
License: GNU Lesser General Public License v2.1
Hi,
First of all, cheers for this package!
I was trying to install it with pip3, I get
Collecting esmre
Using cached esmre-0.5.2.tar.gz (50 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: setuptools in ./.local/lib/python3.10/site-packages (from esmre) (63.4.1)
Building wheels for collected packages: esmre
Building wheel for esmre (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for esmre (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [132 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.10
copying src/esmre.py -> build/lib.linux-x86_64-3.10
running build_ext
creating build/temp.linux-x86_64-3.10
creating build/temp.linux-x86_64-3.10/src
creating build/temp.linux-x86_64-3.10/src/esm
x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.10 -c src/esm.c -o build/temp.linux-x86_64-3.10/src/esm.o
src/esm.c: In function ‘__pyx_tp_dealloc_3esm_Index’:
src/esm.c:2127:5: error: lvalue required as increment operand
2127 | ++Py_REFCNT(o);
| ^~
src/esm.c:2129:5: error: lvalue required as decrement operand
2129 | --Py_REFCNT(o);
| ^~
src/esm.c: In function ‘__Pyx_modinit_type_init_code’:
src/esm.c:2386:24: error: ‘PyTypeObject’ {aka ‘struct _typeobject’} has no member named ‘tp_print’
2386 | __pyx_type_3esm_Index.tp_print = 0;
| ^
src/esm.c: In function ‘__Pyx_ParseOptionalKeywords’:
src/esm.c:2892:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2892 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2892:21: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
2892 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:580:45: note: declared here
580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
| ^~~~~~~~~~~~~~~~~~~
src/esm.c:2892:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2892 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2892:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2892 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2892:21: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
2892 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:580:45: note: declared here
580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
| ^~~~~~~~~~~~~~~~~~~
src/esm.c:2892:21: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2892 | (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2908:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2908 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2908:25: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
2908 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:580:45: note: declared here
580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
| ^~~~~~~~~~~~~~~~~~~
src/esm.c:2908:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2908 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2908:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2908 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
src/esm.c:2908:25: warning: ‘PyUnicode_AsUnicode’ is deprecated [-Wdeprecated-declarations]
2908 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:580:45: note: declared here
580 | Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
| ^~~~~~~~~~~~~~~~~~~
src/esm.c:2908:25: warning: ‘_PyUnicode_get_wstr_length’ is deprecated [-Wdeprecated-declarations]
2908 | (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
| ^
In file included from /usr/include/python3.10/unicodeobject.h:1046,
from /usr/include/python3.10/Python.h:83,
from src/esm.c:18:
/usr/include/python3.10/cpython/unicodeobject.h:446:26: note: declared here
446 | static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for esmre
Failed to build esmre
ERROR: Could not build wheels for esmre, which is required to install pyproject.toml-based projects
Would it be possible to fix this, so that esmre
gets installed?
Thanks,
Eli
May be I don't understand what exactly query
method does. I think it returns provided objects for matched patterns. Then I get false positive error in some cases.
index = esmre.Index()
index.enter(r'download\.com', 'mypattern')
index.query('http://example.com/download')
Out: ['mypattern']
Hi, I run pip install esmre
, and I get error.
How to install it?
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
Collecting esmre
Downloading http://mirrors.tencentyun.com/pypi/packages/b2/e6/d5faf9881a91bda0ae85b210df399d19a74babf3f53edbf653b454cb93fe/esmre-1.0.tar.gz (56 kB)
|████████████████████████████████| 56 kB 585 kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from esmre) (45.2.0)
Building wheels for collected packages: esmre
Building wheel for esmre (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 /tmp/tmpk6vezx68 build_wheel /tmp/tmpm6lyks41
cwd: /tmp/pip-install-tzdd5nc5/esmre
Complete output (19 lines):
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-38
copying src/esmre.py -> build/lib.linux-x86_64-cpython-38
running build_ext
building 'esm' extension
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/src
creating build/temp.linux-x86_64-cpython-38/src/esm
x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.8 -c src/esm.c -o build/temp.linux-x86_64-cpython-38/src/esm.o
src/esm.c:20:10: fatal error: Python.h: No such file or directory
20 | #include "Python.h"
| ^~~~~~~~~~
compilation terminated.
/tmp/pip-build-env-bs75wjag/overlay/lib/python3.8/site-packages/setuptools/dist.py:770: UserWarning: Usage of dash-separated 'index-url' will not be supported in future versions. Please use the underscore name 'index_url' instead
warnings.warn(
error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
----------------------------------------
ERROR: Failed building wheel for esmre
Failed to build esmre
ERROR: Could not build wheels for esmre which use PEP 517 and cannot be installed directly
When I run pip install esmre
, it fails. I noticed there was a closed issue that also had a similar problem like this: #4. I think the latest Cython release may be causing this problem. I ran this with Python 3.10.12. I also tested it on Python 3.8.16, where it also failed. Thank you, I hope this is helpful.
Output from pip install esmre
for Python 3.10.12:
Collecting esmre
Using cached esmre-1.0.tar.gz (56 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [53 lines of output]
/tmp/pip-build-env-bbzfjcft/overlay/lib/python3.10/site-packages/Cython/Compiler/Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /tmp/pip-install-5og48toi/esmre_53cbe567461a4754bfe17e322b101519/src/esm.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
Error compiling Cython file:
------------------------------------------------------------
...
self._index = aho_corasick.ac_index_new()
if self._index is NULL:
raise MemoryError()
def __dealloc__(self):
aho_corasick.ac_index_free(self._index, decref_result_object)
^
------------------------------------------------------------
src/esm.pyx:28:48: Cannot assign type 'ac_error_code (void *, void *) except *' to 'ac_free_function'
Error compiling Cython file:
------------------------------------------------------------
...
result_list = []
status = aho_corasick.ac_index_query_cb(self._index,
phrase,
len(phrase),
append_result,
^
------------------------------------------------------------
src/esm.pyx:64:42: Cannot assign type 'ac_error_code (void *, ac_result *) except *' to 'ac_result_callback'
Compiling src/esm.pyx because it changed.
[1/1] Cythonizing src/esm.pyx
this would output: ['savoy opera'], but it should not match for there is a '$' at the end of the index
D:\Source\Python\Packages_312>pip install esmre
Collecting esmre
Using cached esmre-1.0.1.tar.gz (56 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... error
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [56 lines of output]
D:\Python3\Lib\site-packages\Cython\Compiler\Main.py:381: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: C:\Users\chiang\AppData\Local\Temp\pip-install-xyaaiesy\esmre_0ecab97529f34f98a1fed05278744bd3\src\esm.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
Error compiling Cython file:
------------------------------------------------------------
...
self._index = aho_corasick.ac_index_new()
if self._index is NULL:
raise MemoryError()
def __dealloc__(self):
aho_corasick.ac_index_free(self._index, decref_result_object)
^
------------------------------------------------------------
src\esm.pyx:28:48: Cannot assign type 'ac_error_code (void *, void *) except *' to 'ac_free_function' (alias of 'ac_error_code (*)(void *, void *) noexcept'). Exception values are incompatible. Suggest adding 'noexcept' to the type of 'decref_result_object'.
Error compiling Cython file:
------------------------------------------------------------
...
result_list = []
status = aho_corasick.ac_index_query_cb(self._index,
phrase,
len(phrase),
append_result,
^
------------------------------------------------------------
src\esm.pyx:64:42: Cannot assign type 'ac_error_code (void *, ac_result *) except *' to 'ac_result_callback' (alias of 'ac_error_code (*)(void *, ac_result *) noexcept'). Exception values are incompatible. Suggest adding 'noexcept' to the type of 'append_result'.
Compiling src/esm.pyx because it changed.
[1/1] Cythonizing src/esm.pyx
Traceback (most recent call last):
File "D:\Python3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 353, in <module>
main()
File "D:\Python3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python3\Lib\site-packages\pip\_vendor\pyproject_hooks\_in_process\_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
^^^^^^^^^^^^^^^^^^^^^
File "D:\Python3\Lib\site-packages\setuptools\build_meta.py", line 325, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Python3\Lib\site-packages\setuptools\build_meta.py", line 295, in _get_build_requires
self.run_setup()
File "D:\Python3\Lib\site-packages\setuptools\build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "D:\Python3\Lib\site-packages\setuptools\build_meta.py", line 311, in run_setup
exec(code, locals())
File "<string>", line 53, in <module>
File "D:\Python3\Lib\site-packages\Cython\Build\Dependencies.py", line 1154, in cythonize
cythonize_one(*args)
File "D:\Python3\Lib\site-packages\Cython\Build\Dependencies.py", line 1321, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: src/esm.pyx
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
I was wondering what the best way to make esmre.Index objects pickleable / serializable. It seems that it doesnt like the 'Threading.lock' - we could add a reduce function and probably would want to somehow keep track of the list of original regexes / objects (so the object could be rebuilt), or else maybe we would also need to pickle the esm.Index object itself?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.