I'm semi-new to setuptools in python. I recently added a dependency to my project and encountered an issue with the dependency. Here's the problem:
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
from mypackage import VERSION
setup(
name='mypackage',
...
version=VERSION,
packages=['mypackage'],
install_requires=['six'])
The problem is that mypackage
imports six
and thus setup.py fails on fresh installs (six isn't already installed) due to the from mypackage import VERSION
line. I have solved the problem by hacking in a dummy module import (seen below), but I really hope there is a better way that doesn't require me to maintain the version number in two locations or a separate file.
try:
import six
except ImportError:
# HACK so we can import the VERSION without needing six first
import sys
class HackObj(object):
def __call__(*args):
return HackObj()
def __getattr__(*args):
return HackObj()
sys.modules['six'] = HackObj()
sys.modules['six.moves'] = HackObj()