简体   繁体   中英

how to create setup.py script for modules

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='darshan@python.net',
      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

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).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM