简体   繁体   English

从特定的setup.py安装pip

[英]pip install from specific setup.py

I created a python 3.3 app on RedHat's Openshift cloud service. 我在RedHat的Openshift云服务上创建了一个python 3.3应用程序。 By default it has setup.py for my project. 默认情况下,它具有我的项目的setup.py。 I'm learning Udemy course called "Build a SaaS app with Flask" ( source code ) Now I wanted to use python-click, as recommended by the course. 我正在学习名为“使用Flask构建SaaS应用程序”( 源代码 )的Udemy课程,现在我想按照课程的建议使用python-click。 It needs another setup.py for cli project; cli项目需要另一个setup.py; so to put that file in the project root folder, I renamed it to setup_cli.py . 为了将该文件放在项目根文件夹中,我将其重命名为setup_cli.py Now there are two files: setup.py and setup_cli.py . 现在有两个文件: setup.pysetup_cli.py Pip install seems to automatically look into setup.py. Pip安装似乎会自动进入setup.py。

# See Dockerfile in github source
pip install --editable <from setup_cli.py>

Can pip install --editable be used to point to setup_cli.py? 可以使用pip install --editable指向setup_cli.py吗?

It seems that you can't do anything about it :-) - It's hard coded in pip source code :-) 似乎您无能为力:-)-它是在pip源代码中硬编码的:-)

If you try to use pip install -e . 如果您尝试使用pip install -e . , it will call a method named parse_editable which will run this line : ,它将调用一个名为parse_editable的方法,该方法将运行以下行

if not os.path.exists(os.path.join(url_no_extras, 'setup.py')):
    raise InstallationError(
        "Directory %r is not installable. File 'setup.py' not found." %
        url_no_extras
    )

You may want to to use this command pip install -e file:///full/path/to/setup_cli.py , but this command also appends a hard coded setup.py to your path :-) 您可能要使用此命令pip install -e file:///full/path/to/setup_cli.py ,但是此命令还将硬编码的setup.py附加到您的路径中:-)

In setup_py there is this line: setup_py中以下行:

setup_py = os.path.join(self.setup_py_dir, 'setup.py')

so as @cel commented, it seems that python <whatever-setup.py> develop is your only option. 因此,正如@cel所说,似乎python <whatever-setup.py> develop是您唯一的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM