Changes between Initial Version and Version 1 of rfc17_python_namespaces


Ignore:
Timestamp:
Oct 1, 2007, 10:00:26 AM (17 years ago)
Author:
hobu
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • rfc17_python_namespaces

    v1 v1  
     1= RFC 17: Python Namespaces =
     2
     3Author: Howard Butler[[BR]]
     4Contact: hobu.inc@gmail.com[[BR]]
     5Status: Adopted
     6
     7== Summary ==
     8
     9GDAL bindings for Python have historically dodged the normal Python practices of using packages and namespaces to provide organization. 
     10This RFC implements a new namespace for Python, called '''osgeo''', where the GDAL Python bindings henceforth will reside.  Backward
     11compatibility is provided, so that current code will continue to run unchanged, but new developments should utilize the namespace
     12for code organization and global namespace pollution reasons.  As of 10/1/2007, the changes described here in RFC 17 only pertain to the "next-gen" Python bindings.  It is expected that these bindings will be the default bindings for GDAL 1.5.
     13
     14== Objective ==
     15
     16To provide the GDAL Python bindings in a Python package that is properly namespaced, eliminating pollution of Python's global namespace. 
     17
     18== Past Usage ==
     19
     20GDAL's Python bindings previously used globally-aware Python modules:
     21{{{
     22import gdal
     23import osr
     24import ogr
     25import gdalconst
     26import gdalnumeric
     27}}}
     28
     29== New Usage ==
     30
     31RFC 17 now provides these modules under the '''osgeo''' namespace:
     32{{{
     33from osgeo import gdal
     34from osgeo import osr
     35from osgeo import ogr
     36from osgeo import gdalconst
     37from osgeo import gdal_array
     38}}}
     39
     40Additionally, the old module-style imports continue to work with a deprecation warning:
     41{{{
     42>>> import gdal
     43/Users/hobu/svn/gdal/swig/python/gdal.py:3: DeprecationWarning: gdal.py was placed in a namespace, it is now available as osgeo.gdal
     44  warn('gdal.py was placed in a namespace, it is now available as osgeo.gdal', DeprecationWarning)
     45}}}
     46
     47It is planned that we will remove the GDAL-specific global modules at some point in the future.
     48
     49== Other Sprint Updates ==
     50
     51The work for this RFC was done at the FOSS4G2007 GDAL code sprint by Howard Butler and Chris Barker.  In addition to the Python namespacing, some minor issues were dealt with respect to building the GDAL bindings.
     52
     531) The next-gen Python bindings now use setuptools by default if it is available.
     542) The ./swig/python directory was slightly reorganized to separate extension building from pure python modules.
     553) gdal2tiles, a Google Summer of Code project by Petr Klokan, was integrated into the next-gen bindings