scrapinghub / dateparser

python parser for human readable dates
BSD 3-Clause "New" or "Revised" License
2.55k stars 465 forks source link

Pypy (2) breaks on importing parse #565

Closed Bachmann1234 closed 4 years ago

Bachmann1234 commented 5 years ago

When installing dateparser the most recent version of the regex library is installed which seems to break in pypy (works in pypy3 in my experiments)

When I uninstall it and install the version in your requirements.txt the import seems to work fine. Here is my session

venv ❯ pypy
Python 2.7.13 (8cdda8b8cdb8ff29d9e620cccd6c5edd2f2a23ec, Sep 04 2019, 09:54:49)
[PyPy 7.1.1 with GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> from dateparser import parse
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bachmann/Desktop/venv/site-packages/dateparser/__init__.py", line 4, in <module>
    from .date import DateDataParser
  File "/Users/bachmann/Desktop/venv/site-packages/dateparser/date.py", line 13, in <module>
    from dateparser.date_parser import date_parser
  File "/Users/bachmann/Desktop/venv/site-packages/dateparser/date_parser.py", line 8, in <module>
    from .timezone_parser import pop_tz_offset_from_string
  File "/Users/bachmann/Desktop/venv/site-packages/dateparser/timezone_parser.py", line 79, in <module>
    _tz_offsets = list(get_tz_offsets())
  File "/Users/bachmann/Desktop/venv/site-packages/dateparser/timezone_parser.py", line 70, in get_tz_offsets
    yield get_offset(tz_obj, regex, repl=replace, replw=replacewith)
  File "/Users/bachmann/Desktop/venv/site-packages/dateparser/timezone_parser.py", line 57, in get_offset
    'regex': re.compile(re.sub(repl, replw, regex % tz_obj[0]), re.IGNORECASE),
  File "/Users/bachmann/Desktop/venv/site-packages/regex/regex.py", line 276, in sub
    endpos, concurrent)
ImportError: No module named regex.regex.regex
>>>>

~/Desktop 26s
venv ❯ pip freeze
DEPRECATION: A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
cffi==1.12.3
dateparser==0.7.1
greenlet==0.4.13
python-dateutil==2.8.0
pytz==2019.2
readline==6.2.4.1
regex==2019.8.19
six==1.12.0
tzlocal==2.0.0
venv ❯ pip uninstall regex
DEPRECATION: A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Uninstalling regex-2019.8.19:
  Would remove:
    /Users/bachmann/Desktop/venv/site-packages/regex-2019.8.19.dist-info/*
    /Users/bachmann/Desktop/venv/site-packages/regex/*
Proceed (y/n)? y
  Successfully uninstalled regex-2019.8.19

~/Desktop
venv ❯ pip install regex==2019.01.24
DEPRECATION: A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting regex==2019.01.24
  Downloading https://files.pythonhosted.org/packages/aa/eb/8a56aaf3a0a2a70cf2e017a8fb1ac5b6bad64a143d3096b0c0282b17ead1/regex-2019.01.24.tar.gz (647kB)
     |████████████████████████████████| 655kB 2.7MB/s
Building wheels for collected packages: regex
  Building wheel for regex (setup.py) ... done
  Created wheel for regex: filename=regex-2019.1.24-pp271-pypy_41-macosx_10_14_x86_64.whl size=296874 sha256=59f162bddd3104491d1a051dfa43ee0cade5bbdb35b3c0ef22b655e57c54ce66
  Stored in directory: /Users/bachmann/Library/Caches/pip/wheels/ff/8d/55/2ccfa47df2bc65ea83c605075f690c6338a2da89f82c171133
Successfully built regex
Installing collected packages: regex
Successfully installed regex-2019.1.24

~/Desktop 9s
venv ❯ python
Python 2.7.13 (8cdda8b8cdb8ff29d9e620cccd6c5edd2f2a23ec, Sep 04 2019, 09:54:49)
[PyPy 7.1.1 with GCC 4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>> from dateparser import parse
>>>>

Im not sure if yall want to pin the version in setup.py or if there is an issue that I should file over at the regex project.

Gallaecio commented 4 years ago

~May this be a duplicate of #505?~

knowledgecomputer2018 commented 4 years ago

hi thank you very much .i solve my problem . god willing

noviluni commented 4 years ago

We are removing support for Python 2 and Pypy, so I will close this issue. Thank you all for raising this. In any case, we are discussing if we will add support for Pypy3 in this issue: https://github.com/scrapinghub/dateparser/issues/745. If you are interested, let me know your insights.