2009-04-02 15:10:16 +08:00
|
|
|
|
2009-12-24 02:58:52 +08:00
|
|
|
.. _`index page`: http://pypi.python.org/pypi/py/
|
2009-06-19 19:05:44 +08:00
|
|
|
|
2009-12-24 02:58:52 +08:00
|
|
|
py.test/pylib installation info in a nutshell
|
2008-08-16 23:26:59 +08:00
|
|
|
===================================================
|
|
|
|
|
2010-05-06 03:03:43 +08:00
|
|
|
**Pythons**: 2.4, 2.5, 2.6, 2.7, 3.0, 3.1.x, Jython-2.5.1, PyPy-1.2
|
2009-11-06 00:46:14 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
**Operating systems**: Linux, Windows, OSX, Unix
|
2009-11-06 00:46:14 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
**Requirements**: setuptools_ or Distribute_
|
2009-11-06 00:46:14 +08:00
|
|
|
|
2010-01-03 21:19:31 +08:00
|
|
|
**Installers**: easy_install_ and pip_ or `standalone`_ (new for 1.2)
|
2009-12-24 02:58:52 +08:00
|
|
|
|
|
|
|
**Distribution names**:
|
|
|
|
|
|
|
|
* PyPI name: ``py`` (see `index page`_ for versions)
|
2010-05-29 15:15:50 +08:00
|
|
|
* redhat fedora: ``python-py``
|
2009-12-24 02:58:52 +08:00
|
|
|
* debian: ``python-codespeak-lib``
|
|
|
|
* gentoo: ``pylib``
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
**Installed scripts**: see `bin`_ for which and how scripts are installed.
|
2009-12-24 02:58:52 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
**hg repository**: https://bitbucket.org/hpk42/py-trunk
|
2010-01-22 02:34:42 +08:00
|
|
|
|
2009-12-24 02:58:52 +08:00
|
|
|
.. _`bin`: bin.html
|
2009-11-06 00:46:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
.. _`easy_install`:
|
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
Installation using easy_install
|
2009-11-06 00:46:14 +08:00
|
|
|
===================================================
|
|
|
|
|
|
|
|
Both `Distribute`_ and setuptools_ provide the ``easy_install``
|
2010-09-14 21:43:00 +08:00
|
|
|
installation tool with which you can type into a command line window::
|
2009-06-30 18:42:57 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
easy_install -U py
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-11-06 00:46:14 +08:00
|
|
|
to install the latest release of the py lib and py.test. The ``-U`` switch
|
2010-07-27 03:15:15 +08:00
|
|
|
will trigger an upgrade if you already have an older version installed.
|
2010-09-14 21:43:00 +08:00
|
|
|
Note that setuptools works ok with Python2 interpreters while `Distribute`_
|
|
|
|
additionally works with Python3 and also avoid some issues on Windows.
|
2009-11-02 20:00:48 +08:00
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
Known issues:
|
2009-11-06 00:46:14 +08:00
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
- **Windows**: If "easy_install" or "py.test" are not found
|
|
|
|
please see here for preparing your environment for running
|
|
|
|
command line tools: `Python for Windows`_. You may alternatively
|
|
|
|
use an `ActivePython install`_ which makes command line tools
|
|
|
|
automatically available under Windows.
|
|
|
|
|
|
|
|
.. _`ActivePython install`: http://www.activestate.com/activepython/downloads
|
|
|
|
|
|
|
|
.. _`Jython does not create command line launchers`: http://bugs.jython.org/issue1491
|
|
|
|
|
|
|
|
- **Jython2.5.1 on Windows XP**: `Jython does not create command line launchers`_
|
|
|
|
so ``py.test`` will not work correctly. You may install py.test on
|
|
|
|
CPython and type ``py.test --genscript=mytest`` and then use
|
|
|
|
``jython mytest`` to run py.test for your tests to run in Jython.
|
|
|
|
|
|
|
|
- **On Linux**: If ``easy_install`` fails because it needs to run
|
|
|
|
as the superuser you are trying to install things globally
|
|
|
|
and need to put ``sudo`` in front of the command.
|
2009-11-06 00:46:14 +08:00
|
|
|
|
|
|
|
|
|
|
|
.. _quickstart: test/quickstart.html
|
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
|
|
|
|
Recommendation: install tool and dependencies virtually
|
|
|
|
===========================================================
|
|
|
|
|
|
|
|
It is recommended to work with virtual environments
|
|
|
|
(e.g. virtualenv_ or buildout_ based) and use easy_install_
|
|
|
|
(or pip_) for installing py.test/pylib and any dependencies
|
|
|
|
you need to run your tests. Local virtual Python environments
|
|
|
|
(as opposed to system-wide "global" environments) make for a more
|
|
|
|
reproducible and reliable test environment.
|
|
|
|
|
|
|
|
.. _`virtualenv`: http://pypi.python.org/pypi/virtualenv
|
|
|
|
.. _`buildout`: http://www.buildout.org/
|
|
|
|
.. _pip: http://pypi.python.org/pypi/pip
|
|
|
|
|
2010-01-03 21:19:31 +08:00
|
|
|
.. _standalone:
|
|
|
|
|
|
|
|
Generating a py.test standalone Script
|
|
|
|
============================================
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
If you are a maintainer or application developer and want users
|
2010-01-03 21:19:31 +08:00
|
|
|
to run tests you can use a facility to generate a standalone
|
|
|
|
"py.test" script that you can tell users to run::
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
py.test --genscript=mytest
|
2010-01-03 21:19:31 +08:00
|
|
|
|
|
|
|
will generate a ``mytest`` script that is, in fact, a ``py.test`` under
|
|
|
|
disguise. You can tell people to download and then e.g. run it like this::
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
python mytest --pastebin=all
|
2010-01-03 21:19:31 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
and ask them to send you the resulting URL. The resulting script has
|
|
|
|
all core features and runs unchanged under Python2 and Python3 interpreters.
|
2010-01-03 21:19:31 +08:00
|
|
|
|
2010-09-14 21:43:00 +08:00
|
|
|
.. _`Python for Windows`: http://www.imladris.com/Scripts/PythonForWindows.html
|
2009-06-30 18:42:57 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
.. _mercurial: http://mercurial.selenic.com/wiki/
|
2010-07-27 03:15:15 +08:00
|
|
|
.. _`Distribute`:
|
2009-11-02 20:00:48 +08:00
|
|
|
.. _`Distribute for installation`: http://pypi.python.org/pypi/distribute#installation-instructions
|
2009-09-07 23:53:50 +08:00
|
|
|
.. _`distribute installation`: http://pypi.python.org/pypi/distribute
|
2009-08-19 01:04:57 +08:00
|
|
|
.. _checkout:
|
|
|
|
.. _tarball:
|
2008-09-23 22:42:27 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
Working from version control or a tarball
|
2009-07-15 03:17:13 +08:00
|
|
|
=================================================
|
2008-09-23 22:42:27 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
To follow development or start experiments, checkout the
|
2009-11-06 00:46:14 +08:00
|
|
|
complete code and documentation source with mercurial_::
|
2008-09-23 22:42:27 +08:00
|
|
|
|
2009-07-15 03:17:13 +08:00
|
|
|
hg clone https://bitbucket.org/hpk42/py-trunk/
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-11-13 04:15:59 +08:00
|
|
|
Development takes place on the 'trunk' branch.
|
2009-06-30 18:42:57 +08:00
|
|
|
|
2009-11-05 10:18:55 +08:00
|
|
|
You can also go to the python package index and
|
2009-08-19 01:04:57 +08:00
|
|
|
download and unpack a TAR file::
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
http://pypi.python.org/pypi/py/
|
2009-07-21 00:54:08 +08:00
|
|
|
|
2009-11-02 20:00:48 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
activating a checkout with setuptools
|
2009-08-19 01:04:57 +08:00
|
|
|
--------------------------------------------
|
|
|
|
|
2009-11-02 20:00:48 +08:00
|
|
|
With a working `Distribute`_ or setuptools_ installation you can type::
|
2009-08-19 01:04:57 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
python setup.py develop
|
2009-08-19 01:04:57 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
in order to work inline with the tools and the lib of your checkout.
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-07-21 00:54:08 +08:00
|
|
|
.. _`no-setuptools`:
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
.. _`directly use a checkout`:
|
2009-08-19 01:04:57 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
directly use a checkout or tarball / avoid setuptools
|
2009-11-02 20:00:48 +08:00
|
|
|
-------------------------------------------------------------
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-12-24 19:27:15 +08:00
|
|
|
Get a checkout_ or tarball_ and add paths to your environment variables:
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-12-24 19:27:15 +08:00
|
|
|
* ``PYTHONPATH`` needs to contain the root directory (where ``py`` resides)
|
2010-07-27 03:15:15 +08:00
|
|
|
* ``PATH`` needs to contain ``ROOT/bin`` or ``ROOT\bin\win32`` respectively.
|
2009-12-24 19:27:15 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
There also are helper scripts that set the variables accordingly. On windows
|
2009-12-24 19:27:15 +08:00
|
|
|
execute::
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
# inside autoexec.bat or shell startup
|
2009-11-02 20:00:48 +08:00
|
|
|
c:\\path\to\checkout\bin\env.cmd
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
on linux/OSX add this to your shell initialization::
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
# inside e.g. .bashrc
|
|
|
|
eval `python ~/path/to/checkout/bin/env.py`
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
both of which which will get you good settings. If you install
|
2009-12-24 19:27:15 +08:00
|
|
|
the pylib this way you can easily ``hg pull && hg up`` or download
|
|
|
|
a new tarball_ to follow the development tree.
|
2009-08-19 01:04:57 +08:00
|
|
|
|
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
Note that the scripts manually added like this will look for
|
|
|
|
py libs in the chain of parent directories of the current working dir.
|
2009-12-24 19:27:15 +08:00
|
|
|
For example, if you have a layout like this::
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-07-15 03:17:13 +08:00
|
|
|
mypkg/
|
|
|
|
subpkg1/
|
|
|
|
tests/
|
|
|
|
tests/
|
2009-12-24 19:27:15 +08:00
|
|
|
py/
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-08-19 01:04:57 +08:00
|
|
|
issuing ``py.test subpkg1`` will use the py lib
|
2009-12-24 19:27:15 +08:00
|
|
|
from that projects root directory. If in doubt over where
|
|
|
|
the pylib comes from you can always do::
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-11-06 00:46:14 +08:00
|
|
|
py.test --version
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2010-07-27 03:15:15 +08:00
|
|
|
to see where py.test is imported from.
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-11-06 00:46:14 +08:00
|
|
|
.. _`command line scripts`: bin.html
|
2009-08-19 01:04:57 +08:00
|
|
|
.. _contact: contact.html
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-07-15 03:17:13 +08:00
|
|
|
.. _`RPM`: http://translate.sourceforge.net/releases/testing/fedora/pylib-0.9.2-1.fc9.noarch.rpm
|
2008-08-16 23:26:59 +08:00
|
|
|
|
2009-11-02 20:00:48 +08:00
|
|
|
.. _`setuptools`: http://pypi.python.org/pypi/setuptools
|
2008-08-22 21:41:17 +08:00
|
|
|
|