如何使用 setuptools 安装在自定义目录中? [英] How to use setuptools to install in a custom directory?
问题描述
我有一个 Python 包,我需要将它安装在 /usr/lib/python2.7/dist-packages
或任何其他与此相关的特定目录中.
I have a Python package that I need to install in the /usr/lib/python2.7/dist-packages
or any other specific directory for that matter.
每当我运行 setup.py
脚本时,它都会给出以下输出:
Whenever I run the setup.py
script it gives the following output:
root@abc44:~/som_dir/plugins/abc$python setup.py install
running install
running bdist_egg
running egg_info
writing abcNewPlugin.egg-info/PKG-INFO
writing top-level names to abcNewPlugin.egg-info/top_level.txt
writing dependency_links to abcNewPlugin.egg-info/dependency_links.txt
writing entry points to abcNewPlugin.egg-info/entry_points.txt
reading manifest file 'abcNewPlugin.egg-info/SOURCES.txt'
writing manifest file 'abcNewPlugin.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
warning: install_lib: 'build/lib.linux-x86_64-2.7' does not exist -- no Python modules to install
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
copying build/scripts-2.7/abc_plugin.py -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/abc_plugin.py to 775
copying abcNewPlugin.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying abcNewPlugin.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying abcNewPlugin.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying abcNewPlugin.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying abcNewPlugin.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/abcNewPlugin-0.0-py2.7.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing abcNewPlugin-0.0-py2.7.egg
Removing /usr/local/lib/python2.7/dist-packages/abcNewPlugin-0.0-py2.7.egg
Copying abcNewPlugin-0.0-py2.7.egg to /usr/local/lib/python2.7/dist-packages
abcNewPlugin 0.0 is already the active version in easy-install.pth
Installing abc_plugin.py script to /usr/local/bin
Installed /usr/local/lib/python2.7/dist-packages/abcNewPlugin-0.0-py2.7.egg
Processing dependencies for abcNewPlugin==0.0
Finished processing dependencies for abcNewPlugin==0.0
有没有办法在setuptools
中指定包的安装目录?我尝试了 --install-dir
选项,但它给出了一个错误:
Is there any way to specify the install directory of the package in setuptools
?
I tried --install-dir
option but it gives an error:
$sudo python setup.py install --install-dir=/usr/lib/python2.7/dist-packages
usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: setup.py --help [cmd1 cmd2 ...]
or: setup.py --help-commands
or: setup.py cmd --help
error: option --install-dir not recognized
我也不能使用 --prefix
选项.
I could not use --prefix
option also.
推荐答案
由于 python setup.py install
命令只是 easy_install
的快捷方式,请尝试直接运行,它有 --install-dir
选项:
Since the python setup.py install
command is just a shortcut to easy_install
, try running it directly, it has the --install-dir
option:
easy_install . --install-dir /usr/lib/python2.7/dist-packages
您可以使用 python setup.py install -h
获得其他可用选项,以防您需要更多选项,但这些选项相当神秘.
You can get other available options with python setup.py install -h
, in case you need some more, but these are rather cryptic.
这篇关于如何使用 setuptools 安装在自定义目录中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!