覆盖 Python bdist Windows 安装程序的默认安装目录
是否可以在安装程序生成期间(或实际安装期间)指定 Python 模块的自定义路径?举例来说,假设我有 5 个模块,我使用以下方法为其生成安装程序:
c:\>python setup.py bdist
一切都正确打包,但是当我安装时,我被迫安装到站点包中。我需要能够指定我的(或安装程序选择的)自定义目录。至少,我需要能够覆盖默认路径,以便我的自定义路径显示为默认路径。
使用构建的发行版可以实现这一点吗?
Is it possible to specify during the installer generation (or during the actual installation) a custom path for Python modules? By way of example, let's say I have 5 modules for which I generate an installer using:
c:\>python setup.py bdist
Everything gets packaged up correctly, but when I install, I am forced to install into site-packages. I need to be able to specify a custom directory of my (or the installer's choosing). At a minimum, I need to be able to override the default so my custom path appears as the default.
Is this possible using a built distribution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我确实相信 MaxSin 的回答有些正确。但是要使用他对命令的回答:“python setup.py bdist_wininst”,您必须这样做:
将其视为语法 这里是:
编辑:
看起来这不起作用:(不确定是否有其他可能的解决方案。
I do beleive that MaxSin's answer was somewhat correct. But to use his answer for the command: "python setup.py bdist_wininst" you would have to do it like this:
Seeing as the syntax here is:
edit:
It looks like this doesnt work :( not sure of a possible other solution.
您应该编写 setup.cfg,在其中可以指定安装选项(请参阅 python setup.py install --help 输出),然后运行 python setup.py bdist。创建二进制发行版时,python 将使用此选项在“build”子目录下进行哑安装,并从此哑安装创建安装程序。例如,如果您想创建 bdist,将库安装到 /some/lib/path 并将脚本安装到 /some/bin/path 创建以下 setup.cfg:
然后运行 python setup.py bdist
You should write setup.cfg where you can specify installation options(see python setup.py install --help output) and then run python setup.py bdist. When creating binary distro python will do the dumb installation under the "build" subdir with this options and create the installer from this dumb installation. For example, if you want to create bdist which installs libraries to /some/lib/path and scripts to /some/bin/path create the following setup.cfg:
And then run python setup.py bdist
从运行 python setup.py --help install 中:
From running
python setup.py --help install
: