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/21 18:53] 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===== ====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('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( setup(
     name='jrtools',     name='jrtools',
 +    packages=['jrtools.flux_densities', 'jrtools.quick_chart'],
     version='1.0',     version='1.0',
-    packages=['flux_densities', 'quick_chart'],+    install_requires=requirements,
     entry_points={     entry_points={
         'console_scripts': [         'console_scripts': [
-            'flux_densities=flux_densities:main',+            'flux_densities=jrtools.flux_densities:main',
         ],         ],
     },     },
-    install_requires=install_requires, 
     url='https://github.com/jrseti/jrtools',     url='https://github.com/jrseti/jrtools',
     license='MIT',     license='MIT',
Line 38: Line 60:
     tests_require=['nose']     tests_require=['nose']
 ) )
- 
 </code> </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.1576954412.txt.gz · Last modified: 2019/12/21 18:53 by jrseti