ujson (ultrajson) causes issues in virtualenv created pyenv
Since importing ujson fails in a 3.7 pyenv virtualenv when 3.7 is not provided by the OS (it's the point of pyenv), the Python Language Server can't run there. I have this problem since the move to Ultrajson: #696.
> ./bin/pyls
Traceback (most recent call last):
File "./bin/pyls", line 6, in <module>
from pyls.__main__ import main
File "/home/bertrand/tmp/ujson-test/lib/python3.7/site-packages/pyls/__main__.py", line 7, in <module>
import ujson as json
ImportError: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory
Issue reported upstream: https://github.com/esnme/ultrajson/issues/345.
But since Ultrajson doesn't seem to be maintained, maybe it would make sense to consider an alternative, fast, JSON parser? orjson looks like an interesting, more maintained alternative, and it seems to support Windows, which might help with issues such as #704.
We're considering alternatives to ujson. For now, please install a compiler (i.e. gcc) so that pip can create wheels for ujson.
I do have a compiler in my PATH but that doesn't help: I still get a DLL ujson.cpython-37m-x86_64-linux-gnu.so dynamically linked to libpython3.7m.so.1.0 which isn't found. However, if I use pip install --no-binary=ujson ujson, then it works!
With regards to alternatives, it doesn't look easy because neither rapidjson or orjson (the JSON libraries I know of) seem to support Python 2. I have branches for pyls/python-jsonrpc-server with orjson in case you'd be interested.
Well, Python 2 support ends in a month, so we can start using orjson then (which was one of our plans, by the way).
Well, Python 2 support ends in a month, so we can start using orjson then (which was one of our plans, by the way).
won't orjson still require some stuff to compile it? Since it is rust-based. Also, won't https://github.com/palantir/python-language-server/pull/704/files solve the issue here?
won't orjson still require some stuff to compile it? Since it is rust-based.
Yes but there are wheels (binaries) for that so no compiler will be needed with wheels available which is precisely what we don't have with ujson since they did not create them and there is no one responding there.
Also, won't https://github.com/palantir/python-language-server/pull/704/files solve the issue here?
That one took care of the issue on Windows, but as @bbc2 showed here, this problem is also present in other platforms.
Also, won't https://github.com/palantir/python-language-server/pull/704/files solve the issue here?
That one took care of the issue on Windows, but as @bbc2 showed here, this problem is also present in other platforms.
Yes, but that PR also add try ... except on ujson import, so it falls back to regular json.
Sure, but pip install still tries to install ujson for macOS and Linux.
@ccordoba12 - what if we removed ujson as a dependency, but kept the optimistic try/except import statements?
I'm ok with that. But we'd also need to do it for python-jsonrpc-server.
Then it should be stated very clearly in readme. Otherwise it will be buried in source code :/
On Tue, Jan 21, 2020, 22:25 Carlos Cordoba [email protected] wrote:
I'm ok with that. But we'd also need to do it for python-jsonrpc-server.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/palantir/python-language-server/issues/709?email_source=notifications&email_token=AHR3EDTOLNAMTKM3QF7IEOTQ65K2BA5CNFSM4JTTZOB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJREFAY#issuecomment-576864899, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHR3EDVUUS5K3OGV4DQCY43Q65K2BANCNFSM4JTTZOBQ .
Similar to other plugins though. So we could have a pip install python-language-server[ujson], and include it in the all definition.
Well, that is alright. Although, I still think it is better to note that on readme.
Plugins, at least, are noticable by "enable/disable" parameters in editors
or by plugins folder. While ujson is one of the imports in a file that is
covered by try so it will never fail.
On Tue, Jan 21, 2020, 22:30 Nicholas Gates [email protected] wrote:
Similar to other plugins though. So we could have a pip install python-language-server[ujson], and include it in the all definition.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/palantir/python-language-server/issues/709?email_source=notifications&email_token=AHR3EDTYCYWQURKWMQ24DJDQ65LQDA5CNFSM4JTTZOB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJREXEI#issuecomment-576867217, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHR3EDRYSCZNYSSZ63XSX6DQ65LQDANCNFSM4JTTZOBQ .