8000 gh-71052: Change Android's `sys.platform` from "linux" to "android" by mhsmith · Pull Request #116215 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-71052: Change Android's sys.platform from "linux" to "android" #116215

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Update sys.platform documentation
  • Loading branch information
mhsmith committed Mar 5, 2024
commit d49bd1a3bf1afd715ea1aa1870ee08387fa02a65
45 changes: 20 additions & 25 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1367,47 +1367,42 @@ always available.

.. data:: platform

This string contains a platform identifier that can be used to append
platform-specific components to :data:`sys.path`, for instance.

For Unix systems, except on Linux and AIX, this is the lowercased OS name as
returned by ``uname -s`` with the first part of the version as returned by
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
when Python was built*. Unless you want to test for a specific system
version, it is therefore recommended to use the following idiom::

if sys.platform.startswith('freebsd'):
# FreeBSD-specific code here...
elif sys.platform.startswith('linux'):
# Linux-specific code here...
elif sys.platform.startswith('aix'):
# AIX-specific code here...

For other systems, the values are:
A string containing a platform identifier. Known values are:

================ ===========================
System ``platform`` value
================ ===========================
AIX ``'aix'``
Android ``'android'``
Emscripten ``'emscripten'``
iOS ``'ios'``
Linux ``'linux'``
WASI ``'wasi'``
macOS ``'darwin'``
Windows ``'win32'``
Windows/Cygwin ``'cygwin'``
macOS ``'darwin'``
WASI ``'wasi'``
================ ===========================

On Unix systems not listed in the table, the value is the lowercased OS name
as returned by ``uname -s``, with the first part of the version as returned by
``uname -r`` appended, e.g. ``'sunos5'`` or ``'freebsd8'``, *at the time
when Python was built*. Unless you want to test for a specific system
version, it is therefore recommended to use the following idiom::

if sys.platform.startswith('freebsd'):
# FreeBSD-specific code here...

.. versionchanged:: 3.3
On Linux, :data:`sys.platform` doesn't contain the major version anymore.
It is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``. Since
older Python versions include the version number, it is recommended to
always use the ``startswith`` idiom presented above.
It is always ``'linux'``, instead of ``'linux2'`` or ``'linux3'``.

.. versionchanged:: 3.8
On AIX, :data:`sys.platform` doesn't contain the major version anymore.
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``. Since
older Python versions include the version number, it is recommended to
always use the ``startswith`` idiom presented above.
It is always ``'aix'``, instead of ``'aix5'`` or ``'aix7'``.

.. versionchanged:: 3.13
On Android, :data:`sys.platform` now returns ``'android'`` rather than
``'linux'``.

.. seealso::

Expand Down
0