Thanks for posting the helpful tutorials. I've never been able to share Pro script tools outside of my machine before, so I'm hoping this allows me to.
I'm on Tutorial Two but got stuck. I got as far as step 3 under Build the package. "scripttools" is my build-distribute environment. When I run conda build recipe -c esri it throws an error.
(scripttools) PS C:\WINDOWS\system32> cd \\shareddirectory\postoffice
(scripttools) PS Microsoft.PowerShell.Core\FileSystem::\\shareddirectory\postoffice> conda build recipe -c esri
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\conda_interface.py", line 14, in try_exports
return getattr(import_module('conda.exports'), attr)
AttributeError: module 'conda.exports' has no attribute 'get_prefix'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-build-script.py", line 6, in <module>
from conda_build.cli.main_build import main
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\cli\main_build.py", line 18, in <module>
import conda_build.api as api
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\api.py", line 22, in <module>
from conda_build.config import (Config, get_or_merge_config, get_channel_urls,
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\config.py", line 15, in <module>
from .conda_interface import root_dir, root_writable
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\conda_interface.py", line 119, in <module>
context_get_prefix = try_exports("conda.base.context", "get_prefix")
File "C:\ProgramData\Anaconda3\lib\site-packages\conda_build\conda_interface.py", line 16, in try_exports
return getattr(import_module(module), attr)
AttributeError: module 'conda.base.context' has no attribute 'get_prefix'
(scripttools) PS Microsoft.PowerShell.Core\FileSystem::\\shareddirectory\postoffice>
I've attempted to update the conda-build package, but I'm getting conflicting results. Like, it lists the conda version as 24.7.1 in the environment, but it's warning me to update? After the update, I still get the error.
(scripttools) PS C:\WINDOWS\system32> conda update conda-build
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 23.9.0
latest version: 24.7.1
Please update conda by running
$ conda update -n base -c defaults conda
Or to minimize the number of packages updated during conda update use
conda install conda=24.7.1
# All requested packages already installed.
(scripttools) PS C:\WINDOWS\system32> conda list
# packages in environment at C:\ProgramData\Anaconda3\envs\scripttools:
#
# Name Version Build Channel
anaconda-anon-usage 0.4.4 py39hfc23b7f_100
anaconda-client 1.12.3 py39haa95532_0
archspec 0.2.3 pyhd3eb1b0_0
attrs 23.1.0 py39haa95532_0
beautifulsoup4 4.12.3 py39haa95532_0
boltons 23.0.0 py39haa95532_0
brotli-python 1.0.9 py39hd77b12b_8
bzip2 1.0.8 h2bbff1b_6
ca-certificates 2024.7.2 haa95532_0
certifi 2024.8.30 py39haa95532_0
cffi 1.16.0 py39h2bbff1b_1
chardet 4.0.0 py39haa95532_1003
charset-normalizer 3.3.2 pyhd3eb1b0_0
click 8.1.7 py39haa95532_0
colorama 0.4.6 py39haa95532_0
conda 24.7.1 py39haa95532_0
conda-build 24.7.1 py39haa95532_0
conda-index 0.5.0 py39haa95532_0
conda-libmamba-solver 24.7.0 pyhd3eb1b0_0
conda-package-handling 2.3.0 py39haa95532_0
conda-package-streaming 0.10.0 py39haa95532_0
If you have to publish this to a public repository then you might want to crosspost on a dedicated Conda forum, they should have more insight into the build system than the average ESRI user.
That said, if you aren't uploading to a public system then there's a much easier way to fix your issues with conda's build system: just don't use it! Here's the cliff notes on using Python's standard packaging model:
And there you go, now you can build and deploy your packages using pip instead of conda! The one catch is dependencies: pip will get dependencies from pypi.org instead of the dedicated conda channel, so you could clobber your environment by accident. To avoid this, always check if a dependency is available on conda and then specify that exact version in your pyproj file. You don't have to specify arcpy or any ESRI-specific dependencies if you aren't publishing to a public repository as they're a part of every Pro environment. As a bonus, you now have access to packages outside of the esri conda channel if you need extra functionality.
Thanks for the info. I mean, if I can avoid posting to a public place I would. All I plan to do is share within our office. I started out just saving the toolbox and its script on a shared network drive, but was constantly met with an OSError from the tool when ran from my colleague's machine.