Tuesday, June 12, 2012

Python packaging and installation

in setup.py file
for instance ::
    from distutils.core import setup
    setup(
      name = 'MyTools',
      version = '0.1.0',
      author = 'zhijia yuan',
      packages = ['oct'],
      author_email = 'zyuan@topcon.com',
      install_requires = ['NumPy >= 1.0.4'],
      )

after installation, the available import is related to the packages name::
    import oct #works
    import MyTools.oct #doesnot work
which means that the name MyTools just a top tag for your package, and oct is the real package name that you can import
if you have multiple packages, it would be more reasonable to keep the name and package name organized. 

No comments:

Post a Comment