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='[email protected]',
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?
The setup.py file may be the most significant file that should be placed at the root of the Python project directory. It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on.
The short answer is that requirements. txt is for listing package requirements only. setup.py on the other hand is more like an installation script. If you don't plan on installing the python code, typically you would only need requirements.
from setuptools import setup [...] setup(name="my_package_name", python_requires='>3.5. 2', [...] Note that this requires setuptools>=24.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With