将库路径作为命令行参数传递给setup.py

问题描述 投票:10回答:3
modules = [Extension("MyLibrary",
                    src,
                    language = "c++",
                    extra_compile_args=["-fopenmp", "-std=c++11", "-DNOLOG4CXX"], # log4cxx is not currently used
                    extra_link_args=["-fopenmp", "-std=c++11"],
                    include_dirs=[os.path.join(os.path.expanduser("~"), (os.path.join(gtest, "include"))],
                    library_dirs=[log4cxx_library, os.path.join(os.path.expanduser("~"), gtest)],
                    libraries=["log4cxx", "gtest"])]

这是我的setup.py脚本的一部分。如何通过命令行参数传递诸如include_dirs或library_dirs之类的选项,以便用户可以设置路径?

python distutils python-3.3 setup.py
3个回答
2
投票

2
投票

您可以在setup.cfg文件中指定它

[build_ext]
include-dir="path/to/your/dir/"

0
投票

如果使用pip install,则可以指定library_dirs,例如:

pip install --install-option=build_ext --install-option="--library-dirs=/absolute/path/to/your/library/directory" YourPackage

或仅:

pip install --install-option=build_ext --install-option="-L/absolute/path/to/your/library/directory" YourPackage

--global-option似乎也起作用。参见https://stackoverflow.com/a/22942120/1843329

© www.soinside.com 2019 - 2024. All rights reserved.