User Tools

Site Tools


python_setup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
python_setup [2019/12/20 17:54] jrsetipython_setup [2019/12/28 19:19] (current) – [Sample tox.ini file] jrseti
Line 7: Line 7:
 [[https://amir.rachum.com/blog/2017/07/28/python-entry-points/|How to create a command line version of your python script]] [[https://amir.rachum.com/blog/2017/07/28/python-entry-points/|How to create a command line version of your python script]]
  
-**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===== 
 + 
 +<code> 
 +""" 
 +setup.py -- setup script for use of packages. 
 +""" 
 +import sys 
 +import os 
 +from os import path 
 +from setuptools import setup 
 + 
 +# Restrict to a fairly recent python version 
 +if sys.version_info < (3,6): 
 +    sys.exit('Sorry, Python < 3.6 is not supported'
 + 
 +# Get the list of requirements 
 +#with open('/Users/jrichards/Projects/jrtools/requirements.txt') as f: 
 +with open('requirements.txt') as f: 
 +    requirements = f.read().splitlines() 
 + 
 +# Not using 'packages=find_namespace_packages(include=['jrtools.*'])', 
 +# but instead 'packages=['jrtools.flux_densities', 'jrtools.quick_chart']'
 +# The reason is that setuptools.find_namespace_packages is not available 
 +# on some pthon distributions. Listing them all manually is better anyway. 
 +setup( 
 +    name='jrtools', 
 +    packages=['jrtools.flux_densities', 'jrtools.quick_chart'], 
 +    version='1.0', 
 +    install_requires=requirements, 
 +    entry_points={ 
 +        'console_scripts':
 +            'flux_densities=jrtools.flux_densities:main', 
 +        ], 
 +    }, 
 +    url='https://github.com/jrseti/jrtools', 
 +    license='MIT', 
 +    author='Jon Richards', 
 +    author_email='jrseti@gmail.com', 
 +    description='Various Python tools and applications by Jon Richards, jrseti@gmail.com', 
 +    test_suite='nose.collector', 
 +    tests_require=['nose'
 +
 +</code> 
 + 
 +====Sample tox.ini file==== 
 + 
 +  # tox (https://tox.readthedocs.io/) is a tool for running tests 
 +  # 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" from this directory. 
 +   
 +  [tox] 
 +  envlist = py37 
 +   
 +  [testenv] 
 +  deps = pytest 
 +  commands = pytest
python_setup.1576864471.txt.gz · Last modified: 2019/12/20 17:54 by jrseti