Jay Bell
Jay Bell

Reputation: 77

Differences between including modules in python

I am using a lot of third party modules that I have gathered from other areas and am wondering if there is a big difference between including them like I would a module I wrote myself for the package (simple import statement) and using the setup.py to include it in my installation of python?

Edit:

Say I download xlwt for use with python to output to excel files. should I:

  1. run setup.py inside xlwt-0.7.5
  2. in code:
import xlwt

OR

  1. place xlwt folder within my projects folder
  2. then import the packages right from that folder with
import sys
sys.path.append('~xlwt/')
from xlwt import *

just trying to determine pros and cons of both.

Upvotes: 0

Views: 54

Answers (1)

Stephen Lin
Stephen Lin

Reputation: 4912

Pros of setup.py way:

  1. It's a common method which has been widely accepted. If you tell users to copy your program into some folder instead of executing setup.py, that will be a nightmare for them.
  2. Copy means you can put program wherever you like. This may lead to import error or even can'f find this program. In project, it goes against efficiency. Writing setup.py in a normal way is a better idea for program installation and environment sharing.

These are pros so far I've found.

Upvotes: 1

Related Questions