I totally agree, but I am trying to ease the barriers to entry, and expecting small animation studios to learn the intricacies of easy_install and pip in the context of Mayas python interpreter is not really a thing that is going to happen any time soon. Are there any other options for distributing rigging tools that don't involve programmers on the receiving end?
On Wednesday, 20 January 2016 21:31:48 UTC-8, Justin Israel wrote: > > To be honest, I really don't feel anything should get installed into > Maya's internal site-packages. It should be another path that is added to > Maya's PYTHONPATH, or maybe a Maya module, I which case you could write to > your module location maybe? Maya at least puts modules onto its PYTHONPATH > if I remember correctly. > > On Thu, 21 Jan 2016 6:26 PM Paxton <paxton...@gmail.com <javascript:>> > wrote: > >> Hey Justin, yes!, a modified version of ez_setup.py did the trick. >> although, unfortunately It seems that you need to force an "insecure" >> downloader to get easy_install to work without using system calls. >> Here's what I changed inside ez_setup.py: >> >> downloaders = ( >> #download_file_powershell, >> #download_file_curl, >> #download_file_wget, >> download_file_insecure, >> ) >> >> Still... pretty cool that i can give someone a .py file and it will >> download dependencies automatically all from within Maya. >> That said.. I was on a mac while setting this up, and I have noticed that >> windows is a bit more strict when in comes to write access to the maya >> site-packages directory >> >> >> On Wednesday, 20 January 2016 14:05:19 UTC-8, Justin Israel wrote: >> >>> Could you not just use the code from within ez_setup.py directly within >>> maya, as opposed to running a subprocess? Or if you really want to run a >>> subprocess, can you just avoid all that path searching and building, and >>> just use "sys.executable" to run the ez_setup? >>> >>> On Thu, Jan 21, 2016 at 10:39 AM Marcus Ottosson <konstr...@gmail.com> >>> wrote: >>> >> Whatever you do from the system Python, simply do it from mayapy. There >>>> should be a binary within your Maya installation directory called that, at >>>> least that’s how it is on Windows and Linux; I’m not sure about OSX. >>>> >>>> For example. >>>> >>>> # From OS Python >>>> $ python my_script.py >>>> # From Mayapy >>>> $ /dir/to/mayapy my_script.py >>>> >>>> >>>> >>> >>>> On 20 January 2016 at 21:05, Paxton <paxton...@gmail.com> wrote: >>>> >>>>> >>>>> >>>>> Hey Folks, >>>>> >>>>> I am trying to download and install setup_tools, easy_install and >>>>> tinydb all from within mayas python interpreter.. >>>>> >>>>> I'm pretty close, but it looks like the system command to run >>>>> ez-setup.py is not downloading the easy_install packages to mayas >>>>> site_packages directory, which is strange because the same command works >>>>> perfectly in the shell.. >>>>> >>>>> So the system call reads like this: >>>>> /Applications/Autodesk/maya2016/Maya.app/Contents/bin/mayapy >>>>> /Users/paxtongerrish/downloads/ez_setup.py >>>>> >>>>> I am pointing mayas python interpreter at ez_setup.py >>>>> >>>>> When i punch this command into the shell, it downloads setup_tools to >>>>> mayas python site_packages directory... Great! :D >>>>> >>>>> However.. I need to have this all happen from inside mayas python >>>>> interpreter and it does not work when called from os.system or >>>>> subprocess.call >>>>> >>>>> Any help super appreciated.. >>>>> >>>>> thanks! >>>>> >>>>> >>>>> import os >>>>> import sys >>>>> import urllib2 >>>>> import subprocess >>>>> >>>>> setup_tools_address = >>>>> 'https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py' >>>>> downloads_directory = '%s/downloads' % os.getenv('HOME') >>>>> >>>>> if not os.path.exists(downloads_directory): >>>>> os.makedirs(downloads_directory) >>>>> >>>>> def setup(): >>>>> url = setup_tools_address >>>>> file_path = '%s/%s' % (downloads_directory, url.split('/')[-1]) >>>>> maya_py = maya_py_path() >>>>> for p in download_url(url, file_path): >>>>> print p >>>>> system_command = '%s %s' % (maya_py, file_path) >>>>> print '----- sys command--- (only works in shell)------\n' >>>>> print system_command >>>>> print '\n----------------------------------------------\n' >>>>> #This system command works from shell, but not from python.... Maybe >>>>> superuser thing?? >>>>> #os.system(system_command) >>>>> #sub process doesnt work either >>>>> >>>>> p = subprocess.Popen(system_command, shell=True, >>>>> stdout=subprocess.PIPE) >>>>> for i in p.stdout.readline(): >>>>> sys.stdout.flush() >>>>> print i >>>>> add_eggs() >>>>> from setuptools.command import easy_install >>>>> easy_install.main(['tinydb']) >>>>> add_eggs() >>>>> import tinydb >>>>> >>>>> def download_url(url, file_path, block_size=2056): >>>>> request = urllib2.urlopen(url) >>>>> file_size = int(request.info()['Content-Length']) >>>>> if not file_path: >>>>> file_path = '%s/%s' % (os.getenv('HOME'), url.split("/")[-1]) >>>>> downloaded_chunk = 0 >>>>> with open(file_path, "wb") as f: >>>>> while downloaded_chunk < file_size: >>>>> chunk = request.read(block_size) >>>>> downloaded_chunk += len(chunk) >>>>> f.write(chunk) >>>>> progress = float(downloaded_chunk) / file_size * 100 >>>>> yield progress >>>>> print("\nDownload Complete.") >>>>> >>>>> def maya_app_path(): >>>>> appName = 'Maya' >>>>> if sys.platform == 'win32': >>>>> appName = 'Maya.exe' >>>>> for p in sys.path: >>>>> app_path = '%s/%s' % (p.replace('\\','/') , appName) >>>>> if os.path.exists(app_path): >>>>> return app_path >>>>> >>>>> def maya_py_path(): >>>>> file_name = 'mayapy' >>>>> if sys.platform == 'win32': >>>>> file_name = 'mayapy.exe' >>>>> return '%s\\%s' % >>>>> (os.path.dirname(maya_app_path().replace('/','\\')), >>>>> file_name.replace('/','\\')) >>>>> return '%s/bin/%s' % >>>>> (os.path.dirname(os.path.dirname(maya_app_path())), file_name) >>>>> >>>>> def get_site_packages_directory(): >>>>> for p in sys.path: >>>>> if p.endswith('site-packages'): >>>>> return p >>>>> >>>>> def add_eggs(): >>>>> site_packages_directory = get_site_packages_directory() >>>>> for item in os.listdir(site_packages_directory): >>>>> if item.endswith('.egg'): >>>>> sys.path.append('%s/%s' % (site_packages_directory, item)) >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Python Programming for Autodesk Maya" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to python_inside_maya+unsubscr...@googlegroups.com. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/python_inside_maya/d3ff77b4-2cad-4f2f-b9a7-ad23be2fd604%40googlegroups.com >>>>> >>>>> <https://groups.google.com/d/msgid/python_inside_maya/d3ff77b4-2cad-4f2f-b9a7-ad23be2fd604%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> >>>> >>>> -- >>>> *Marcus Ottosson* >>>> konstr...@gmail.com >>>> >>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Python Programming for Autodesk Maya" group. >>>> To unsubscribe from this group and stop receiving emails from it, send >>>> an email to python_inside_maya+unsubscr...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBj_hBHj3b4zgiY2Shfxr8g_K1%2BKvBNdbkzKSkAsd_NBQ%40mail.gmail.com >>>> >>>> <https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOBj_hBHj3b4zgiY2Shfxr8g_K1%2BKvBNdbkzKSkAsd_NBQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to python_inside_maya+unsubscr...@googlegroups.com <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/f9529258-9f99-4e3c-988d-459950103c9b%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/f9529258-9f99-4e3c-988d-459950103c9b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/f4961f7f-ef70-4f3b-b2af-895452eb0441%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.