Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions Lib/sysconfig/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,8 @@ def get_platform():
osname, release, machine = _osx_support.get_platform_osx(
get_config_vars(),
osname, release, machine)
elif osname == "freebsd":
release = release.partition('-')[0]

return '-'.join(map(str, filter(None, (osname, release, machine))))

Expand Down
10 changes: 10 additions & 0 deletions Lib/test/test_sysconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,16 @@ def test_get_platform(self):
'#1 Tue Jan 9 20:35:43 UTC 2018', machine))
self.assertEqual(get_platform(), f'android-9-{abi}')

# FreeBSD
os.name = 'posix'
sys.platform = 'freebsd'
self._set_uname((
'FreeBSD', 'localhost', '15.1-RELEASE-p4',
'FreeBSD 15.1-RELEASE-p4 releng/15.1-n283627-e38a7085f3a8 GENERIC',
'amd64'
))
self.assertEqual(get_platform(), 'freebsd-15.1-amd64')

# XXX more platforms to tests here

@unittest.skipIf(is_wasi, "Incompatible with WASI mapdir and OOT builds")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On FreeBSD, :func:`sysconfig.get_platform` now omits the branch and patch level.
Loading