SkillAgentSearch skills...

Phoenix

wxPython's Project Phoenix. A new implementation of wxPython, better, stronger, faster than he was before.

Install / Use

/learn @wxWidgets/Phoenix

README

========================= wxPython Project Phoenix

.. image:: demo/bitmaps/splash.png :align: center

Introduction

Welcome to wxPython's Project Phoenix! Phoenix is the improved next-generation wxPython, "better, stronger, faster than he was before." This new implementation is focused on improving speed, maintainability and extensibility. Just like "Classic" wxPython, Phoenix wraps the wxWidgets C++ toolkit and provides access to the user interface portions of the wxWidgets API, enabling Python applications to have a native GUI on Windows, Macs or Unix systems, with a native look and feel and requiring very little (if any) platform specific code.

.. note:: This document is primarily intended for those who will be working on wxPython, or at least building with the source code fetched directly from GitHub. If that's not you then please refer to the instructions at the wxPython website <https://wxpython.org/pages/downloads/>_ about how to get the current release of wxPython for your platform and chosen Python environment.

.. contents:: Contents

Development at GitHub.com

Development of wxPython is done with git, using https://github.com/wxWidgets/Phoenix as the main development site.

Currently (September, 2024), only 2 developers (@swt2c, @RobinD42) can merge pull requests, or assign others to review pull requests.

How to build wxPython Phoenix

First of all, this README is intended primarily for those who want to build wxPython from a workspace checked out from the wxPython Phoenix repository. If you are not making changes to wxPython, or needing to build it for some unsupported compiler or some other hardware architecture, then you probably do not need to put yourself through the pain for building in this way. It's a complicated build, and can sometimes be confusing even for the experts. Instead, if the binaries available at PyPI are not what you need then you can use pip to build from the released source archives, or from the source archives created in the pre-release snapshot builds. See the notes about it at:

  • https://wxpython.org/pages/downloads/
  • https://wxpython.org/blog/2017-08-17-builds-for-linux-with-pip

Next, review the section below about prerequisites.

All aspects of the wxPython Phoenix build are managed through a series of commands provided by the build.py script. There is also a setup.py script available for builds using setuptools. The setup.py script assumes that all of the code generation steps have already been performed, and so it is suitable for use when building from a source snapshot tarball or when using pip. The setup.py script will delegate to build.py for the actual build, and build.py will delegate to setup.py when using pip or building a wheel.

Using the build.py script allows for greater control over the build process than setup.py does, including commands for performing the various code-generation steps. So developers working on Phoenix itself or building from a Git checkout, instead of a source snapshot tarball, should be using the build.py script. The build.py script provides a fairly simple command-line interface consisting of commands and options. To see the full list run python build.py --help. The most important commands are listed below.

Windows Users NOTE: If you are building Phoenix on Windows and have a non-English language installation of Microsoft Visual Studio then you may need to set the code page in your console window in order to avoid Unicode decoding errors. For example::

chcp 1252
python build.py <build commands>...

In addition, some tasks within the build currently expect to be able to use Cygwin on Windows (https://www.cygwin.com/) to do its work. If you have Cygwin installed in one of the default locations (c:\cygwin or c:\cygwin64) then all is well. If you have it installed somewhere else then you can set CYGWIN_BASE in the environment and the build tool will use that for the base dir.

On the other hand, if you just want to do a standard setuptools-style build using setup.py and are using a full source tarball, then you can stop reading at this point. If you want to build from a source repository checkout, or need to make changes and/or to regenerate some of the generated source files, then please continue reading.

Building wxWidgets

Since build.py will, by default, build both wxWidgets and Phoenix you will need the wxWidgets code as well. The source tarballs already include both wxWidgets and the Phoenix source code, so if you are getting your copy of the source code that way then you are all set. If you are fetching it from GitHub you will need to do an additional step. The git repository is set up to bring in the wxWidgets code as a git "submodule" so after cloning the Phoenix repository, you can get the wxWidgets source with these commands::

$ git submodule update --init --recursive

This will clone the wxWidgets repo into: Phoenix/ext/wxWidgets. Once the submodule is updated, the build script should be able to build wxWidgets.

If you would rather use an already built and installed wxWidgets then that is possible as well by changing some options, see python build.py --help for details. However be aware that doing so will require a wxWidgets that is very close to the same age as the Phoenix code, at least for the unreleased preview snapshots. In other words, the wxWidgets build should use code from the wxWidgets source repository within a few days of when the Phoenix code was checked out. Currently the master branch of Phoenix is tracking the master branch of wxWidgets. Also note that even when using an external copy of wxWidgets with --use_syswx option, you still need the contents of ext/nanosvg submodule for the build to succeed, so you will still need to run at least::

git submodule update --init ext/nanosvg

On the other hand, it is probably best to just let wxPython build and bundle wxWidgets. The build tools will by default build wxWidgets in a way that allows it to be bundled with the wxPython extension modules as part of the wxPython package, meaning it can peacefully coexist with any wxWidgets libraries you may already have installed. This bundling of the wx shared libraries works on Windows, OSX and Linux, and probably any other unix-like system using shared libraries based on the ELF standard. The libraries are built in such a way that they are relocatable, meaning that they do not have to be in a fixed location on the filesystem in order to be found by the wxPython extension modules. This also means that you can do things like use pip to install a wxPython wheel in one or more virtual environments, move the wx package to a versioned folder, or even move it into your own project if desired, all without needing to rebuild the binaries. (Assuming that compatible Pythons are being used in all cases of course.)

The build phase of the build.py script will copy the results of the wxWidgets and Phoenix builds into the wx folder in the Phoenix source tree. This will allow you to run and test Phoenix directly from the source tree without installing it, if desired. You just need to set PYTHONPATH appropriately, or you can use python setup.py develop or pip install -e . to install an .egg-link file in your current Python site-packages folder that will point to the folder where you built wxPython Phoenix. When you are finished testing you can then use the install or one of the bdist commands like you normally would for other Python packages.

Important build.py commands

The following build.py commands are required to be able to build Phoenix from scratch. In other words, from a pristine source tree with none of the generated code present yet. They can be run individually or you can specify all of them on a single command line, in the order given. Once a command has succeeded in one run of build.py there is no need to run that command again in a later run, unless you've changed something which that command has the responsibility to process. Many of the commands require the results of the earlier commands, so at least the first time you run the build you will need to use all 4 of the commands (or their equivalents for composite commands) in the given order.

  • dox: Builds the XML files from the wxWidgets documentation source, which will be used as input for the etg command.

  • etg: Extracts information from the dox XML files, runs hand-written tweaker code on the extracted data structures, and runs various generators on the result to produce code for the next steps. The code being run for each item in this step is located in the etg folder in the Phoenix source tree.

  • sip: This command processes the files generated in the etg command and produces the C++ code that will become the Python extension modules for wxPython Phoenix.

  • build: Build both wxWidgets and wxPython. There are additional commands if you want to build just one or the other. The results will be put in the Phoenix/wx folder, and can be used from there without installation if desired, by setting PYTHONPATH so the Phoenix/wx package dir is found by Python.

Some other useful commands and options are:

  • clean: Clean up the build products produced by prior runs of build.py. There are additional clean commands that will let you clean up just portions of the build if needed.

  • touch: Updates the timestamp on all of the etg scripts, so they will be forced to be run in the next build. This is useful when a change has been made to the wxWidgets documentation that needs to be propagated through the build since the etg command doesn't yet do full dependency checking of the input.

  • M.N: This is the Major.Minor version number of the Python that the extension module

Related Skills

View on GitHub
GitHub Stars2.6k
CategoryDevelopment
Updated5h ago
Forks558

Languages

Python

Security Score

85/100

Audited on Mar 25, 2026

No findings