python_setup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| python_setup [2019/12/21 18:53] – jrseti | python_setup [2019/12/28 19:19] (current) – [Sample tox.ini file] jrseti | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| [[https:// | [[https:// | ||
| - | **DONT USE python setup.py install**, use **pip install .**. Otherwise console scripts do not work. | + | **DONT USE python setup.py install**, use **"pip install ."**. Otherwise console scripts do not work. |
| + | |||
| + | ====You need a MANIFEST.in file!!==== | ||
| + | |||
| + | Manifest.in needs to include requirements.txt for it to get added into the distribution. Add this line: | ||
| + | |||
| + | include requirements.txt | ||
| + | |||
| + | |||
| ====setup.py example===== | ====setup.py example===== | ||
| Line 15: | Line 24: | ||
| setup.py -- setup script for use of packages. | setup.py -- setup script for use of packages. | ||
| """ | """ | ||
| + | import sys | ||
| + | import os | ||
| + | from os import path | ||
| from setuptools import setup | from setuptools import setup | ||
| - | install_requires = [] | + | # Restrict to a fairly recent python version |
| + | if sys.version_info < (3,6): | ||
| + | sys.exit(' | ||
| + | # Get the list of requirements | ||
| + | #with open('/ | ||
| + | with open(' | ||
| + | requirements = f.read().splitlines() | ||
| + | |||
| + | # Not using ' | ||
| + | # but instead ' | ||
| + | # The reason is that setuptools.find_namespace_packages is not available | ||
| + | # on some pthon distributions. Listing them all manually is better anyway. | ||
| setup( | setup( | ||
| name=' | name=' | ||
| + | packages=[' | ||
| version=' | version=' | ||
| - | | + | |
| entry_points={ | entry_points={ | ||
| ' | ' | ||
| - | ' | + | ' |
| ], | ], | ||
| }, | }, | ||
| - | install_requires=install_requires, | ||
| url=' | url=' | ||
| license=' | license=' | ||
| Line 38: | Line 60: | ||
| tests_require=[' | tests_require=[' | ||
| ) | ) | ||
| - | |||
| </ | </ | ||
| + | |||
| + | ====Sample tox.ini file==== | ||
| + | |||
| + | # tox (https:// | ||
| + | # in multiple virtualenvs. This configuration file will run the | ||
| + | # test suite on all supported python versions. To use it, "pip install tox" | ||
| + | # and then run " | ||
| + | | ||
| + | [tox] | ||
| + | envlist = py37 | ||
| + | | ||
| + | [testenv] | ||
| + | deps = pytest | ||
| + | commands = pytest | ||
python_setup.1576954412.txt.gz · Last modified: 2019/12/21 18:53 by jrseti