Use Saxon-HE/C build package anywhere to use in Python application
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)?
#1 Updated by O'Neil Delpratt 6 months ago
- Status changed from New to AwaitingInfo
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
#2 Updated by santanu das 6 months 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'"
#3 Updated by Martin Honnen 6 months 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.
#4 Updated by O'Neil Delpratt 6 months ago
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.
#5 Updated by santanu das 6 months 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.
#6 Updated by Norm Tovey-Walsh 6 months 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
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!
Please register to edit this issue