I have a multiple Python scripts that act as geoprocessing tools. I have an ArcGIS Pro Toolbox (.atbx format) defining how to call them. The scripts are in a subdirectory of the location where the .atbx file is stored. I want to be able to move around the directory containing the .atbx file and .py files and have them go on working.
According to the ArcGIS Pro documentation Add a script tool:
If your toolbox is an ArcGIS toolbox (.atbx), this behavior is managed differently. If the script is in the same directory as the .atbx file or is in a child folder from where the .atbx is stored, a relative path is maintained. If the script and .atbx file are completely separate, an absolute path is maintained.
However, I have not seen this happen as described above. I have tried putting the .py files in various locations, including the same folder as the .atbx file. The path to the .py file is always absolute.
I see that the .atbx file format is a zipped archive where each tool gets a .tool directory containing a file called tool.script.execute.link
. I have opened this after trying various .py locations and it always shows an absolute path. I tried manually editing it to use a relative path, but the next time I modified anything about the tool in the .atbx file it switched back to an absolute path.
My organisation is using ArcGIS Pro 2.9 for compatibility reasons, if this makes a difference.
My question: ifSo, can I wantget these .atbx files to keep the scripts and the toolbox instore a directory I can move around, what arerelative path to my optionsscripts?
Other options if ArcGIS Pro simply won't do this with .atbx files:
- The scripts are long and under version control, so I don't consider storing them inside the .atbx satisfactory.
- I could use the legacy toolbox (.tbx) format, but this may be removed from some future version of ArcGIS Pro.
- In similar circumstances I have used the Python Toolbox (.pyt) format and it has been unwieldy but functional. It remains an option if there is no way to use the .atbx.