Skip to content

Commit f280bff

Browse files
committed
Misc. docs cleanup
1 parent 4f1f339 commit f280bff

File tree

4 files changed

+71
-68
lines changed

4 files changed

+71
-68
lines changed

doc/faq.rst

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,24 @@
22

33
PySDL2 FAQ
44
==========
5-
This is a list of Frequently Asked Questions about PySDL2. If you think,
6-
something is missing, please suggest it!
5+
This is a list of Frequently Asked Questions about PySDL2. If there are any
6+
questions and answers you would like added here, please let us know on GitHub!
77

88
On importing...
99
---------------
1010
... my script fails and complains that a SDL2 library could not be found!
1111

12-
Do you have the libraries properly installed? If on macOS or Windows,
13-
try running ``pip install pysdl2-dll`` and opening a fresh terminal
14-
to fix the problem. If on Linux or similar, did you follow the operating
15-
system's way of installing or registering libraries? If you placed the
16-
libraries in some folder, make sure that the ``PYSDL2_DLL_PATH``
17-
environment variable points to the correct location.
12+
Do you have the libraries properly installed? On most platforms, you can
13+
install them easily using ``pip install pysdl2-dll``. On ARM64 macOS, you
14+
can install native SDL2 binaries using the Homebrew package manager. For
15+
BSD, Linux on exotic architectures (not x86 or ARM64), and other Unix-like
16+
platforms, install the SDL2 binaries using your system's package manager. On
17+
all platforms, you can manually set the path of your SDL2 binaries using
18+
the ``PYSDL2_DLL_PATH`` environment variable.
1819

1920
... my script fails complaining that the *found* SDL2 library can't be used!
2021

21-
Do you use a 64-bit operating system? Please make sure, that the Python
22+
Do you use a 64-bit operating system? Please make sure that the Python
2223
interpreter *and* that the SDL2 libraries are either 64-bit ones *or*
2324
32-bit ones. A 32-bit Python interpreter can't deal with a 64-bit library
2425
and vice versa.
@@ -28,28 +29,34 @@ Using...
2829

2930
... the sdl2 API is weird. Why do you use the SDL\_ prefix all the time?
3031

31-
The low-level APIs for SDL2, SDL2\_mixer, SDL2\_ttf, ... shall represent a
32-
clean wrapping around the original C API calls. Thus, if you have to search
33-
for documentation or want to make a Python to C conversion (or C to Python),
34-
most of the code cleanly maps to the original API naming and layout and you
35-
do not have to think about whether you had to use SDL\_ or TTF\_ or whatever
36-
as prefix or suffix.
32+
PySDL2 offers 1-to-1 bindings for most of the SDL2 API, keeping the same
33+
function names and arguments as the original SDL2, SDL2\_mixer, SDL2\_ttf,
34+
SDL2\_image, and SDL2\_gfx libraries. This makes the package much easier to
35+
maintain, but also makes it easy to reference the SDL2 documentation and
36+
adapt C SDL2 examples into Python code. For a friendlier, more Pythonic
37+
wrapper around the SDL2 API, take a look at PySDL2's :mod:`sdl2.ext`
38+
module.
3739

38-
... the sdl2 API is does not comply to PEP-8. Please make it PEP-8 compatible.
40+
... the sdl2 API does not comply to PEP-8. Please make it PEP-8 compatible.
3941

40-
Most of the API is PEP-8 compatible. The low-level bindings to SDL2 and
41-
related libraries however use the exact naming (including capital letters)
42-
as the functions or structures, they map to. See the previous entry for
43-
the reason of that.
42+
Most of the API is PEP-8 compatible. However, the low-level bindings to SDL2
43+
and its addon libraries use the exact same function/structure/constant naming
44+
as their C counterparts, meaning that PySDL2 will necessarily diverge from
45+
PEP-8 in some places. The :mod:`sdl2.ext` module should theoretically be
46+
fully PEP-8 compliant.
4447

4548
How do I...
4649
-----------
4750

4851
... save my surfaces as image files?
4952

50-
You can use :func:`sdl2.SDL_SaveBMP()` to save them as bitmap files. Other
51-
formats are currently unsupported, but might be added to
52-
the :mod:`sdl2.ext` package in the future.
53+
You can use :func:`sdl2.ext.save_bmp()` to save them as bitmap files, or the
54+
low-level :func:`sdl2.sdlimage.IMG_SavePNG()` function to save them to PNG on
55+
systems with SDL\_image installed. For a wider range of formats, you can use
56+
the :func:`~sdl2.ext.surface_to_ndarray` function to convert an SDL surface
57+
into a Numpy array, open the array with the Pillow library using
58+
``Image.from_array()``, and then save it to any export format supported by
59+
Pillow.
5360

5461

5562
Font handling...
@@ -59,10 +66,7 @@ Font handling...
5966

6067
The :mod:`sdl2.sdlttf` API does not know about platform-specific font
6168
locations and is unable to resolve font paths based on e.g. the font name
62-
or typeface. It's not its job and PySDL2 likewise does not provide such
63-
functionality. If you need improved font detection support, you might want
64-
to take a look at the sysfont module of the python-utils project, which can
65-
be found at https://bitbucket.org/marcusva/python-utils/. That said, it's
66-
usually a bad idea for a projects to rely on system fonts that may not be
67-
available on every computer: finding a free-use font you like and bundling
68-
it with your code is much safer.
69+
or typeface. Additionally, it's usually a bad idea for a projects to rely
70+
on system fonts that may not be available on every computer: finding a
71+
free-use font you like and bundling it with your project is almost always
72+
the better option.

doc/install.rst

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,30 @@ Installing PySDL2
33
This section provides an overview and guidance for installing PySDL2 on
44
various target platforms.
55

6-
Getting the sources
7-
-------------------
6+
Using pip
7+
---------
8+
The easiest way to get up and running with PySDL2 is to install it and the
9+
SDL2 binaries it depends on using the Pip package manager ::
10+
11+
python -m pip install pysdl2 pysdl2-dll
12+
13+
Note that the pysdl2-dll binaries may not be available yet for your platform.
14+
If not, please read through the Prerequisites section below.
15+
16+
Installing from source
17+
----------------------
818
You can download the official releases of PySDL2 from
919
https://github.com/marcusva/py-sdl2/releases. Download the most
1020
recent release, unpack it and make sure that you installed the relevant
1121
prerequisites before continuing with the installation.
1222

23+
Then, you can install PySDL2 directly with Python ::
24+
25+
python setup.py install
26+
1327
Prerequisites
1428
-------------
15-
PySDL2 relies on some 3rd party packages to be fully usable and to
29+
PySDL2 relies on some additional libraries to be fully usable and to
1630
provide you full access to all of its features.
1731

1832
You must have at least one of the following Python versions installed:
@@ -24,38 +38,23 @@ Other Python versions or Python implementations might work, but are
2438
(currently) not officially tested or supported by the PySDL2
2539
distribution.
2640

27-
You need to have a working SDL2 library on your target system. You can obtain
28-
the source code (to build it yourself) or a prebuilt version at
29-
http://www.libsdl.org. Alternatively, on macOS and Windows, you can install
30-
the SDL2 binaries for PySDL2 using pip via the pysdl2-dll package.
41+
You need to have a working SDL2 library on your target system. On Windows
42+
(32-bit and 64-bit x86), macOS (64-bit x86), and Linux (32-bit/64-bit x86,
43+
and 64-bit ARM), you can install the latest official binaries with pip via the
44+
pysdl2-dll package. Alternatively, you can install it using your system's
45+
package manager, download the official binaries from http://www.libsdl.org, or
46+
compile it from source yourself.
3147

32-
PySDL2 also offers support for the following SDL-related libraries:
48+
PySDL2 also offers optional support for the following SDL-related libraries:
3349

3450
* SDL2_image (http://www.libsdl.org/projects/SDL_image/)
3551
* SDL2_mixer (http://www.libsdl.org/projects/SDL_mixer/)
3652
* SDL2_ttf (http://www.libsdl.org/projects/SDL_ttf/)
3753
* SDL2_gfx (http://www.ferzkopp.net/Software/SDL_gfx-2.0/)
3854

39-
Those are optional though and only necessary if you want to use
40-
:mod:`sdl2.sdlimage`, :mod:`sdl2.sdlmixer`, :mod:`sdl2.sdlttf` or
41-
:mod:`sdl2.sdlgfx`.
42-
43-
Installation
44-
------------
45-
You can either use the python way of installing the package or the make
46-
command using the Makefile on POSIX-compatible platforms, such as Linux
47-
or BSD, or the make.bat batch file on Windows platforms.
48-
49-
Simply type ::
50-
51-
python setup.py install
52-
53-
for the traditional python way or ::
54-
55-
make install
56-
57-
for using the Makefile or make.bat. Both will try to perform a default
58-
installation with as many features as possible.
55+
However, these are only necessary if you want to use the :mod:`sdl2.sdlimage`,
56+
:mod:`sdl2.sdlmixer`, :mod:`sdl2.sdlttf` or :mod:`sdl2.sdlgfx` modules. Binaries
57+
for all these modules are provided by the pysdl2-dll package.
5958

6059
Trying out
6160
^^^^^^^^^^

doc/integration.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ The :mod:`sdl2` package relies on an external SDL2 library for creating the
1919
wrapper functions. This means that the user needs to have SDL2 installed or
2020
that you ship a SDL2 library with your project.
2121

22-
For macOS, Windows, and most distributions of x86 Linux, the easiest and most
23-
flexible way to bundle and install the SDL2 binaries with your project is via
24-
the ``pysdl2-dll`` package on PyPI,
22+
For macOS, Windows, and most distributions of x86 and ARM64 Linux, the easiest
23+
and most flexible way to bundle and install the SDL2 binaries with your project
24+
is via the ``pysdl2-dll`` package on PyPI,
2525
which pysdl2 will load automatically if available. This approach allows you to
2626
add the SDL2 binaries as a dependency for your project in a requirements.txt
2727
file, a setup.py file, a Pipfile, or any other form of Python dependency
@@ -30,7 +30,7 @@ project using this mechanism if your project depends on a function not
3030
available in earlier versions of SDL2.
3131

3232
For platforms without any available pysdl2-dll binaries (e.g. Alpine Linux,
33-
ARM64 Linux, BSD), PySDL2 will still work as long as a recent version of SDL2
33+
ARM32 Linux, BSD), PySDL2 will still work as long as a recent version of SDL2
3434
is installed using the system's package manager. Additionally, pysdl2-dll will
3535
still install successfully on unsupported platforms as an empty pacakge with
3636
no binaries, making it safe to add as a dependency for cross-platform projects.
@@ -53,7 +53,7 @@ be found.
5353
it will try to use that one in the first place, before using any SDL2
5454
library installed on the target system.
5555

56-
Let's assume, you ship your own library *SDL2.dll* within your project
56+
Let's assume you ship your own library *SDL2.dll* within your project
5757
location *fancy_project/third_party*. You can set the environment
5858
variable :envvar:`PYSDL2_DLL_PATH` before starting Python. ::
5959

doc/news.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Fixed Bugs:
7878
``TTF_RenderUTF`` instead of ``TTF_RenderUTF8``.
7979
* Fixed a bug introduced in 0.9.9 where the ``SDL_WINDOW_INPUT_GRABBED``
8080
constant was no longer exported.
81-
* :class:`~sdl2.ext.MemoryView` and :class:`~sdl2.ext.PixelAccess `objects now
81+
* :class:`~sdl2.ext.MemoryView` and :class:`~sdl2.ext.PixelAccess` objects now
8282
support negative indexing (e.g. ``arr[-1][-1]`` for accessing the last element
8383
in a 2D array). In previous versions, negative indices would retrieve values
8484
from undefined sections of memory outside the surface (PR #204)
@@ -92,8 +92,8 @@ Fixed Bugs:
9292
* :meth:`sdl2.ext.BitmapFont.contains` no longer assumes that the font map
9393
contains a space (PR #208)
9494
* Rendering multiline text with the :class:`sdl2.ext.BitmapFont` class now
95-
always splits lines using the newline (`\n`) character. Previously on
96-
Windows, it would only split on Windows-style line endings (`\r\n`) (PR #208)
95+
always splits lines using the newline (``\n``) character. Previously on
96+
Windows, it would only split on Windows-style line endings (``\r\n``) (PR #208)
9797

9898
API Changes:
9999

@@ -109,12 +109,12 @@ API Changes:
109109
* Updated the :meth:`~sdl2.ext.Renderer.draw_line` and
110110
:meth:`~sdl2.ext.Renderer.draw_point` methods of the
111111
:class:`~sdl2.ext.Renderer` class to accept coordinates as lists of ``(x, y)``
112-
tuples or :obj:`~sdl2.SDL_Point`s in addition to flat ``[x, y, x, y, x, y]``
112+
tuples or :obj:`~sdl2.SDL_Point` in addition to flat ``[x, y, x, y, x, y]``
113113
lists (PR #207)
114114
* Updated the :meth:`~sdl2.ext.Renderer.draw_rect` and
115115
:meth:`~sdl2.ext.Renderer.fill` methods of the
116116
:class:`~sdl2.ext.Renderer` class to accept coordinates as lists of
117-
:obj:`~sdl2.SDL_Rects`s in addition to lists of ``(x, y, w, h)``
117+
:obj:`~sdl2.SDL_Rect` in addition to lists of ``(x, y, w, h)``
118118
tuples (PR #207)
119119
* Updated the :meth:`~sdl2.ext.Renderer.copy` method of the
120120
:class:`~sdl2.ext.Renderer` class to accept an ``(x, y)`` tuple as a

0 commit comments

Comments
 (0)