How to request debug Python build?

I tried searching but I couldn’t find any way to ask for, or use, a debug Python build. This is useful as it runs with asserts enabled, and is very helpful for finding bugs in C extension modules.

I tried just calling python-dbg, but is not found in any of the Python 3 versions, and instead falls back to the default command-not-found behaviour (“run apt-get install python-dbg”). However, this is wrong, as Python is installed manually by travis scripts (e.g. “Downloading archive: https://storage.googleapis.com/travis-ci-language-archives/python/binaries/ubuntu/16.04/x86_64/python-3.8.tar.bz2”), and does not match the apt-provided package.

Any ideas?

Do you need to debug at Python or at C level?

Or do you rather need to run the entire build in an interactive debug mode (then refer to the link)?

python-dbg deb package is for system python 2 (possibly /usr/bin/python).
python3-dbg deb package is for system python 3 (possibly /usr/bin/python3).

If you want to run language: python's python with python-dbg or python-dbg3, make sure if the python is the system python installed by the deb package. I am not sure this case works.

https://packages.ubuntu.com/xenial/python-dbg
https://packages.ubuntu.com/xenial/python3-dbg

Maybe possible case to run Python3 with using deb packages as much as possible.

With language: minimal in .travis.yml,

$ sudo apt-get install python3 python3-dbg python3-something
$ which python3
$ dpkg -S /usr/bin/python3

Or

With language: python and python: 3.6 for example in .travis.yml,

$ python -m pip install dbg something

At python interpreter level, so neither actually :slight_smile:

Sadly, apt install doesn’t work because with ‘language: python’ and ‘python: 3.8’, python itself doesn’t come from apt, so installing the -dbg package from apt doesn’t work.

But pip install works to install the dbg variant of the interpreter? I’d be surprised, but I’ll look, thanks for the hint.

Have no idea what that means. But if you need Python from distro, use language: generic and install one of python*-dbg packages as @junaruga suggested. The executable will be available as python-dbg or python3-dbg (checked that with apt-file list).

Note that you can only get that for python versions provided by the distro. Travis doesn’t provide debug builds.

Sadly, apt install doesn’t work because with ‘language: python’ and ‘python: 3.8’, python itself doesn’t come from apt, so installing the -dbg package from apt doesn’t work.

That’s what I supposed. Thanks for sharing your experiment.

But pip install works to install the dbg variant of the interpreter? I’d be surprised, but I’ll look, thanks for the hint.

I see dbg in PyPI. That’s the dbg you are talking about right?

Okay, I found that pyenv can install debug versions (pyenv install X.Y.Z -g).

  • It builds versions from source
    • so you are responsible for installing binary dependencies from Apt. You can find their list online though.
    • Add the resulting installation to Travis cache and use e.g. pyenv install -s to avoid rebuilding.
  • Pyenv identifier for debug versions is X.Y.Z-debug so it won’t clash with preinstalled alternative versions
  • Travis has Pyenv installed globally into /opt so need to run pyenv install with sudo.
  • Last time I checked, pip was unable to install packages for a debug Python – at least, in Windows.