Select to view content in your preferred language

Publishing a GP Tool is scanning all py files in the tool dir even other Python packages

508
2
11-15-2023 09:56 AM
DougBrowning
MVP Esteemed Contributor

I am using the trick to have any Python packages I need sitting next to the script and then using one of these

sys.path.append(__file__)  - way I use
sys.path.append(sys.path[0])  - way i see this in the help

DougBrowning_0-1700070311549.png

This gets around the issue where users need the packages installed.  This all works great in a toolbox on the file system.

But when I go to publish this as a GP Tool ArcPro is scanning ALL the .py files down in the package directories.  This can take hours!  Plus then it throws all kinds of crazy errors.

Is there anyway I can stop it from doing this?  I tried reference data and copy all data but it still does the big scan.  The scanning and path changing it does has always been highly annoying and problematic but this is an all new level.

One idea is to path to the packages somewhere on the network instead but I think our server has almost no file system access to the network.  Sub option is to have a common space where packages sit on the server but not sure if they will go for that.

Other idea is to keep those package dirs out, publish, then add then manually to the server dir.  But not sure IT will let me do that.

Option 3 is to add the packages to Python on the server but IT has a big no on that.

So has anyone got this to work?

thanks for any ideas.

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

I am also getting this weird message about some Index directory?  It is there but nothing in it.  No matter what I set the environments to it still goes to My Documents and makes this dir with nothing in it.  No idea why it needs it or how to fix.  New issue in Pro 3.1?  Tried deleting it but it just comes back.  There are 0 paths in my script to anything.

DougBrowning_1-1700093784711.png

thanks

 

 

0 Kudos
mody_buchbinder
Occasional Contributor III

Hi All

I did not tried it but it might work.

Create identical path on your publish machine and on server (C:\temp\packages) and place your files there.

Register this path on the server so it is "trusted"

Use this path in your code to access the packages and remove them from the script location.

In theory when you published since this is the registered directory the lines will not be changed.

You must keep the contact in your local directory and in the server local directory identical

Have fun

0 Kudos