Thursday, January 18, 2018

The setup.py file of a Python project can be as simple as this:

from setuptools import setup
setup(name='foo', version='1.0.0')

But for atelier there are two additional required conventions:

  • The setup.py must actually call the setup() function only if invoked from a command line, i.e. only if __name__ == ‘__main__’.

  • The setup.py must definea name SETUP_INFO which is a dict containing all those keyword arguments passed to the setup() function.

So the above minimal setup.py file becomes:

from setuptools import setup
SETUP_INFO = dict(name='foo', version='1.0.0')
if __name__ == '__main__':
    setup(**SETUP_INFO)

When I recently added the timtools project to my atelier, I forgot to verify this condition. It took me at least one hour to find the reason. I now added a test to atelier.projects.get_setup_info() in order to make it more fool-proof:

Oops, {} called sys.exit().
Atelier requires the setup() call to be in a "if __name__ == '__main__':\" condition.

I updated the documentation about atelier Usage.