Difference between revisions of "PyOGP Client Library Development Sandbox"

From Second Life Wiki
Jump to navigation Jump to search
(Added links to archives)
 
(23 intermediate revisions by 3 users not shown)
Line 2: Line 2:
We will first run down the general explanation and add platform specific notes later.
We will first run down the general explanation and add platform specific notes later.


== Note ==


We're migrating to [[Mercurial_repositories|Mercurial]]... Please check back soon for updated docs.
== Repositories ==


PyOGP package install instructions need some work... stay tuned. Feel free to follow the buildout directions to use the Subversion repositories for now.
Stable trunk repositories:
* http://bitbucket.org/lindenlab/pyogp.apps/
* http://bitbucket.org/lindenlab/pyogp.lib.base/
* http://bitbucket.org/lindenlab/pyogp.lib.client/
* http://bitbucket.org/lindenlab/pyogp.buildout/


=== Repositories ===
Maintenance repositories:
* http://bitbucket.org/lindenlab/pyogp.apps-maint/
* http://bitbucket.org/lindenlab/pyogp.lib.base-maint/
* http://bitbucket.org/lindenlab/pyogp.lib.client-maint/
* http://bitbucket.org/lindenlab/pyogp.buildout-maint/


Need some work before they are ready as installed packages. In the meantime, just add the path to "pyogp.{package} to your PYTHONPATH to use the libs.
Defunct until someone picks them up and fixes them:
* http://bitbucket.org/enus_linden/pyogp.apps/
* http://bitbucket.org/lindenlab/pyogp.interop/
* http://bitbucket.org/enus_linden/pyogp.lib.base/
* http://bitbucket.org/lindenlab/pyogp.lib.agentdomain/
* http://bitbucket.org/enus_linden/pyogp.lib.client/


Needs updates to work:
Archives of the above repositories:
* http://bitbucket.org/enus_linden/pyogp.buildout/
* https://bitbucket.org/tapplek/ [[User:Tapple Gao|Tapple Gao]] ([[User talk:Tapple Gao|talk]])
 
* https://github.com/orgs/SL-PyOGP/repositories [[User:Kadah Coba|Kadah Coba]] ([[User talk:Kadah Coba|talk]])
Defunct until someone picks them up and fixes them:
* http://bitbucket.org/enus_linden/pyogp.interop/
* http://bitbucket.org/enus_linden/pyogp.lib.agentdomain/


== Browse the Code ==
== Browse the Code ==


If all you want to do is glance at the source code, use the bitbucket source browser:
If all you want to do is glance at the source code, use the bitbucket source browser:
* http://bitbucket.org/enus_linden/pyogp.apps/src/
* http://bitbucket.org/lindenlab/pyogp.apps/src/
* http://bitbucket.org/enus_linden/pyogp.buildout/src/
* http://bitbucket.org/lindenlab/pyogp.buildout/src/
* http://bitbucket.org/enus_linden/pyogp.interop/src/
* http://bitbucket.org/lindenlab/pyogp.interop/src/
* http://bitbucket.org/enus_linden/pyogp.lib.agentdomain/src/
* http://bitbucket.org/lindenlab/pyogp.lib.agentdomain/src/
* http://bitbucket.org/enus_linden/pyogp.lib.base/src/
* http://bitbucket.org/lindenlab/pyogp.lib.base/src/
* http://bitbucket.org/enus_linden/pyogp.lib.client/src/
* http://bitbucket.org/lindenlab/pyogp.lib.client/src/
 
== Environment Preparation ==


== Prerequisites ==
=== Prerequisites ===


You must have the following installed:
You must have the following installed:
* Mercurial - 1.3 or greater
* Mercurial - 1.3 or greater
* Python 2.4.4, 2.5.x (fails on 2.6 currently and untested on 3.0)
* Python 2.4.4, 2.5.x, 2.6.x (untested on 3.0)
* pyopenssl http://sourceforge.net/projects/pyopenssl/files/pyopenssl-win/0.8a1/pyOpenSSL-0.8a1.winxp32-py2.5.msi/download (Windows 32-bit)


'''Note:''' Snow Leopard upgrades require a reinstall of XCode, in this case to accommodate gcc (and greenlet).
'''Setuptools''' and '''easy_install''' are Python standard means for installing modules. For more info, start here: http://pypi.python.org/pypi/setuptools.


'''Note:''' Buildout does not yet support subversion 1.6, only 1.4.4-1.5.x.
'''Virtualenv''' is a method which allows you to create isolated Python environments, separate from your base install if you so prefer. For more, see here: http://pypi.python.org/pypi/virtualenv.


== Environment Preparation ==
Your distribution may have Python's '''setuptools''' and '''virtualenv''' packages in its package repository.  If so, it is probably best to use your normal package installation procedures (see below for information on specific Linux distributions).  If the packages are not available then follow these generic instructions.


'''Setuptools''' and '''easy_install''' are Python standard means for installing modules. For more info, start here: http://pypi.python.org/pypi/setuptools.
=== Mac Specifics ===


'''Virtualenv''' is a method which allows you to create isolated Python environments, separate from your base install if you so prefer. For more, see here: http://pypi.python.org/pypi/virtualenv.
'''Note:''' Snow Leopard upgrades require a updated install of XCode, in this case to accommodate gcc (and greenlet).


Your distribution may have Python's '''setuptools''' and '''virtualenv''' packages in its package repository.  If so, it is probably best to use your normal package installation procedures (see below for information on specific Linux distributions).  If the packages are not available then follow these generic instructions.
=== Generic *nix Specifics ===


=== Generic *nix distribution ===
In order to install Python Packages and creating a development sandbox you have to do the following:
In order to install Python Packages and creating a development sandbox you have to do the following:


==== easy_install ====
=== easy_install ===
 
"Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages." I stole that from here: http://peak.telecommunity.com/DevCenter/EasyInstall.


Download ez_setup.py and run it with your Python interpreter. You can find it here: http://peak.telecommunity.com/dist/ez_setup.py
Download ez_setup.py and run it with your Python interpreter. You can find it here: http://peak.telecommunity.com/dist/ez_setup.py
Line 61: Line 66:


  wget http://peak.telecommunity.com/dist/ez_setup.py
  wget http://peak.telecommunity.com/dist/ez_setup.py
  -or-
curl -O http://peak.telecommunity.com/dist/ez_setup.py
  sudo python ez_setup.py
  sudo python ez_setup.py


==== virtualenv ====
=== virtualenv ===


One may choose to create an isolated python instance on your host, to be able to work with PyOGP without installing packages to your base Python install on your host.  
Virtualenv builds isolated python environments. To learn more, read this: http://pypi.python.org/pypi/virtualenv.


To use a dedicated python installation in your host, install virtualenv like this:
To use a dedicated python installation in your host, isolated from your system python install, install virtualenv like this:


  easy_install virtualenv
  easy_install virtualenv
Line 81: Line 88:
== Install methods ==
== Install methods ==


Python modules can be installed in a variety of ways...
Python modules can be installed in a variety of ways... we're encouraging the virtualenv and setup.py method.


=== Install Method 1: buildout [Defunct] ===
=== buildout ===


We use zc.buildout to automatically setup a development environment. buildout gives you the ability to install packages only locally instead of your global python installation. It's sort of a local python installation which helps you avoiding version conflicts of packages.
Buildout has a variety of uses, in PyOGP's case it is used as a development sandbox. Buildout will checkout all the necessary PyOGP repositories and their dependencies, and configure everything automatically (set up the right path members and install scripts). Once the sandbox is set up, you can make changes to the libs in the parts/ directory (they are actually local mercurial repositories), update the code referenced in buildout (re-run bin/buildout), and test your changes.
 
It's really easy to work with...


1. First check out the buildout into a directory of your choice:
1. First check out the buildout into a directory of your choice:


  svn co http://svn.secondlife.com/svn/linden/projects/2008/pyogp/buildouts/libdev/trunk/ libdev
  hg clone http://bitbucket.org/enus_linden/pyogp.buildout (or grab pyogp.buildout-maint to work with maintenance repos)


For those who are interested, tagged and stable version of buildout (with pinned versions on externals) is available at https://svn.secondlife.com/svn/linden/projects/2008/pyogp/buildouts/libdev/tags/0.1/.
2. Now turn this checkout into a virtual python environment, independent of your normal Python installation:


2. '''(Optional)''' Now turn this directory into a virtual python environment which is independent of your normal Python installation:
  cd pyogp.buildout
 
  cd libdev
  virtualenv . --no-site-packages
  virtualenv . --no-site-packages


Line 102: Line 109:
  c:\Python25\Scripts\virtualenv.exe . --no-site-packages
  c:\Python25\Scripts\virtualenv.exe . --no-site-packages


3. Now run the bootstrap.py file with the newly created local Python interpreter (if installed. If not, use your system's python.):
3. Now run the bootstrap.py file with the newly created local Python interpreter:


  bin/python bootstrap.py
  bin/python bootstrap.py
Line 113: Line 120:


   bin/buildout -v
   bin/buildout -v
*** This fails with the message:
  Abort: repository 'http://bitbucket.org/enus_linden/pyogp.lib.base/' is not local


or on Windows:
or on Windows:
Line 118: Line 129:
   bin\buildout.exe -v
   bin\buildout.exe -v


5. The development sandbox is ready. There now is a bin/pyogp which is a python interpreter which contains all the installed packaged and the pyogp library and related projects.
5. The development sandbox is ready. There now is a bin/pyogp_interpreter, a python interpreter which contains all the installed packages and the pyogp libraries and dependencies referenced in the path.


6. Test the buildout installation. To test this installation you can (at least at this stage of the project) try the following:
6. Test the buildout installation. To test this installation you can (at least at this stage of the project) try the following sample script or run the unittests:


   bin/region_connect <firstname> <lastname>
   bin/region_connect <firstname> <lastname>


Give your Avatar name and it will ask for a password. Then it tries to login to the Preview Grid.
  -or-


=== Install Method 2: setup.py ===
  bin/unittests --where=parts/pyogp.lib.base (or pyogp.lib.client)


How to check out packages and using them independently of buildout.
Enter the avatar's password when prompted, and you're on your way to aditi, the Beta Grid.


If you are comfortable, feel free to use setup.py (with or without a dedicated virtualenv) in any of the following repos:
=== setup.py ===


: hg clone https://enus_linden@bitbucket.org/enus_linden/pyogp.apps/
If you prefer to not use buildout, and to do things a bit more manually, well, you probably don't need much help here then do you? ;)
: hg clone https://enus_linden@bitbucket.org/enus_linden/pyogp.lib.base/
: hg clone https://enus_linden@bitbucket.org/enus_linden/pyogp.lib.client/


Each of the repos already has eggs embedded, and pyogp.apps has the appropriate dependency on pyogp.lib.base configured, which can be checked out and installed in isolation.
Grab the source for each of the pyogp repos, and install them to a virtualenv instance (see above for installing virtualenv if you don't have it)..


1Check out the repository of your choice
Here's a simple setup that Enus likes:
  svn co https://svn.secondlife.com/svn/linden/projects/2008/pyogp/<the repo you wanted>/trunk <your pyogp dir>
cd ~
mkdir sandbox
cd sandbox
virtualenv . --no-site-packages
cd ~
mkdir hg
cd hg
  hg clone https://enus_linden@bitbucket.org/lindenlab/pyogp.apps/
  hg clone https://enus_linden@bitbucket.org/lindenlab/pyogp.lib.base/
hg clone https://enus_linden@bitbucket.org/lindenlab/pyogp.lib.client/
cd ~/hg/pyogp.lib.base
~/sandbox/bin/python setup.py install
cd ~/hg/pyogp.lib.client
~/sandbox/bin/python setup.py install
cd ~/hg/pyogp.apps
~/sandbox/bin/python setup.py install
......
now, in ~/sandbox/bin/ you'll have all kinds of pyogp executables for testing stuff out (like region_connect, etc)


2. Run setup.py
You now have all the source, plus a sandbox, for tinkering with pyogp!
cd <your pyogp dir>
 
python setup.py
To try an executable out, just run it in ~/sandbox/bin/. for example:
  ~/sandbox/bin/region_connect firstname lastname
This command will login in your agent to aditi, and will prompt you for a password.
 
Pass any script the "-h" param to get it's usage.


== Run the tests ==
== Run the tests ==


See [[PyOGP_Client_Library#Pyogp_Unit_Tests]] for details...
See [[PyOGP_Package_Unittests]] for details...
 
== The structure of the sandbox ==


You now might wonder what all those directories are good for. To learn more about this check out the [[Pyogp/Filesystem_Structure|Filesystem Structure]]


[[Category: Pyogp_Client_Lib]]
[[Category: Pyogp_Client_Lib]]

Latest revision as of 02:27, 13 September 2022

We will first run down the general explanation and add platform specific notes later.


Repositories

Stable trunk repositories:

Maintenance repositories:

Defunct until someone picks them up and fixes them:

Archives of the above repositories:

Browse the Code

If all you want to do is glance at the source code, use the bitbucket source browser:

Environment Preparation

Prerequisites

You must have the following installed:

  • Mercurial - 1.3 or greater
  • Python 2.4.4, 2.5.x, 2.6.x (untested on 3.0)

Setuptools and easy_install are Python standard means for installing modules. For more info, start here: http://pypi.python.org/pypi/setuptools.

Virtualenv is a method which allows you to create isolated Python environments, separate from your base install if you so prefer. For more, see here: http://pypi.python.org/pypi/virtualenv.

Your distribution may have Python's setuptools and virtualenv packages in its package repository. If so, it is probably best to use your normal package installation procedures (see below for information on specific Linux distributions). If the packages are not available then follow these generic instructions.

Mac Specifics

Note: Snow Leopard upgrades require a updated install of XCode, in this case to accommodate gcc (and greenlet).

Generic *nix Specifics

In order to install Python Packages and creating a development sandbox you have to do the following:

easy_install

"Easy Install is a python module (easy_install) bundled with setuptools that lets you automatically download, build, install, and manage Python packages." I stole that from here: http://peak.telecommunity.com/DevCenter/EasyInstall.

Download ez_setup.py and run it with your Python interpreter. You can find it here: http://peak.telecommunity.com/dist/ez_setup.py

Eventually you have to be root to do this depending on your system (mostly non-windows). It should look like this on a unix based machine:

wget http://peak.telecommunity.com/dist/ez_setup.py
 -or-
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py

virtualenv

Virtualenv builds isolated python environments. To learn more, read this: http://pypi.python.org/pypi/virtualenv.

To use a dedicated python installation in your host, isolated from your system python install, install virtualenv like this:

easy_install virtualenv

Or, if you need to be root something like this:

sudo easy_install virtualenv

On windows, you may need a different path to easy_install

c:\Python25\Scripts\easy_install.exe virtualenv

Install methods

Python modules can be installed in a variety of ways... we're encouraging the virtualenv and setup.py method.

buildout

Buildout has a variety of uses, in PyOGP's case it is used as a development sandbox. Buildout will checkout all the necessary PyOGP repositories and their dependencies, and configure everything automatically (set up the right path members and install scripts). Once the sandbox is set up, you can make changes to the libs in the parts/ directory (they are actually local mercurial repositories), update the code referenced in buildout (re-run bin/buildout), and test your changes.

It's really easy to work with...

1. First check out the buildout into a directory of your choice:

hg clone http://bitbucket.org/enus_linden/pyogp.buildout (or grab pyogp.buildout-maint to work with maintenance repos)

2. Now turn this checkout into a virtual python environment, independent of your normal Python installation:

cd pyogp.buildout
virtualenv . --no-site-packages

on windows, you may need to specify the path

c:\Python25\Scripts\virtualenv.exe . --no-site-packages

3. Now run the bootstrap.py file with the newly created local Python interpreter:

bin/python bootstrap.py

or on Windows:

 Scripts\python bootstrap.py

4. This creates a bunch of directories and the bin/buildout script (bin\buildout.exe on windows). We now run this:

 bin/buildout -v
      • This fails with the message:
 Abort: repository 'http://bitbucket.org/enus_linden/pyogp.lib.base/' is not local

or on Windows:

 bin\buildout.exe -v

5. The development sandbox is ready. There now is a bin/pyogp_interpreter, a python interpreter which contains all the installed packages and the pyogp libraries and dependencies referenced in the path.

6. Test the buildout installation. To test this installation you can (at least at this stage of the project) try the following sample script or run the unittests:

 bin/region_connect <firstname> <lastname>
 -or-
 bin/unittests --where=parts/pyogp.lib.base (or pyogp.lib.client)

Enter the avatar's password when prompted, and you're on your way to aditi, the Beta Grid.

setup.py

If you prefer to not use buildout, and to do things a bit more manually, well, you probably don't need much help here then do you? ;)

Grab the source for each of the pyogp repos, and install them to a virtualenv instance (see above for installing virtualenv if you don't have it)..

Here's a simple setup that Enus likes:

cd ~
mkdir sandbox
cd sandbox
virtualenv . --no-site-packages
cd ~
mkdir hg
cd hg
hg clone https://enus_linden@bitbucket.org/lindenlab/pyogp.apps/
hg clone https://enus_linden@bitbucket.org/lindenlab/pyogp.lib.base/
hg clone https://enus_linden@bitbucket.org/lindenlab/pyogp.lib.client/
cd ~/hg/pyogp.lib.base
~/sandbox/bin/python setup.py install
cd ~/hg/pyogp.lib.client
~/sandbox/bin/python setup.py install
cd ~/hg/pyogp.apps
~/sandbox/bin/python setup.py install
......
now, in ~/sandbox/bin/ you'll have all kinds of pyogp executables for testing stuff out (like region_connect, etc)

You now have all the source, plus a sandbox, for tinkering with pyogp!

To try an executable out, just run it in ~/sandbox/bin/. for example:

 ~/sandbox/bin/region_connect firstname lastname

This command will login in your agent to aditi, and will prompt you for a password.

Pass any script the "-h" param to get it's usage.

Run the tests

See PyOGP_Package_Unittests for details...