Skip to content

Instantly share code, notes, and snippets.

@SamuelMarks SamuelMarks/
Last active Aug 29, 2015

What would you like to do?
An attempt to explicitly installs package dependencies **before** running `setuptools.setup`…
from pip.commands import install
from pip.exceptions import DistributionNotFound
def setup2(**kwargs):
kwargs['install_requires'] = kwargs.get('dependency_links', []) + kwargs.get('install_requires', [])
if path.exists('requirements.txt'):
kwargs['install_requires'] += open('requirements.txt', 'r').readlines()
install_cmd = install.InstallCommand()
print 'Installing:', kwargs['install_requires']
except DistributionNotFound as e:
name = e.message[e.message.rfind(' ') + 1:]
if len(filter(lambda n: n == name, kwargs['install_requires'])) > 1:
print e
kwargs['install_requires'] = filter(lambda i: i != name,
kwargs['install_requires']) # HAAAACK
# raise e # RAISE THIS!
kwargs.pop('install_requires') # Deps already handled [hopefully!]
return setup(**kwargs)

This comment has been minimized.

Copy link
Owner Author

SamuelMarks commented Feb 18, 2015

Hacked this together whilst troubleshooting:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.