Select to view content in your preferred language

Sharing an ArcMap Python Toolbox

476
0
03-14-2023 02:19 AM
Labels (1)
Manu
by
Regular Contributor

I need to share/locally distribute an ArcMap Python Toolbox. I tried to proceed similarly to the description for ArcGIS Pro but I ran into some issues. Mainly, it did not include the .pyt file.

My Toolbox directory looks like this:

 

 

Toolbox
├  setup.py
├  Readme.txt
├ Example_data
│       ├ Subdirectory_with_files_and_folders_0
│       └ Subdirectory_with_files_and_folders_1
├── External
│       ├ Script_to_be_run_externally_in_Python_3.py
│       ├ Script_to_be_run_externally_in_Matlab.m
│       └ Even_more_such_scripts.py
├── Spectral (some entire Python package I copied here from Github)
│       └ All_files_and_subdirectories_of_this_additional_package
└── Toolbox
        ├ Functions.py
        ├ Classes.py
        └ Toolbox.pyt

 

 

 

The following is my setup.py file:

 

 

import os 
from setuptools import setup 
 
def read(fname): 
    return open(os.path.join(os.path.dirname(__file__), fname)).read() 
 
setup(name='Toolbox', 
      version='1.0', 
      author='Me', 
      description=("Some description"), 
      long_description=read('Readme.txt'), 
      python_requires='~=2.7.16', 
      packages=['Toolbox', 'Spectral'], 
      package_data={'Toolbox':['External/*',  
                  'Example_data/*']}
      )

 

 

 

I tried to create a dist archive calling the Python executable of an ArcPro installation I also have on the machine (and no, I cannot simply switch to ArcPro with the entire project; using ArcMap was not my choice):

 

 

> O:
> cd O:\path\to\my\toolbox
> "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" setup.py sdist

 

 

This is the first Python Package/Toolbox I am trying to distribute, so there might be major errors or violations of best practices. Perhaps there is a lot to change here? Any help appreciated.

0 Kudos
0 Replies