Skip to main content

A pythonic wrapper for SDL2

Project description

psdl is a package that wraps the excellent SDL2 module in an easy to use python interface.

Note that this project is still in its super early stages, theres lots of stuff still left to be wrapped.

Why PSDL?

You may be already knowing that there are many SDL wrappers out there, from stuff like PySDL2 to pygame. What makes PSDL different? Well, PSDL aims to be a wrapper “of right thickness”. There are some SDL wrappers that are too thin, and they expose the C-level details to python, which is not that elegant. Also, they directly copy the SDL API, which is un-pythonic. And there are SDL wrappers that are too thick, and they dont export the SDL API at all, they have their own API.

PSDL aims to export the SDL API as directly as possible, while also “pythonifying” it. Let us consider a typical SDL function that looks like SDL_SomeFunctionForSomething. PSDL will export it, by stripping the inital SDL_ (because python has namespaces, unlike C) and changing the style of the function name to something that looks more pythonic. The function will look like psdl.some_function_for_something from the PSDL side. Similarly, SDL constants are exported by just stripping the initial SDL_ part of it, SDL_SOME_CONSTANT becomes psdl.SOME_CONSTANT. While SDL provided enums, PSDL does not export the enums directly, it just exports the constants within it.

Coming to structures, PSDL does different stuff based on the context. Since C is not object oriented, you will find this style of coding commonly used in SDL.

SDL_someobj *obj;
SDL_CreateSomeObj(obj, someargs);
SDL_SomeMethod(obj, moreargs);
SDL_AnotherMethod(obj, args, moreargs);
SDL_DestroyObj(obj);

We can take advantage of python OOP, and psdl will export the samething like

::

obj = psdl.SomeObj(args) obj.some_method(moreargs) obj.another_method(args, moreargs)

Notice the naming convention adopted here. Also notice that in python, we need not explicitly deallocate objects, python being a high-level language, does that automatically for us.

Installation

psdl can be installed via pip, using the following command, pip3 install psdl. Note that currently, psdl does not provide binary “wheels” on PyPI, so the pip command will build psdl from source. For that, check out the section below

Building from source

Windows

The build process is pretty straight forward on windows. You just need to have the MSVC C compiler set up correctly. psdl is automatically going to get all its dependencies (ie, its gonna download SDL from the official website) and automatically build psdl.

Mac/Linux

On Mac/linux too, the build process aint complicated. All you need to have is a C compiler (which is usually present on most systems) and SDL installed via your package manager. Then psdl will easily install from source.

Advanced Build Options

You can set two environment variables, PSDL_INCLUDE_DIR and PSDL_LIB_DIR to optionally specify paths to SDL include and library directories, respectively. This will be used by PSDL when it attempts to build from source.

TODO

Theres still lot left to do, like I said earlier, this project is still in its super early stages. There needs to be docs, tests, and examples written, apart from the code that needs to be written.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

psdl-0.0.1a1.tar.gz (15.1 kB view details)

Uploaded Source

File details

Details for the file psdl-0.0.1a1.tar.gz.

File metadata

  • Download URL: psdl-0.0.1a1.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.7.3

File hashes

Hashes for psdl-0.0.1a1.tar.gz
Algorithm Hash digest
SHA256 7af63017de90672101c55cf87096432544c776cc9089f684d8160ae863d71abd
MD5 17d8385dad66cd17edab9aeeef3f720e
BLAKE2b-256 f21f53f4f46f55e8a7bde6184ae43a5669da089ea756be7ac0be00f282c4792b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page