Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Marcus Ottosson
With pip there is --target which installs to a given location. Not sure if
there’s an equivalent for ez_install.

ps. Not sure why your sending so many duplicate emails, but they each seem
slightly different than the last. Perhaps you are attempting to edit a post
on Google Groups? Just a heads up that that won’t work with a mailing list
as each reply get’s send to everyone who’s subscribed immediately.
​

On 21 January 2016 at 17:27, Paxton  wrote:

> Marcus,
> Right. but what i'm saying is that I am specifying a non-system directory
> C:\Users\USER\MyScripts\MYPACKAGE\extensions with '--to-dir'
> but it still errors out saying i cant write  to C:\Program
> Files\Autodesk\MAYAVERSION\Python\Lib\site-packages
> even though i have specified a different directory...
> it seems to use the directory specified to download the zip archive, but
> then it procedes to install to site-pacckages anyway.
> Is there a better way of pointing ez_install to a specific directory?
>
> Fredrik, to answer your question
> "Is there a reason why you wouldn't want to go down such a route?"
>
> I am, perhaps foolheartedly trying to build packages that can download
> their own latest versions as well as dependencies.
>
>
> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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.endsw

[Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Paxton
Marcus,
Right. but what i'm saying is that I am specifying a non-system directory 
C:\Users\USER\MyScripts\MYPACKAGE\extensions with '--to-dir' 
but it still errors out saying i cant write  to C:\Program 
Files\Autodesk\MAYAVERSION\Python\Lib\site-packages
even though i have specified a different directory...
it seems to use the directory specified to download the zip archive, but 
then it procedes to install to site-pacckages anyway.
Is there a better way of pointing ez_install to a specific directory?

here is the error i get:

The following error occurred while trying to add or remove files in the
installation directory:

[Errno 13] Permission denied: 'C:\\Program 
Files\\Autodesk\\Maya2016\\Python\\Lib\\site-packages\\test-easy-install-10980.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

C:\Program Files\Autodesk\Maya2016\Python\Lib\site-packages\

Fredrik, to answer your question
"Is there a reason why you wouldn't want to go down such a route?"

I am, perhaps foolheartedly trying to build packages that can download 
their own latest versions as well as dependencies.

On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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 subscr

[Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Paxton
Marcus,
Right. but what i'm saying is that I am specifying a non-system directory 
C:\Users\USER\MyScripts\MYPACKAGE\extensions with '--to-dir' 
but it still errors out saying i cant write  to C:\Program 
Files\Autodesk\MAYAVERSION\Python\Lib\site-packages
even though i have specified a different directory...
it seems to use the directory specified to download the zip archive, but 
then it procedes to install to site-pacckages anyway.
Is there a better way of pointing ez_install to a specific directory?

Fredrik, to answer your question
"Is there a reason why you wouldn't want to go down such a route?"

I am, perhaps foolheartedly trying to build packages that can download 
their own latest versions as well as dependencies.


On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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/0681ca22-d1e5-42dc-83f0-a7aa4ea4e2c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Paxton
Right. but what i'm saying is that I am specifying a non-system directory 
C:\Users\USER\MyScripts\MYPACKAGE\extensions with '--to-dir' 
but it still errors out saying i cant write  to C:\Program 
Files\Autodesk\MAYAVERSION\Python\Lib\site-packages
even though i have specified a different directory...
it seems to use the directory specified to download the zip archive, but 
then it procedes to install to site-pacckages anyway.
Is there a better way of pointing ez_install to a specific directory?

Fredrik, to answer your question
"Is there a reason why you wouldn't want to go down such a route?"

I am, perhaps foolheartedly trying to build packages that can download 
their own latest versions as well as dependencies.




On Thursday, 21 January 2016 09:03:29 UTC-8, Marcus Ottosson wrote:
>
> You can't write to a system directory as a user without elevated 
> permissions. The same happens when you try and paste a file there via 
> Explorer. You'll need to run the console as administrator. Or change the 
> permission of the Maya directory, or install Maya in a user-writable 
> location.
>
> On 21 January 2016 at 16:57, Paxton > 
> wrote:
>
>>
>> Yea, I suppose on second thought, installing to site-packages is a bad 
>> idea.. 
>> that said, when I use the "--to-dir" arg for  ez_setup.py (and point it 
>> to a different path)
>>
>> command = [get_maya_py_path(), ez_setup.__file__,'--to-dir',  
>> extensions_directory]
>> p = subprocess.Popen(command, stdout=subprocess.PIPE, 
>> stderr=subprocess.STDOUT)
>>
>>
>> I still get permissions errors for mayas "site-packages" directory.
>> shouldn't that override the default site-packages path?
>> strange..
>>
>> -Paxton
>>
>> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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'
>>> 

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Marcus Ottosson
You can't write to a system directory as a user without elevated
permissions. The same happens when you try and paste a file there via
Explorer. You'll need to run the console as administrator. Or change the
permission of the Maya directory, or install Maya in a user-writable
location.

On 21 January 2016 at 16:57, Paxton  wrote:

>
> Yea, I suppose on second thought, installing to site-packages is a bad
> idea..
> that said, when I use the "--to-dir" arg for  ez_setup.py (and point it to
> a different path)
>
> command = [get_maya_py_path(), ez_setup.__file__,'--to-dir',  
> extensions_directory]
> p = subprocess.Popen(command, stdout=subprocess.PIPE, 
> stderr=subprocess.STDOUT)
>
>
> I still get permissions errors for mayas "site-packages" directory.
> shouldn't that override the default site-packages path?
> strange..
>
> -Paxton
>
> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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 th

[Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Paxton

Yea, I suppose on second thought, installing to site-packages is a bad 
idea.. 
that said, when I use the "--to-dir" arg for  ez_setup.py (and point it to 
a different path)

command = [get_maya_py_path(), ez_setup.__file__,'--to-dir',  
extensions_directory]
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)


I still get permissions errors for mayas "site-packages" directory.
shouldn't that override the default site-packages path?
strange..

-Paxton

On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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/dfdf2b10-5412-4269-b348-cd2e8b93afb5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Paxton
Yea, I suppose on second thought, installing to site-packages is a bad 
idea.. 
that said, when I use the "--to-dir" arg for  ez_setup.py (see code)

command = [get_maya_py_path(), ez_setup.__file__,'--to-dir',  
extensions_directory]
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)


I still get permissions errors for mayas "site-packages" directory.
shouldn't that override the default site-packages path?
strange..

-Paxton


On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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/a5e036a3-6532-45b7-ae42-2bc8daa02120%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Robert White
So I've not had any issues really using mayapy to handle compilation 
either. I was doing the custom build to potentially use it as a base for a 
CI/build system where I could avoid installing maya itself. Never did get a 
chance to finish the project, other issues came up and it keeps getting 
stuck in the middle of my queue.

As to how,  I found this walkthrough 
awhile
 
back, and adapted the process to work with VS2012. 

On Thursday, January 21, 2016 at 8:21:54 AM UTC-6, Marcus Ottosson wrote:
>
> I’ve also built my own local versions of Python that match maya’s python 
> build environment, at least on windows. So I’ve got copies of 2.7 build 
> against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when 
> compiling extension modules for python such as the P4API and PySide/PyQt 
> ect…
>
> I’m curious, how come you compiled your own Python here, and didn’t use 
> mayapy? I’ve compiled packages with it before and can’t recall having any 
> issues with it.
> ​
>
> On 21 January 2016 at 14:16, Robert White  > wrote:
>
>> So maya doesn't play to nicely with virtualenv, has to do with how it 
>> packages the standard lib into a zip-file.
>> Now you can transfer pure python libraries from a standard python 
>> install's virtualenv, and then just place that onto maya's pythonpath.
>>
>> So I use a version of pip that I've installed to my local maya 
>> environment, then I integrate them into our development and distribution 
>> setup myself. Artists then use our deployed packages on their local 
>> machines, and for that we piggy back on maya's module system.
>>
>> I've also built my own local versions of Python that match maya's python 
>> build environment, at least on windows. So I've got copies of 2.7 build 
>> against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when 
>> compiling extension modules for python such as the P4API and PySide/PyQt 
>> ect...
>>
>>
>> On Thursday, January 21, 2016 at 2:09:17 AM UTC-6, Fredrik Averpil wrote:
>>>
>>> I'm late to the party and have probably misunderstood what's going on 
>>> totally... but...
>>>
>>> I'd create a virtual environment outside of Maya, pip install into it 
>>> and then inside of Maya I would make the virtualenv's site-packages 
>>> available. This would leave the Maya installation intact.
>>>
>>> Is there a reason why you wouldn't want to go down such a route?
>>> Do you need to use modules which needs to be compiled during pip install?
>>>
>>> Cheers,
>>> Fredrik
>>>
>>>
>>> On Thu, Jan 21, 2016 at 9:01 AM Justin Israel  
>>> wrote:
>>>
 So,  what about Maya modules, which are meant to be distributed 
 packages of code? 
 Another option, what about distributing your tools with vendored 
 dependencies bundled in? What if a given studio doesn't have an internet 
 connection on the same machines as their production workstations? 

 On Thu, 21 Jan 2016 7:44 PM Paxton  wrote:

> I totally agree, but expecting small animation studios to learn the 
> intricacies of easy_install and pip in the context of Mayas python 
> interpreter is not realistic (in my experience). 
> Are there any other options for distributing tools (with dependencies) 
>  that don't involve programmers on the receiving end?
>
>
> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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, 

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Marcus Ottosson
I’ve also built my own local versions of Python that match maya’s python
build environment, at least on windows. So I’ve got copies of 2.7 build
against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when
compiling extension modules for python such as the P4API and PySide/PyQt
ect…

I’m curious, how come you compiled your own Python here, and didn’t use
mayapy? I’ve compiled packages with it before and can’t recall having any
issues with it.
​

On 21 January 2016 at 14:16, Robert White  wrote:

> So maya doesn't play to nicely with virtualenv, has to do with how it
> packages the standard lib into a zip-file.
> Now you can transfer pure python libraries from a standard python
> install's virtualenv, and then just place that onto maya's pythonpath.
>
> So I use a version of pip that I've installed to my local maya
> environment, then I integrate them into our development and distribution
> setup myself. Artists then use our deployed packages on their local
> machines, and for that we piggy back on maya's module system.
>
> I've also built my own local versions of Python that match maya's python
> build environment, at least on windows. So I've got copies of 2.7 build
> against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when
> compiling extension modules for python such as the P4API and PySide/PyQt
> ect...
>
>
> On Thursday, January 21, 2016 at 2:09:17 AM UTC-6, Fredrik Averpil wrote:
>>
>> I'm late to the party and have probably misunderstood what's going on
>> totally... but...
>>
>> I'd create a virtual environment outside of Maya, pip install into it and
>> then inside of Maya I would make the virtualenv's site-packages available.
>> This would leave the Maya installation intact.
>>
>> Is there a reason why you wouldn't want to go down such a route?
>> Do you need to use modules which needs to be compiled during pip install?
>>
>> Cheers,
>> Fredrik
>>
>>
>> On Thu, Jan 21, 2016 at 9:01 AM Justin Israel 
>> wrote:
>>
>>> So,  what about Maya modules, which are meant to be distributed packages
>>> of code?
>>> Another option, what about distributing your tools with vendored
>>> dependencies bundled in? What if a given studio doesn't have an internet
>>> connection on the same machines as their production workstations?
>>>
>>> On Thu, 21 Jan 2016 7:44 PM Paxton  wrote:
>>>
 I totally agree, but expecting small animation studios to learn the
 intricacies of easy_install and pip in the context of Mayas python
 interpreter is not realistic (in my experience).
 Are there any other options for distributing tools (with dependencies)
  that don't involve programmers on the receiving end?


 On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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_

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Robert White
So maya doesn't play to nicely with virtualenv, has to do with how it 
packages the standard lib into a zip-file.
Now you can transfer pure python libraries from a standard python install's 
virtualenv, and then just place that onto maya's pythonpath.

So I use a version of pip that I've installed to my local maya environment, 
then I integrate them into our development and distribution setup myself. 
Artists then use our deployed packages on their local machines, and for 
that we piggy back on maya's module system.

I've also built my own local versions of Python that match maya's python 
build environment, at least on windows. So I've got copies of 2.7 build 
against VS2010 (Maya2014), and VS2012 (Maya2015/6). This has helped me when 
compiling extension modules for python such as the P4API and PySide/PyQt 
ect...


On Thursday, January 21, 2016 at 2:09:17 AM UTC-6, Fredrik Averpil wrote:
>
> I'm late to the party and have probably misunderstood what's going on 
> totally... but...
>
> I'd create a virtual environment outside of Maya, pip install into it and 
> then inside of Maya I would make the virtualenv's site-packages available. 
> This would leave the Maya installation intact.
>
> Is there a reason why you wouldn't want to go down such a route?
> Do you need to use modules which needs to be compiled during pip install?
>
> Cheers,
> Fredrik
>
>
> On Thu, Jan 21, 2016 at 9:01 AM Justin Israel  > wrote:
>
>> So,  what about Maya modules, which are meant to be distributed packages 
>> of code? 
>> Another option, what about distributing your tools with vendored 
>> dependencies bundled in? What if a given studio doesn't have an internet 
>> connection on the same machines as their production workstations? 
>>
>> On Thu, 21 Jan 2016 7:44 PM Paxton > 
>> wrote:
>>
>>> I totally agree, but expecting small animation studios to learn the 
>>> intricacies of easy_install and pip in the context of Mayas python 
>>> interpreter is not realistic (in my experience). 
>>> Are there any other options for distributing tools (with dependencies) 
>>>  that don't involve programmers on the receiving end?
>>>
>>>
>>> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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 +

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Fredrik Averpil
I'm late to the party and have probably misunderstood what's going on
totally... but...

I'd create a virtual environment outside of Maya, pip install into it and
then inside of Maya I would make the virtualenv's site-packages available.
This would leave the Maya installation intact.

Is there a reason why you wouldn't want to go down such a route?
Do you need to use modules which needs to be compiled during pip install?

Cheers,
Fredrik


On Thu, Jan 21, 2016 at 9:01 AM Justin Israel 
wrote:

> So,  what about Maya modules, which are meant to be distributed packages
> of code?
> Another option, what about distributing your tools with vendored
> dependencies bundled in? What if a given studio doesn't have an internet
> connection on the same machines as their production workstations?
>
> On Thu, 21 Jan 2016 7:44 PM Paxton  wrote:
>
>> I totally agree, but expecting small animation studios to learn the
>> intricacies of easy_install and pip in the context of Mayas python
>> interpreter is not realistic (in my experience).
>> Are there any other options for distributing tools (with dependencies)
>>  that don't involve programmers on the receiving end?
>>
>>
>> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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

Re: [Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-21 Thread Justin Israel
So,  what about Maya modules, which are meant to be distributed packages of
code?
Another option, what about distributing your tools with vendored
dependencies bundled in? What if a given studio doesn't have an internet
connection on the same machines as their production workstations?

On Thu, 21 Jan 2016 7:44 PM Paxton  wrote:

> I totally agree, but expecting small animation studios to learn the
> intricacies of easy_install and pip in the context of Mayas python
> interpreter is not realistic (in my experience).
> Are there any other options for distributing tools (with dependencies)
>  that don't involve programmers on the receiving end?
>
>
> On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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/c8b74747-78c2-49df-bf4a-b684db90fa5d%40googlegroups.com
> 

[Maya-Python] Re: easy_install from Maya's python interpreter

2016-01-20 Thread Paxton
I totally agree, but expecting small animation studios to learn the 
intricacies of easy_install and pip in the context of Mayas python 
interpreter is not realistic (in my experience). 
Are there any other options for distributing tools (with dependencies) 
 that don't involve programmers on the receiving end?


On Wednesday, 20 January 2016 13:05:08 UTC-8, Paxton 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/c8b74747-78c2-49df-bf4a-b684db90fa5d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.