<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Publishing dependencies with custom tool to server in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345167#M27099</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Kevin!&amp;nbsp; Your suggestion worked.&amp;nbsp; It actually prompted me when publishing that it was copying the scripts folder and did move it and update the original script correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One other thing I found, in my original script, I had a few imports to modules from the 3rd party site-package I mentioned.&amp;nbsp; Those modules weren't used in the script, they just hadn't been removed from the import.&amp;nbsp; When I take out the 3rd party imports and publish, then ADSSurface.py is copied to the server.&amp;nbsp; When I add back the 3rd party imports and publish, ADSSurface.py is NOT copied.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In either case, if I follow your suggestion using sys.path.append, then ADSSurface.py is copied over and everything works.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 21 Sep 2012 16:25:47 GMT</pubDate>
    <dc:creator>GregFinch</dc:creator>
    <dc:date>2012-09-21T16:25:47Z</dc:date>
    <item>
      <title>Publishing dependencies with custom tool to server</title>
      <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345163#M27095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have a custom script tool (python) that uses some classes defined in separate .py files.&amp;nbsp; When I publish the tool to ArcGIS server only the script is deployed, but its dependencies are left behind.&amp;nbsp; Is there any way to package python dependencies with a tool so they are deployed with the tool?&amp;nbsp; I'm using version 10.1.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 13:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345163#M27095</guid>
      <dc:creator>GregFinch</dc:creator>
      <dc:date>2012-09-21T13:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing dependencies with custom tool to server</title>
      <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345164#M27096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes, see this topic: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/#/Authoring_geoprocessing_tasks_with_Python_scripts/00570000007r000000/&lt;/A&gt;&lt;BR /&gt;&lt;SPAN&gt;Specifically the "Importing other Python modules" section&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 14:59:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345164#M27096</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2012-09-21T14:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing dependencies with custom tool to server</title>
      <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345165#M27097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the quick response Kevin.&amp;nbsp; That article is very helpful.&amp;nbsp; However, it doesn't seem to be working as it's described.&amp;nbsp; The script I'm trying to publish looks like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
from ADSSurface import ADSSurface

fieldId = arcpy.GetParameterAsText(0)
year = arcpy.GetParameter(1)

surface = ADSSurface(fieldId, year)
raster = surface.getRaster()

arcpy.SetParameter(2, raster)&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ADSSurface.py is in the same folder as this script (GetSurface.py) and it contains all of our custom logic.&amp;nbsp; After I publish and look in the server directories, the published script (GetSurface.py) is identical to the original script and when I run on server, I get an error something like "ADSSurface not found."&amp;nbsp; There is no sign of ADSSurface.py embedded or standalone on the server.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there something that controls whether the published script embeds its dependencies or not?&amp;nbsp; Anything that could prevent the embed from happening?&amp;nbsp; ADSSurface uses a 3rd party site-package that is installed on the server.&amp;nbsp; Would that cause ArcGIS to not embed dependencies?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:15:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345165#M27097</guid>
      <dc:creator>GregFinch</dc:creator>
      <dc:date>2021-12-11T16:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing dependencies with custom tool to server</title>
      <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345166#M27098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well we dont scan any imported scripts, so the fact it imports a 3rd party module wouldnt have any impact on it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on your explanation and code, this should be working. Nothing you've said stands out as strange to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Well - the published script you're looking at inside the arcgisinput directory: it doesnt have at the very least a new header of #esri added variables#? I'd expect to see at least that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Would you be willing to re-work your script ever so slightly to see if this works?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Make a folder at the same level as your ADSSurface.py called "scripts"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Move your GetSurface.py script in there. Then add the sys.path.append into your script (shown below)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I know that this will copy over everything in the "myPythonModules" folder.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Because of sys.path.append, when it gets moved to the server, the paths will line up.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os, sys
myPythonModules = r'e:\&amp;lt;directory where ADSSurace.py lives&amp;gt;\Scripts'
sys.path.append(myPythonModules)

from ADSSurface import ADSSurface

fieldId = arcpy.GetParameterAsText(0)
year = arcpy.GetParameter(1)

surface = ADSSurface(fieldId, year)
raster = surface.getRaster()

arcpy.SetParameter(2, raster)
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 16:16:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345166#M27098</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2021-12-11T16:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing dependencies with custom tool to server</title>
      <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345167#M27099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Kevin!&amp;nbsp; Your suggestion worked.&amp;nbsp; It actually prompted me when publishing that it was copying the scripts folder and did move it and update the original script correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;One other thing I found, in my original script, I had a few imports to modules from the 3rd party site-package I mentioned.&amp;nbsp; Those modules weren't used in the script, they just hadn't been removed from the import.&amp;nbsp; When I take out the 3rd party imports and publish, then ADSSurface.py is copied to the server.&amp;nbsp; When I add back the 3rd party imports and publish, ADSSurface.py is NOT copied.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In either case, if I follow your suggestion using sys.path.append, then ADSSurface.py is copied over and everything works.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 16:25:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345167#M27099</guid>
      <dc:creator>GregFinch</dc:creator>
      <dc:date>2012-09-21T16:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Publishing dependencies with custom tool to server</title>
      <link>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345168#M27100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ok cool. I'm glad you're off and running.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And thanks for the info - I'll use it here to see if I can reproduce whats happening to better understand why its not behaving like it should.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2012 16:27:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/publishing-dependencies-with-custom-tool-to-server/m-p/345168#M27100</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2012-09-21T16:27:29Z</dc:date>
    </item>
  </channel>
</rss>

