1
1
mirror of https://github.com/Kozea/WeasyPrint.git synced 2024-10-05 00:21:15 +03:00
WeasyPrint/docs/install.rst
2013-02-26 15:04:52 +01:00

163 lines
4.3 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Installing
==========
WeasyPrint |version| depends on:
* CPython_ 2.6, 2.7 or ≥ 3.1
* cairo_ [#]_
* Pango_
* CFFI_ ≥ 0.5
* lxml_
* cairocffi_ ≥ 0.3
* tinycss_ = 0.3
* cssselect_ ≥ 0.6
* CairoSVG_ ≥ 0.4.1
* Optional: GDK-PixBuf_ [#]_
.. _CPython: http://www.python.org/
.. _cairo: http://cairographics.org/
.. _Pango: http://www.pango.org/
.. _CFFI: https://cffi.readthedocs.org/
.. _cairocffi: http://packages.python.org/cairocffi/
.. _GTK: http://www.gtk.org/
.. _lxml: http://lxml.de/
.. _tinycss: http://packages.python.org/tinycss/
.. _cssselect: http://packages.python.org/cssselect/
.. _CairoSVG: http://cairosvg.org/
.. _GDK-PixBuf: https://live.gnome.org/GdkPixbuf
Python, cairo, Pango and GDK-PixBuf need to be installed separately.
See :ref:`platform-specific instructions <platforms>` below.
CFFI and lxml can be installed by pip automatically
if your system has a C compiler and all the relevant development files,
but using a system package might be easier.
Install WeasyPrint with pip_.
This will automatically install most of dependencies.
You probably need either virtualenv_ [#]_ (recommended) or using ``sudo``.
.. _virtualenv: http://www.virtualenv.org/
.. _pip: http://pip-installer.org/
.. code-block:: sh
virtualenv ./venv
. ./venv/bin/activate
pip install WeasyPrint
Now lets try it:
.. code-block:: sh
weasyprint --help
weasyprint http://weasyprint.org ./weasyprint-website.pdf
You should see warnings about unsupported CSS 3 stuff; this is expected.
In the PDF you should see the WeasyPrint logo on the first page.
You can also play with :ref:`navigator`:
.. code-block:: sh
python -m weasyprint.navigator
If everything goes well, youre ready to :doc:`start using </tutorial>`
WeasyPrint! Otherwise, please copy the full error message and
`report the problem <http://weasyprint.org/community/>`_.
.. [#] cairo ≥ 1.12 is best but older versions should work too.
The test suite passes on cairo 1.8 and 1.10 with some tests marked as
“expected failures” due to behavior changes or bugs in cairo.
.. [#] Without it, PNG and SVG are the only supported image format:
JPEG, GIF and others are not available.
Versions before 0.22 were part of GTK_.
.. [#] If you installed CFFI or lxml with a system package,
you need to pass the `--system-site-packages` to virtualenv
for pip and WeasyPrint to find them.
Otherwise, pip will try to install them inside the isolated virtualenv.
.. _platforms:
By platform
-----------
Pango, GdkPixbuf, and cairo can not be installed
with pip and need to be installed from your platforms packages.
lxml can\ [#]_, but pre-compiled packages are often easier.
.. [#] In this case you additionally need libxml2 and libxslt with
development headers to compile lxml. On Debian the package are named
``libxml2-dev`` and ``libxslt1-dev``.
Debian / Ubuntu
~~~~~~~~~~~~~~~
Debian 7.0 Wheezy or newer, Ubuntu 11.10 Oneiric or newer:
.. code-block:: sh
sudo apt-get install python-pip python-lxml libcairo2 libpango1.0-0 libgdk-pixbuf2.0-0
Debian 6.0 Squeeze, Ubuntu 10.04 Lucid:
GDK-PixBuf is part of GTK, which also depends on cairo and Pango.
.. code-block:: sh
sudo apt-get install python-pip python-lxml libgtk2.0-0
Archlinux
~~~~~~~~~
.. code-block:: sh
sudo pacman -S python-pip python-lxml cairo pango gdk-pixbuf2
Gentoo
~~~~~~
WeasyPrint itself is packaged in the `Kozea overlay
<https://github.com/Kozea/Overlay/blob/master/README>`_.
Mac OS X
~~~~~~~~
With Macports
.. code-block:: sh
sudo port install py27-pip py27-lxml cairo pango gdk-pixbuf2
With Homebrew:
.. code-block:: sh
brew install python cairo pango gdk-pixbuf libxml2 libxslt
Note that Homebrew has no package
`for lxml <https://github.com/mxcl/homebrew/wiki/Acceptable-Formula>`_.
So were installing its own dependencies.
lxml itself will be installed automatically
when you run ``pip install WeasyPrint``.
Windows
~~~~~~~
* Get CPython 2.7 `from python.org <http://www.python.org/download/>`_,
* `Christoph Gohlkes unofficial binaries
<http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml>`_ for CFFI and lxml,
* and `Alexander Shaduris GTK installer
<http://gtk-win.sourceforge.net/home/index.php/Main/Downloads>`_.
Make sure the *Set up PATH environment variable* checkbox is checked.