Installing local add-ons in Python

The setup.py of my X package uses setuptools to optionally install the additional Y package through the extras_require parameter.

Now package Y has disappeared from PyPi and, as far as I can tell, from the visible Internet. easy_install X[Y] does not work with error: Could not find suitable distribution for Y

However, I still have a local copy of Y tarball. Y is a package with pure Python.

What is the best way to modify setup.py so that this (local?) Is optional?


EDIT: The fix is โ€‹โ€‹intended to be temporary until I figure out the correct replacement. I do not want to officially start supporting Y :)

+6
source share
2 answers

I found a quick workaround through the dependency_links setuptools option.

  • Load the Y tarball into some URL http://URL_Y .
  • Add the line: dependency_links = ['http://URL_Y'], to my setup.py.

easy_install X[Y] works, and I donโ€™t need to register Y anywhere. I will remove it from URL_Y as soon as I get the correct fix.

+1
source

You can subclass setuptools.Command and then overload the default install command. Then you can force THAT to execute the subprocess setting the dependency. This is a hack, but this is what you asked for!

In setup.py:

 from setuptools import Command class MyInstallCommand(Command): # Overload the 'install' command to do default install but also install # your provided tarball. Blah blah blah read the docs on what to do here. setup( name='mypackage', # etc ... and then... # Overload the 'install' command cmdclass={ 'install': MyInstallCommand, } ) 

I greatly simplify this, but this is the main point.

+1
source

Source: https://habr.com/ru/post/891503/


All Articles