astral-sh / astral-sh/python-build-standalone
Enable Bluetooth support
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 314
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 27
Description
CPython has has [supported Bluetooth with `socket.AF_BLUETOOTH`](https://docs.python.org/3/library/socket.html#socket-families) since [version 2.4 alpha 1](https://www.python.org/download/releases/2.4.1/notes/#what-s-new-in-python-2-4-alpha-1), but it seems the builds weren't compiled with the necessary header files:
> The socket module now supports Bluetooth sockets, if the system has
```shell
$ python
Python 3.13.0rc2 (main, Sep 9 2024, 22:13:26) [Clang 18.1.8 ] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.AF_BLUETOOTH
Traceback (most recent call last):
File "", line 1, in
socket.AF_BLUETOOTH
AttributeError: module 'socket' has no attribute 'AF_BLUETOOTH'
>>> import sysconfig
>>> {k:v for k,v in sysconfig.get_config_vars().items() if 'blue' in k.lower() or k=='MODDISABLED_NAMES'}
{'HAVE_BLUETOOTH_BLUETOOTH_H': 0, 'HAVE_BLUETOOTH_H': 0, 'MODDISABLED_NAMES': '_gdbm _scproxy _testcapi xx xxlimited xxlimited_35'}
```
The relevant headers appear to be part of `libbluetooth-dev` (from [BlueZ](https://www.bluez.org/), the "Official Linux Bluetooth protocol stack") on Debian.
Would you like me to submit a PR?
Contributor guide
Assessment
This issue has not been assessed yet.