简体   繁体   English

如何捆绑Python软件包(案例研究:Microsoft Visual Studio 2017)

[英]How to bundle Python packages (case study: Microsoft Visual Studio 2017)

I am building Python from source, the advantage of this being it will be optimized for my hardware (PGO). 我正在从源代码构建Python,这样做的好处是它将针对我的硬件(PGO)进行优化。 But I also want to compile 3rd party packages like NumPy or SciPy to take advantage of intel MKL (I have a Xeon CPU) and optimize them instead of just installing them via PIP which would download pre-compiled, "generic", non-optimized code. 但是我也想编译NumPy或SciPy之类的第三方软件包来利用intel MKL(我有一个Xeon CPU)并对其进行优化,而不是仅仅通过PIP来安装它们,后者会下载预先编译的,“通用”,未优化的码。

Because I would potentially compile "a lot" of packages by myself I am looking for suggestions as to how to automatize this process. 因为我可能自己自己编译“很多”软件包,所以我正在寻找有关如何自动执行此过程的建议。 The "traditional" or "standard" way of doing this would be something like this: 这样做的“传统”或“标准”方式如下:

1) compile a package 1)编译一个包

2) include that package to python (maybe using PIP?) 2)包括该包到Python(也许使用PIP?)

3) repeat the previous 2 steps for each package. 3)对每个程序包重复前面的2个步骤。

I intend to use Microsoft Visual Studio (under Windows 10 x64), so my question is this: 我打算使用Microsoft Visual Studio(在Windows 10 x64下),所以我的问题是这样的:

Is there a way to automatize this process using Visual Studio? 有没有一种方法可以使用Visual Studio自动执行此过程? if so, Can anyone give me a hint as to what to look for? 如果是这样, 有人可以给我提示要寻找什么吗?

I am new to Visual Studio and I am not asking for a complete "How To" but I would appreciate someone telling me if this can be done (or feasible, depending on what packages need to be compiled), otherwise I would revert back to manually make that process by compiling and adding them to Python one by one. 我是Visual Studio的新手,我并没有要求完整的“操作方法”,但我希望有人告诉我是否可以做到这一点(或可行,取决于需要编译的包),否则我将回到通过将它们逐一编译并添加到Python中来手动完成该过程。

If you're looking to optimize, you can't really automate much as each library will need its own customization. 如果您要进行优化,则不能真正实现自动化,因为每个库都需要自己的自定义。 otherwise pip is probably the way to go. 否则点子可能是要走的路。 Realistically however, you'll only probably need to optimize a few libraries such as the scientific stack and possibly numba for better jit compilation. 但是,实际上,您可能只需要优化一些库(例如科学堆栈),还可能需要优化numba才能更好地进行jit编译。

TLDR; TLDR; install numpy from source using the blas/lapack (math libs) optimized for your system and use pip for the rest. 使用针对您的系统优化的blas / lapack(数学库)从源代码安装numpy,其余部分则使用pip。

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

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