开发者

Python/jython coexisting in virtualenv

开发者 https://www.devze.com 2023-04-03 16:08 出处:网络
I have Python code split into a web frontend and consumer backend. The backend has to run under Jython for interoperability with some Java libraries, but we want to run the webserver in cpython/mod_ws

I have Python code split into a web frontend and consumer backend. The backend has to run under Jython for interoperability with some Java libraries, but we want to run the webserver in cpython/mod_wsgi because of memory problems we've had running it in Jython through Jetty.

We use virtualenv for developm开发者_运维技巧ent, and I've currently got two virtualenv directories, one for cpython and one for jython. My question is whether both interpreters can happily coexist in one virtualenv (primarily to save having to update installed libraries twice, but also from curiosity). I've initialized the same environment with both interpreters:

virtualenv -p python environ
virtualenv -p jython environ

I can run both interpreters, and I can symlink environ/Lib/site-packages and environ/lib/python/site-packages so that they're both looking at the same place. As long as there are no libraries relying on C extensions/optimizations I can't see why they wouldn't work in both interpreters. Anyone disagree or have any further things to look out for?


I don't see why the two shouldn't be able to coexist -- they use completely different infrastructure, sharing only .py files. Jython is a java program, Python is C; Jython compiles to $class files, Python to .pyc; etc etc.

The only thing to look out for (apart from avoiding C-based modules in Jython as you say) is setting PYTHONPATH and JYTHONPATH to the same value (Jython doesn't use PYTHONPATH).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号