Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip install from specific setup.py

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?

like image 527
synergetic Avatar asked Aug 15 '16 11:08

synergetic


People also ask

How do I install Python packages from setup py?

Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

How does pip use setup py?

If you use setup.py , you have to visit the library's website, figure out where to download it, extract the file, run setup.py ... In contrast, pip will automatically search the Python Package Index (PyPi) to see if the package exists there, and will automatically download, extract, and install the package for you.

Does pip install invoke setup py?

For installing packages in “editable” mode (pip install --editable), pip will invoke setup.py develop , which will use setuptools' mechanisms to perform an editable/development installation.

How do I install a version of a package using pip?

By default, pip only finds stable versions. Install a project in editable mode (i.e. setuptools “develop mode”) from a local project path or a VCS url. Don’t actually install anything, just print what would be. Can be used in combination with --ignore-installed to ‘resolve’ the requirements. Install packages into <dir>.

How to install a package from the private PyPi repository?

you can define a path to the CA bundle and install a package from the private PyPi repository as follows: Or you can mark the <repository-domain> as a trusted host to ignore the SSL check: Connect to the private PyPi repository using the basic authentication: The private PyPi repository settings can also be defined in /etc/pip.conf, for example:

What does Pip check when looking at the items to install?

When looking at the items to be installed, pip checks what type of item each is, in the following order: Project or archive URL. Local directory (which must contain a setup.py, or pip will report an error). Local file (a sdist or wheel format archive, following the naming conventions for those formats). A requirement, as specified in PEP 440.

Can I use Setuptools with Pip build system interface?

The arguments and syntax of the various invocations of setup.py made by pip, are considered an implementation detail that is strongly coupled with setuptools. This build system interface is not meant to be used by any other build backend, which should be based on the pyproject.toml build system interface instead.


1 Answers

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.

like image 162
aliva Avatar answered Nov 03 '22 23:11

aliva