Saturday 29 July 2017

File organization for sharing ArcGIS python code


What is the best organizational structure for sharing ArcGIS python code and geoprocessing tools? Or even, are sharing code and sharing tools separate questions?



Esri has a Methods for distributing tools structure, published for Arcgis 9.3 and 10.0:


distributing tool folder structure example


However in other places people are saying things like Also do avoid distributing your code the way its done in Arc Scripts or Code Galleries in favour of the native python Distutils. Esri doesn't seem to have a corresponding distributing tools article for 10.1 (ref), lending some weight to the counter-argument.


What says GIS.se?


Update: though perhaps too late, but the nub of this question is more about best practices for file and folder structure before the tools-used-for-sharing (arcgis online, google drive, dropbox, github, bitbucket, etc.) come into play.


Update2: and will no-one speak up for the apparently orphan distutils approach?



Answer



Esri's ArcGIS Pro doc Extending geoprocessing through Python modules shows how to structure a project that is Distutils friendly, including building Windows and Linux binary installers.


(Note: this is for sharing scripts and tools, it's not a good model for sharing scripts and maps and data as a single package.)


Source project layout:



Src tree


Becomes this on end user's system, under C:\Path\to\ArcGIS\Desktop\python


Destination folder tree


They don't mention pip but from studying the examples I don't see why it wouldn't work. Ex: for collaborative editing and/or a toolset that changes often, install using pip install --editable X:\path\to\src, pip install --editable http://github.com/project/path/to/master


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...