Support #5041
closed

Use Saxon-HE/C build package anywhere to use in Python application
0%
Description
Hi,
I have downloaded and installed the Saxon-HE/C linux binary and build the Python extension using command 'python3 saxon-setup.py build_ext -if'. As a result 'saxonc.cpp' and 'saxonc.cpython-37m-x86_64-linux-gnu.so' files generated inside 'python-saxon' folder.
Now I want to copy and use the build (I guess only the 'python-saxon' folder) as library in a different system(PC - Win or Linux or Mac) and call from Python application.
Is it possible? If not then where can I download that kind of code package (just copy paste and use)?
Thanks, Santanu
Updated by O'Neil Delpratt over 2 years ago
- Status changed from New to AwaitingInfo
Dear User,
You should be able to move the Saxon/C library to the default location for python libraries. The following forum post should help you to setup: https://saxonica.plan.io/boards/3/topics/7701
Also check out https://docs.python.org/3/tutorial/modules.html#the-module-search-path
Updated by santanu das over 2 years ago
Thanks Neil for your reply.
As I have understood, the workaround from the above links works within the same system, means you can use the Python extension within any project in the same system where you have made the build by setting up the environment variables.
But in my case the build was made in a linux system then I copied that in a Win 10 laptop. And performed the following steps:
- Saxon location: "D:\Content\SaxonHEC1.2.1\Saxon.C.API\python-saxon"
- Added above path in PYTHONPATH and Path environment variables.
- Created a file with Notepad++ in another folder with the code below:
import sys sys.path.append("D:\Content\SaxonHEC1.2.1\Saxon.C.API\python-saxon") import saxonc proc = saxonc.PySaxonProcessor(license=False)
It says "ModuleNotFoundError: No module named 'saxonc'"
Any thoughts?
Thanks.
Updated by Martin Honnen over 2 years ago
In my understanding you need to install and build on Windows to have a Windows specific Python extension, you need to install and build on Linux to have a Linux compatible Python extension, you can't expect to copy a C/C++ based extension from one OS/platform to another OS/platform.
Updated by O'Neil Delpratt over 2 years ago
Hi,
Yes Martin is right.I misinterpreted the initial requirement in comment #0. You cannot build the Saxon/C python library on one os platform to use on a different os platform. You will need to download the Saxon/C installer for each os system you intend to use.
Updated by santanu das over 2 years ago
Thanks Neil and Martin for your inputs.
One more question, I want to use Saxon in AWS lambda script. Does it require the same type of installation and configurations' that we do for physical systems or it requires any special configuration?
Any suggestion or forum post link will be helpful.
Updated by Norm Tovey-Walsh over 2 years ago
There's no reason that it shouldn't work in a lambda.
The only challenge, I think, will be making sure that your lambda includes all the necessary libraries and dependencies. I've never tried to install Saxon/C in a lambda, but I did get a slightly complicated Python+ImageMagick+exiftool (everyone's favorite lambda, the one that uploads photographs automatically) lambda working with serverless
.
It's been a while since I did that, but I seem to recall that serverless
lets you run the whole thing locally in a container that mocks up the AWS interfaces. That really speeds up the process of working out which dependencies are missing!
Updated by santanu das over 2 years ago
Finally, I could integrate the Saxon/C Python extension combined with 'rt' and 'libsaxonhec.so' in AWS lambda.
Cheers!!!
Updated by O'Neil Delpratt 10 months ago
- Status changed from AwaitingInfo to Closed
I am closing this issue given we have released Python package wheels for SaxonC 12.
Please register to edit this issue