Ben Finney <ben+pyt...@benfinney.id.au> writes: > How can I ‘import docutils’ in ‘setup.py’ without creating a circular > dependency: > > * The correct way to get Docutils installed is to run ‘setup.py’ and > have it install the dependencies. […] > What I need is a way to express “ensure Docutils is installed before > continuing with other Setuptools actions” in ‘setup.py’. I don't know of > a neat way to tell Setuptools that.
Thanks to George V. Reilly for a much neater solution: # setup.py from setuptools import (dist, setup, find_packages) # Declare a requirement for Docutils in a throw-away distribution. # Surprisingly, Setuptools will magically ensure this is installed, # or raise an exception if it can't. dist.Distribution(dict(setup_requires="docutils")) # By the time we get here, the following import will work. import docutils # … other code that needs Docutils … setup(…) Should this be in the Setuptools documentation? My time over the past several weeks would have been *much* less frustrating if this was the documented One Obvious Way™ to early-load a dependency in setup. -- \ “Free thought is a necessary, but not a sufficient, condition | `\ for democracy.” —Carl Sagan | _o__) | Ben Finney _______________________________________________ Distutils-SIG maillist - Distutils-SIG@python.org https://mail.python.org/mailman/listinfo/distutils-sig