简体   繁体   English

使 saxon-c 在 Python 中可用

[英]Making saxon-c available in Python

I have just read that Saxon is now available for Python, and that's just great fun and good, but can anyone write a tutorial on how to make it available for Python/Anaconda/WingIDE or similar?我刚刚读到 Saxon 现在可用于 Python,这非常有趣而且很好,但是任何人都可以编写有关如何使其可用于 Python/Anaconda/WingIDE 或类似软件的教程吗? I am used to installing with pip or conda, and pointing to a package/wheel for integration in my environment, but I have never started from scratch, as it feels I am doing here, or am I missing something?我习惯于使用 pip 或 conda 安装,并指向一个包/轮子以在我的环境中集成,但我从未从头开始,因为感觉我在这里做的,还是我错过了什么?

The doc states that:该文档指出:

The Python extension on the Linux and MacOS platforms can be built using the following command: python3 saxon-setup.py build_ext -if Linux 和 MacOS 平台上的 Python 扩展可以使用以下命令构建: python3 saxon-setup.py build_ext -if

Well, I'm on a windows machine so what then?好吧,我在 Windows 机器上,那又怎样? I've tried to read up on this subject, but recepies and ".h" files seems to be way over my head.我试图阅读这个主题,但接收和“.h”文件似乎超出了我的脑海。

I just really want to get this to work on Python, but for now, I'm stuck with xslt and xpath 1.0 in Python, and having to wrestle through Java for xslt 2+.我真的很想让它在 Python 上工作,但现在,我被困在 Python 中的 xslt 和 xpath 1.0,并且不得不通过 Java 为 xslt 2+ 努力。

Any help would be apreciated!任何帮助将不胜感激!

I will write another question here on StackOverflow, but with focus on how to build using Cython when I have a 64-bit version of Anaconda installed.我将在 StackOverflow 上写另一个问题,但重点是当我安装了 64 位版本的 Anaconda 时如何使用 Cython 进行构建。 This seems to be my initial problem.这似乎是我最初的问题。

I have managed to build saxonc for Python on a couple of Windows 10 machines where I had already installed Visual Studio 2017 or 2019 with Python 3 support and C/C++ support.我已经成功地在几台 Windows 10 机器上为 Python 构建了 saxonc,在这些机器上我已经安装了 Visual Studio 2017 或 2019,支持 Python 3 和 C/C++。

The steps are roughly:大致步骤如下:

  • Install Saxon-C HE 1.2.1 from Saxonica从 Saxonica 安装 Saxon-C HE 1.2.1
  • For Python: update pip对于 Python:更新 pip
  • Use pip to install Cython: pip install Cython使用 pip 安装 Cython: pip install Cython
  • open Powershell for Python 3.7 (with administrator rights if you installed in C:\\Program Files)打开 Python 3.7 的 Powershell(如果您安装在 C:\\Program Files 中,则具有管理员权限)
  • cd Saxon install dir (eg cd C:\\Program Files\\Saxonica\\SaxonHEC1.2.1 ) cd Saxon 安装目录(例如cd C:\\Program Files\\Saxonica\\SaxonHEC1.2.1
  • cd Saxon.C.API\\python-saxon
  • run py saxon-setup.py build_ext -if运行py saxon-setup.py build_ext -if
  • for arbitrary Powershell Windows need to set: $Env:PYTHONPATH += ";C:\\Program Files\\Saxonica\\SaxonHEC1.2.1\\Saxon.C.API\\python-saxon" to ensure that "import saxonc" in any Python program finds the saxonc module对于任意 Powershell Windows 需要设置: $Env:PYTHONPATH += ";C:\\Program Files\\Saxonica\\SaxonHEC1.2.1\\Saxon.C.API\\python-saxon"以确保任何 Python 程序中的“import saxonc”都能找到萨克森模块

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM