I have a setup.py
that looks like this:
from setuptools import setup
from subprocess import call
from setuptools.command.install import install
class MyInstall(install):
def run(self):
call(["pip install -r requirements.txt --no-clean"], shell=True)
install.run(self)
setup(
author='Attila Zseder',
version='0.1',
name='entity_extractor',
packages=['...'],
install_requires=['DAWG', 'mrjob', 'cchardet'],
package_dir={'': 'modules'},
scripts=['...'],
cmdclass={'install': MyInstall},
)
I need MyInstall
because I want to install some libraries from github and I didn't want to use dependency_links
option, because it's discouraged (for example here), so I can do this with requirements.txt.
When I install this package with pip
, everything is working fine, but for some reasons I have to solve this in a way that it also works with pure python setup.py install
. And it doesn't.
When overriding cmdclass
in setup()
with my own class, install_requires
seems to be ignored. As soon as I comment out that line, those packages are being installed.
I know that install_requires is not supported for example in distutils (if I remember well), but it is in setuptools. And then cmdclass
wouldn't have any effect on install_requires
.
I googled this problem for hours, found a lot of kind of related answers on stackoverflow, but not for this particular problem.
With putting every needed package to requirements.txt, everything's working fine, but I would like to understand why this is happening. Thanks!
The same problem just happened to me. It somehow seems like something triggers setuptools to do an 'old-style install' with
distutils
, which indeed does not supportinstall_requires
.You call install.run(self) which calls run(self) in setuptools/setuptools/command/install.py, line 51-74
https://bitbucket.org/pypa/setuptools/src/8e8c50925f18eafb7e66fe020aa91a85b9a4b122/setuptools/command/install.py?at=default
I'm not sure whether this behaviour is intended, but replacing
with
should solve your problem. At least it works for me, but I would also appreciate a more detailed answer. Thanks!
I know this is an old question, but I ran into a similar problem. The solution I have found fixes this problem for me is very subtle: The
install
class you're setting incmd_class
must physically be namedinstall
. See this answer on a related issue.You also should use
self.execute(_func_name, (), msg="msg")
in your post_install instead of calling the function directlySo implementing something like this should cause you to avoid the
do_egg_install
workaround implemented above by KEgg.According to https://stackoverflow.com/a/20196065 a more correct way to do this may be to override
bdist_egg
command.You could try:
It worked for me and
install_require
is no more ignored. Nevertheless, I still don't understand why most people seem to overridecmdclass install
and do not complain aboutinstall_require
being ignored.