Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex module with pypy

Tags:

python

pypy

is there any way to use this regex module with pypy?

https://pypi.python.org/pypi/regex

or any alternative regex module that works with pypy and has the features of this regex module. I did copy regex module files from my python installation into pypys lib_pypy folder, but i cannot import this module, the error is:

ImportError: No module named _regex

it seems that it cannot import _regex.pyd file. I'm using pypy3-2.1-beta1-win32, windows xp.

I also tried building the library with pypy:

pypy setup.py build -c mingw32

and i've got this error:

error: package directory 'Python3' does not exist

I tried removing package_dir={'': PKG_BASE} from setup.py and retry the build, and then there was another error:

File "...\pypy3-2.1-beta1-win32\lib-python\3\distutils\cygwinccompiler.py", line 352, in check_config_h
    fn = sysconfig.get_config_h_filename()
AttributeError: 'module' object has no attribute 'get_config_h_filename'
like image 222
Pooya Eghbali Avatar asked Sep 22 '13 13:09

Pooya Eghbali


People also ask

How to use regular expressions with regex in Python?

RegEx can be used to check if a string contains the specified search pattern. Python has a built-in package called re, which can be used to work with Regular Expressions. When you have imported the re module, you can start using regular expressions: The re module offers a set of functions that allows us to search a string for a match:

How do I install the new regex module?

I'm trying to install the new Regex module The readme.txt says::: To build and install regex for your default Python run python setup.py install To install regex for a specific version run setup.py with that interpreter, e.g. python3.1 setup.py install

Why does PyPy not work outside of U+0000?

PyPy This module is targeted at CPython. It expects that all codepoints are the same width, so it won’t behave properly with PyPy outside U+0000..U+007F because PyPy stores strings as UTF-8. Old vs new behaviour

What is the replacement for re in Python?

Alternative regular expression module, to replace re. This regex implementation is backwards-compatible with the standard ‘re’ module, but offers additional functionality. The re module’s behaviour with zero-width matches changed in Python 3.7, and this module will follow that behaviour when compiled for Python 3.7.


1 Answers

I'm afraid the library would have to be adapted to work with PyPy—PyPy doesn't support the same C extension mechanism CPython does. Also, I'm not sure if Python 3 support is ready or even usable in PyPy as of yet: they're still collecting donations for the py3k PyPy sub-project as per the right side of the home page of their site: http://pypy.org.

As to the C extension problem, if you have the time and willingness, you can try to port the library to use the CFFI module of PyPy (import cffi) to call into the C parts of regex. Luckily, as per http://doc.pypy.org/en/latest/release-2.0.0-beta2.html, CFFI is now built in to PyPy.

like image 151
Erik Kaplun Avatar answered Oct 17 '22 14:10

Erik Kaplun