how to create setup.py script for modules

1.6k Views Asked by At

I have the below directory structure for modules :

QCsnapshot/
    setup.py
    src/
        checkConnectivity.py
        checkDefaultJobServer.py

        approx. 20 other modules ...

QCsnapshot directory is located in the eclipse workspace and the src directory in it has all the python modules.

I wrote the below setup.py script to package and distribute these modules:

from distutils.core import setup

setup(name='snapshot',
      version='1.0',
      description='Snapshot Utility',
      author='Darshan',
      author_email='[email protected]',
      url='http://www.python.org/snapshot-url',
      package_dir={'src':'src'}
      #package_data={'':'src'}
     )

when I run this setup.py file from the windows command prompt I get this output:

C:\Users\darshanb\temp\de.ecw.python.QCsnapshot>setup.py install
running install
running build
running install_egg_info
Writing C:\Python27\Lib\site-packages\snapshot-1.0-py2.7.egg-info

I went through a lot of articles, web pages to learn more on this, but I'm not sure how to proceed further, __init__.py file, pypric file, etc. is very confusing

Please tell me how can I create a package of all these modules, I also have some libraries I have used in the modules like urllib2, lxml, pydobc, etc. I am not sure how to auto install these libraries

1

There are 1 best solutions below

0
On

The setup call needs a py_modules or packages argument, it won’t try to find the Python files automatically. You’d need to list all modules, or use glob.glob, or reorganize your code a little to have one package instead of many modules (my recommendation).