Ocassionally you may wish to pack your tools for other people outside your general pipeline. I wrote this dirty batch script that registers the folder from which it is run to the pythonpath. This way a user can extract and place a folder where desired, run this magical “setup.bat” and perhaps run some inline code (like import Pfx_MyPackage.Setup;) from maya that intializes the remainder of the tool (by generating shelves and other necessities).
We can cheat some more if we wish to copy files from the Setup (icons!) because the setup __file__ variable points to the current script file. Knowing that the user extracted an archive as-is perhaps ‘%s/icons/’%os.dirname(__file__) may give us a path to all shelf icons (to be moved to maya’s own icon folder).
Enjoy just the batch file for now…
@setlocal enableextensions enabledelayedexpansion @echo off IF "%PYTHONPATH%" == "" GOTO CREATE :APPEND set NEWPATH=%CD%;%PYTHONPATH% set NEWPATH=!NEWPATH:*%CD%;=! setx PYTHONPATH "%NEWPATH%" GOTO FINALIZE :CREATE setx PYTHONPATH "%CD%" :FINALIZE echo %PYTHONPATH% pause