<bdo id='CrQNw'></bdo><ul id='CrQNw'></ul>
    1. <i id='CrQNw'><tr id='CrQNw'><dt id='CrQNw'><q id='CrQNw'><span id='CrQNw'><b id='CrQNw'><form id='CrQNw'><ins id='CrQNw'></ins><ul id='CrQNw'></ul><sub id='CrQNw'></sub></form><legend id='CrQNw'></legend><bdo id='CrQNw'><pre id='CrQNw'><center id='CrQNw'></center></pre></bdo></b><th id='CrQNw'></th></span></q></dt></tr></i><div id='CrQNw'><tfoot id='CrQNw'></tfoot><dl id='CrQNw'><fieldset id='CrQNw'></fieldset></dl></div>

      <small id='CrQNw'></small><noframes id='CrQNw'>

      <legend id='CrQNw'><style id='CrQNw'><dir id='CrQNw'><q id='CrQNw'></q></dir></style></legend>
      <tfoot id='CrQNw'></tfoot>

      1. 分发带有已编译动态共享库的 Python 包

        时间:2023-09-14
        1. <i id='pb0Ty'><tr id='pb0Ty'><dt id='pb0Ty'><q id='pb0Ty'><span id='pb0Ty'><b id='pb0Ty'><form id='pb0Ty'><ins id='pb0Ty'></ins><ul id='pb0Ty'></ul><sub id='pb0Ty'></sub></form><legend id='pb0Ty'></legend><bdo id='pb0Ty'><pre id='pb0Ty'><center id='pb0Ty'></center></pre></bdo></b><th id='pb0Ty'></th></span></q></dt></tr></i><div id='pb0Ty'><tfoot id='pb0Ty'></tfoot><dl id='pb0Ty'><fieldset id='pb0Ty'></fieldset></dl></div>

              <bdo id='pb0Ty'></bdo><ul id='pb0Ty'></ul>
                <tbody id='pb0Ty'></tbody>

                  <small id='pb0Ty'></small><noframes id='pb0Ty'>

                  <tfoot id='pb0Ty'></tfoot>
                1. <legend id='pb0Ty'><style id='pb0Ty'><dir id='pb0Ty'><q id='pb0Ty'></q></dir></style></legend>
                2. 本文介绍了分发带有已编译动态共享库的 Python 包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何将 Python 模块与预编译的 .so 库打包在一起?具体来说,我该如何编写 setup.py 以便当我在 Python 中执行此操作时

                  How do I package a Python module together with a precompiled .so library? Specifically, how do I write setup.py so that when I do this in Python

                  >>> import top_secret_wrapper
                  

                  不用设置LD_LIBRARY_PATH也能轻松找到top_secret.so?

                  It can easily find top_secret.so without having to set LD_LIBRARY_PATH?

                  在我的模块开发环境中,我的文件结构如下:

                  In my module development environment, I have the following file structure:

                  .
                  ├── top_secret_wrapper
                  │   ├── top_secret.so
                  │   └── __init__.py
                  └── setup.py
                  

                  __init__.py 里面,我有类似的东西:

                  Inside __init__.py, I have something like:

                  import top_secret
                  

                  这是我的 setup.py

                  from setuptools import setup, Extension
                  
                  setup(
                      name = 'top_secret_wrapper',
                      version = '0.1',
                      description = 'A Python wrapper for a top secret algorithm',
                      url = None,
                      author = 'James Bond',
                      author_email = 'James.Bond.007@mi6.org',
                      license = 'Spy Game License',
                      zip_safe = True,
                  )
                  

                  我确定我的 setup.py 缺少指定 top_secret.so 位置的设置,但我不确定如何执行此操作.

                  I'm sure my setup.py is lacking a setting where I specify the location of top_secret.so, though I'm not sure how to do that.

                  推荐答案

                  我最终做的是:

                  setup(
                      name='py_my_lib',
                      version=version,  # specified elsewhere
                      packages=[''],
                      package_dir={'': '.'},
                      package_data={'': ['py_my_lib.so']},
                  )
                  

                  这样我可以按名称导入库,并且没有其他级别的嵌套:

                  This way I get to import the lib by its name, and don't have another level of nestedness:

                  import py_my_lib
                  

                  而不是

                  from py_my_lib_wrapper import py_my_lib
                  

                  这篇关于分发带有已编译动态共享库的 Python 包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:R,Python:在 rpy2 上安装包 下一篇:如何刷新 sys.path?

                  相关文章

                  最新文章

                  1. <small id='ieoyO'></small><noframes id='ieoyO'>

                  2. <i id='ieoyO'><tr id='ieoyO'><dt id='ieoyO'><q id='ieoyO'><span id='ieoyO'><b id='ieoyO'><form id='ieoyO'><ins id='ieoyO'></ins><ul id='ieoyO'></ul><sub id='ieoyO'></sub></form><legend id='ieoyO'></legend><bdo id='ieoyO'><pre id='ieoyO'><center id='ieoyO'></center></pre></bdo></b><th id='ieoyO'></th></span></q></dt></tr></i><div id='ieoyO'><tfoot id='ieoyO'></tfoot><dl id='ieoyO'><fieldset id='ieoyO'></fieldset></dl></div>
                    <legend id='ieoyO'><style id='ieoyO'><dir id='ieoyO'><q id='ieoyO'></q></dir></style></legend>

                  3. <tfoot id='ieoyO'></tfoot>

                        <bdo id='ieoyO'></bdo><ul id='ieoyO'></ul>