[basemap] getting setuptools' "develop" command to work

Hi Jeff,

I've been investigating what is required to get setuptools' "develop"
command to work on the pyshapelib stuff in basemap.

The "develop" command essentially creates a link from site-packages to
the source directory (e.g. pyshapelib/lib) so that Python statements
like "import shapelib" will load the file directly from your source
tree. In other words, this takes the "python setup.py install" out of
the module/package development cycle.

Unfortunately, the implementation in setuptools seems unable to locate
the package root when there are multiple packages at multiple roots
specified using the "packages" and "package_dirs" arguments to a single
distutils.core.setup() call. I think there are two alternative
approaches if we want to get this to work, which I do.

My recommendation is to move pyshapelib/lib/shapelib to lib/shapelib and
pyshapelib/lib/dbflib to lib/dbflib and keep a single setup.py file.

The other option is to make two separate setup.py files, one for
"basemap" (which installs the matplotlib.toolkits.basemap python
packages) and one for "pyshapelib" (which installs the shapelib and
dbflib Python packages).

I've tested both of these options, and they both work. Let me know if
you want me to make the changes in svn.

Then there's the issue of the "try: import shapelib except:" in the
setup.py... I'm not in love with that style of testing, but I'm not sure
why it's in there. Do other packages install shapelib and you don't want
the possibility of overwriting them? Or is it just to save some build
time? If its the former, wouldn't it be better to rename basemap's
version so basemap doesn't get hit with an API change in an external
package? If it's the latter, I think that's a false economy. Finally, we
should at least qualify the except statement to only gobble and ImportError.

Cheers!
Andrew

Andrew Straw wrote:

Hi Jeff,

I've been investigating what is required to get setuptools' "develop"
command to work on the pyshapelib stuff in basemap.

The "develop" command essentially creates a link from site-packages to
the source directory (e.g. pyshapelib/lib) so that Python statements
like "import shapelib" will load the file directly from your source
tree. In other words, this takes the "python setup.py install" out of
the module/package development cycle.

Unfortunately, the implementation in setuptools seems unable to locate
the package root when there are multiple packages at multiple roots
specified using the "packages" and "package_dirs" arguments to a single
distutils.core.setup() call. I think there are two alternative
approaches if we want to get this to work, which I do.

My recommendation is to move pyshapelib/lib/shapelib to lib/shapelib and
pyshapelib/lib/dbflib to lib/dbflib and keep a single setup.py file.

Hi Andrew: That sounds reasonable, go ahead and do it if you like.

The other option is to make two separate setup.py files, one for
"basemap" (which installs the matplotlib.toolkits.basemap python
packages) and one for "pyshapelib" (which installs the shapelib and
dbflib Python packages).

I've tested both of these options, and they both work. Let me know if
you want me to make the changes in svn.

Then there's the issue of the "try: import shapelib except:" in the
setup.py... I'm not in love with that style of testing, but I'm not sure
why it's in there. Do other packages install shapelib and you don't want
the possibility of overwriting them? Or is it just to save some build
time? If its the former, wouldn't it be better to rename basemap's
version so basemap doesn't get hit with an API change in an external
package? If it's the latter, I think that's a false economy. Finally, we
should at least qualify the except statement to only gobble and ImportError.

Cheers!
Andrew
  
I'll get rid of that try/except. Turns out it's only Thuban that installs pyshapelib (AFAICT it doesn't exist as a standalone package).

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449
325 Broadway Web : http://www.cdc.noaa.gov/~jsw
Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124

Jeff Whitaker wrote:

Andrew Straw wrote:

My recommendation is to move pyshapelib/lib/shapelib to lib/shapelib and
pyshapelib/lib/dbflib to lib/dbflib and keep a single setup.py file.

Hi Andrew: That sounds reasonable, go ahead and do it if you like.

Thanks, done.

I'll get rid of that try/except. Turns out it's only Thuban that
installs pyshapelib (AFAICT it doesn't exist as a standalone package).

OK, I temporarily turned it off, but perhaps you want to do something
more sophisticated.

Cheers!
Andrew