How should setup.py and requirements.txt be used by application developers?
What should an application developer do in setup.py
and out requirements.txt
? If the app even has setup.py
?
The docs seems to only cover the script for writing a module. But in the application, how should the package and module dependency be coded? Using both setup.py and requirements.txt files?
I was handed draft 2.7.8 with some questionable coding and I'm not sure if this one is setup.py
sane. I'm surprised by the amount of coding:
#!/usr/bin/env python
from setuptools import setup, find_packages
import sys
if sys.argv[1] == 'test':
import multiprocessing, logging
from billiard import util
with open('requirements.txt') as f:
required = f.read().splitlines()
if sys.version_info < (2, 7, 0):
required.append('importlib')
setup(
version='0.1',
name='...',
description='...',
author='...',
author_email='...',
packages=find_packages(),
package_data={},
install_requires=required,
include_package_data=True,
tests_require=[
'billiard',
'nose==1.3'
],
test_suite='nose.collector'
)
I am new to Python but I see some potential problems:
- An outdated version number that must be manually updated.
- Import "test" is not project specific ("multiprocessing").
- We don't run tests by running setup.py; we execute the command
nosetests
. -
install_requires
depends on the contentrequirements.txt
. But afaik should be the other way around:requirements.txt
you need to create based on a sectioninstall_requires
. - Seems to check the python version the app is not coded to support.
source to share
An outdated version number that must be manually updated.
The version number in setup.py
is only relevant to your application / deployment.
Import "test" is not project specific ("multiprocessing").
In this case, you may need to remove it - it may be deprecated code.
We don't run tests by running setup.py; we run nosetests command.
I will need to look at it, but some test frameworks use setup.py
to set up the project in a separate environment (for example, tox
to test the project in different Python interpreters).
It depends on the content of the requirements. txt, but afaik should be the other way around: require.txt needs to be created based on the install_requires section in setup.py
Usage requirements.txt
and setup.py
depends on the Python community. For now, I setup.py
should be aware of the project setup requirements, but when your application is meant to be deployed, you can skip the file setup.py
and use the requirements.txt
.
No install_requires.
This can be a problem, depending on whether or not you are actually using setup.py
to install your dependencies (as stated above, it is perfectly possible to develop and deploy an application without a file setup.py
).
Seems to check the python version the app is not coded to support.
You may need to remove this.
source to share