pip install from specific setup.py

2019-06-22 15:25发布

I created a python 3.3 app on RedHat's Openshift cloud service. By default it has setup.py for my project. 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. It needs another setup.py for cli project; so to put that file in the project root folder, I renamed it to setup_cli.py. Now there are two files: setup.py and setup_cli.py. Pip install seems to automatically look into 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?

1条回答
走好不送
2楼-- · 2019-06-22 15:51

It seems that you can't do anything about it :-) - It's hard coded in pip source code :-)

If you try to use pip install -e ., it will call a method named parse_editable which will run this line:

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 :-)

In setup_py there is this line:

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.

查看更多
登录 后发表回答