使用setuptools将文件安装到任意位置 [英] Using setuptools to install files to arbitrary locations

查看:103
本文介绍了使用setuptools将文件安装到任意位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用setuptools将文件安装到任意位置?我以前将数据文件与setuptools一起使用,但通常已安装在包目录中。我需要安装一个插件文件,该文件位于另一个应用程序的安装目录中。

Is there a way to install files to arbitrary locations with setuptools? I've used Data Files with setuptools before, but those are typically installed inside the package directory. I need to install a plugin file that will be located in the install directory of another application.

推荐答案

似乎setuptools故意

It seems that setuptools has purposely made it difficult to install files outside of the package directory.

我改为将插件文件作为软件包数据包含在内,并使用了 setuptools的入口点功能公开了我要分发的插件文件的安装/卸载功能。

I instead included the plugin files as package data and used the Entry Points feature of setuptools to expose the install/uninstall functions for the plugin files I wanted to distribute.

setup(
    ...
    entry_points={
        'console_scripts': [
            'mypackage_install_plugins = mypackage:install_plugins',
            'mypackage_uninstall_plugins = mypackage:uninstall_plugins',
        ],                
    }
)

我刚刚在安装说明中添加了一个附加步骤,以便在安装inst之后运行以下命令Alling the python package:

I just added an additional step to the installation instructions to run the following command after installing the python package:

$> mypackage_install_plugins

这篇关于使用setuptools将文件安装到任意位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆