Reputation: 7590
I have a conceptual doubt regarding how Python packages dependencies are installed/configured, this is related to compilation configurations.
Case 1
Installed packages pyscreenshot, image, pillow
using pip from a python 2.7 configured with ucs2
in the user lib space (--user). Executed some api to get desktop screenshot, everything runs smoothly.
Case 2
Executed another python 2.7 configured with ucs4
, it finds the packages due that those were installed in the user space. Executed same api to get desktop screenshot, it crashes. The ucs4 configuration was incompatible with how the packages works.
So why that happened? could different versions of the same packages be installed depending on how Python was configured?
Note: ucs2/ucs4 explanation https://docs.python.org/2/c-api/unicode.html
Upvotes: 2
Views: 114
Reputation: 967
So why that happened?
It happened because when both C (binary) codes were loaded into memory, each one of them treated strings in different ways. In python documentation it is clearly stated that: "... UCS2 and UCS4 Python builds are not binary compatible. Please keep this in mind when writing extensions or interfaces."
Documentation also says that: "Python’s default builds use a 16-bit type for Py_UNICODE and store Unicode values internally as UCS2." So what you did was to: install a package compatible with the default interpreter and run it with a non compatible Python interpreter.
could different versions of the same packages be installed depending on how Python was configured?
I am not sure if pip is able to handle UCS2 and UCS4 package variants. What happens when you install the same packages using the pip from your UCS4 interpreter? If the UCS2 version of the package is installed when using the UCS4 version of pip, I would recommend to download the source distribution of the package and compile it yourself with UCS4.
I know that pip can differentiate between os (windows / linux) and ABI, but I don't think it can handle UCS differences.
Upvotes: 2