我有Python/C++ 项目,其中使用Python 封装的一些C++ 函数,并在Python 中作为库提供。目录结构如下:
.
├── examples
│ └── test_file1.py
├── include
│ ├── proj1_headers
│ └── proj2_headers
├── LICENSE.md
├── mylib.cpython-39-x86_64-linux-gnu.so
├── mylib.egg-info
│ ├── dependency_links.txt
│ ├── PKG-INFO
│ ├── requires.txt
│ ├── SOURCES.txt
│ └── top_level.txt
├── README.md
├── setup.cfg
├── setup.py
└── src
└── file1.cc
因此,C++ 头文件位于
include
目录下。要在本地构建项目(即不将其安装到我的 Python 环境),我使用以下命令:
python setup.py develop
此方法给我带来的便利如下 - 我可以简单地将
mylib*
文件/目录移动到我的示例目录,在我的示例 Python 文件中,我可以简单地执行
import mylib
。我的环境中没有安装任何东西,仍然保持干净。尽管此命令在项目根目录下构建所需的库为 mylib*
,但它会引发以下警告:
/home/user/miniconda3/envs/py39env/lib/python3.9/site-packages/setuptools/command/develop.py:40: EasyInstallDeprecationWarning: easy_install command is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` and ``easy_install``.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://github.com/pypa/setuptools/issues/917 for details.
********************************************************************************
!!
easy_install.initialize_options(self)
/home/user/miniconda3/envs/py39env/lib/python3.9/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated.
!!
********************************************************************************
Please avoid running ``setup.py`` directly.
Instead, use pypa/build, pypa/installer, pypa/build or
other standards-based tools.
See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
********************************************************************************
!!
self.initialize_options()
我对上述问题的问题分为两部分:
如何使用新方法“本地”进行构建,而无需实际安装到我的 Python 环境中? (设置方法中的开发选项)
*.whl
文件?