uralbash / sqlalchemy_mptt

SQLAlchemy nested sets mixin (MPTT)
http://sqlalchemy-mptt.readthedocs.io
MIT License
196 stars 32 forks source link

Package is not installable if sqlalchemy is not (yet) installed #22

Closed GaretJax closed 10 years ago

GaretJax commented 10 years ago

When installing using a pip requirements file, listing both sqlalchemy and sqlalchemy_mptt, the installation fails because when pip runs python setup.py egg_info for the sqlalchemy_mptt package, an exception is raised about sqlalchemy not being found.

This is due to the setup.py file importing __version__ from the package, and thus indirectly trying to import sqlalchemy as well.

In such cases I use the following approach in my setup.py files:

data = Setup.read(os.path.join('sqlalchemy_mptt', '__init__.py'))
__version__ = (re.search(u"__version__\s*=\s*u?'([^']+)'", data).group(1).strip())

(I know some people don't like this approach, but while not that elegant, it is simple enough to work in all cases I had to use it).