以编程方式获取Python cflags和libs以编译C扩展

时间:2015-10-29 03:02:53

标签: python c cython

前奏

在linux中可以运行:

npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs
node_modules\\npm\\bin\\npm-cli.js" "install" "ionic" "-g"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6

npm ERR! Callback called more than once.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
C:\Users\<users>\AppData\Roaming\npm
└── (empty)

npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs
node_modules\\npm\\bin\\npm-cli.js" "install" "ionic" "-g"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6

npm ERR! Callback called more than once.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>
C:\Users\<users>\AppData\Roaming\npm
└── (empty)

npm ERR! Windows_NT 6.1.7600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs
node_modules\\npm\\bin\\npm-cli.js" "install" "ionic" "-g"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6

npm ERR! Callback called more than once.
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Windows\system32\npm-debug.log
npm ERR! code 1

得到结果:

showhide

问题

我想以编程方式从Linux和Windows中的Python脚本中获取此结果。

动机

我有几个Python脚本,我想使用cython编译为C.我正在尝试创建一个可以处理此编译过程的Python脚本。

有三个文件:$(document).ready(function() { $(".cards").find(":gt(4)").hide(); $(".cards").append("<p class=\"showhide\">Show More</p>"); $(".cards").on("click", ".showhide", function(ev) { var showhide = $(this); var container = showhide.parent(); if (showhide.text() == "Show More") { container.find(":gt(4)").show(); showhide.text("Show Less"); } else { container.find(":gt(4)").hide(); showhide.text("Show More"); } }); }); $ pkg-config --cflags --libs python3 -I/usr/include/python3.5m -lpython3.5m ;所需的执行顺序是:

  1. exec.py
  2. apkg.py
  3. bpkg.py
  4. cython --embed exec.py
  5. cython apkg.py
  6. cython bpkg.py
  7. gcc -shared -fPIC -O3 -I/usr/include/python3.5m -lpython3.5m apkg.c -o apkg.so
  8. gcc -shared -fPIC -O3 -I/usr/include/python3.5m -lpython3.5m bpkg.c -o bpkg.so将是一个已编译的可执行文件,需要在同一目录中运行apkg.so和bpkg.so。

    可靠答案

    • 使用gcc -c -O3 -I/usr/include/python3.5m -lpython3.5m exec.c:从版本3.5开始,Windows的Python安装程序(64位试用)不包括gcc -o exec exec.o

    • 用户exec:再次出现Windows兼容性问题。

0 个答案:

没有答案