9

I package my Python application with PIP, providing a setup.py. During installation, I want to ask the user for several values (user name, other configuration values), these values are then saved inside the application configfile stored inside the user directory.

Is there a special PIP/distutils-way to ask for these configuration values during setup? Or should I just use input to ask the user, like this:

#!/usr/bin/env python

from distutils.core import setup

cfg['name'] = input("Please your username:")
cfg.save()

setup(name='appname',
      version='1.0',
      description='App Description',
      author='Author',
      author_email='author@author.net',
      packages=['mypackage'],
     )

Or should I leave out asking for these values, and instead let the user configure the application on the first start?

I know that all of these ways are possible, but are there any conventions or best practices for that? Or do you know of a popular Python project doing similar stuff which is a good example?

Wolkenarchitekt
  • 20,170
  • 29
  • 111
  • 174
  • 2
    I don't think there's a 'standard' for things like this. I like to delay asking for settings until after instalation unless there are some paths that are required for the actual installation. – Bogdan Feb 10 '12 at 15:11
  • 3
    You should not use install phase for user interaction. If you want to ask something from the user do it when the application is run for the first time. – Mikko Ohtamaa Feb 10 '12 at 20:12

1 Answers1

2

setup.py provides you very primitive interface to install python packages. You can use a config file or create some GUI installer for your application.

Another way is to build OS depended packages (deb, rpm, msi for Windows) for your application.