Repository navigation
Conversation
Documentation build overview
7 files changed ·
|
StanFromIreland
left a comment
There was a problem hiding this comment.
A new sys.platform value, wheel tag and public platform.ohos_ver() API are more than a minor feature, e.g., Android and iOS got theirs through PEPs (738 and 730), so I think those parts need at minimum a Discourse discussion first. Could this PR be reduced to the config.sub/config.guess sync and the platform_triplet.c block, leaving sys.platform as "linux" like we do for musl?
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
How to distinguish OpenHarmony and HarmonyOS(the commercial one from Huawei)? Thanks. |
| "x86_64": "x86_64", | ||
| }[machine] | ||
| elif sys.platform == "ohos": | ||
| return f"ohos-{machine}" |
| self._set_uname(('Linux', 'localhost', '5.10.43', '#1 SMP', 'aarch64')) | ||
| self.assertEqual(get_platform(), 'ohos-aarch64') | ||
| self.assertEqual(get_platform(), 'ohos-26-aarch64') | ||
| sys.platform = 'linux' |
|
I am not very familiar with GitHub setup to comment in commits. Hope I have done the right thing. After brief reading https://github.com/python/cpython/pull/162322/commits
I don't think that's the right idea, based on my experience of development on HarmonyOS. I am generally fine with those two changes just to add a new platform ohos. One more thing, OpenHarmony and HarmonyOS 7.0 SDK are not public available to developers outside of China(even with Huawei Developer ID). Then it's better also support 6.1 in some way. |
It's not a problem. HarmonyOS can continue to use ohos. |
|
@liangqi You are not a community maintainer, I did not request a review from you, and this matter has absolutely nothing to do with you. Could you please remain silent for now and let the community maintainers complete the review? You have generated far too much activity. If you need to discuss anything, please do so with me through another channel. |
|
Community members are welcome to review PRs, regardless of whether they are maintainers or were explicitly asked to do so. While in this case the review may have been a little excessive, people make mistakes, and we should assume good intentions. Asking someone to remain silent in this manner is unnecessarily dismissive. Please take a moment to read our Code of Conduct and keep interactions respectful and welcoming. |
|
@StanFromIreland Got it. |
|
@StanFromIreland Today, I learned that another developer is also working on adding support for OpenHarmony and is expected to start a discussion on Discourse in the next few days. Their goals align with my current objectives. Therefore, I would prefer to retain all of the feature support currently included rather than narrow the scope of the PR. Once the Discourse thread has been created, we can continue discussing this topic there. |
|
Sure, then I'll convert this to a draft. |
Closes #162319.
Background
This PR adds basic build support for the OpenHarmony platform.
The OpenHarmony standard system uses a Linux kernel (or a Linux-compatible kernel) but not the GNU userland. This architecture is similar to Android, so this PR follows CPython's existing Android platform handling where applicable:
*-*-linux-android*is identified asLinux-android, withMACHDEP=android.*-*-linux-ohos*is identified asLinux-ohos, withMACHDEP=ohos.This preserves the existing Linux platform logic while providing the platform identity required for OpenHarmony, including its wheel platform tags.
The
linux-ohosidentifier is not an arbitrary name introduced by this PR. It follows the target triple assigned to OpenHarmony by the LLVM toolchain:<arch>-unknown-linux-ohos(shorthand:<arch>-linux-ohos).Changes
__OHOS__and*-*-linux-ohos*in native and cross-compilation paths, resulting insys.platform == "ohos".config.subto acceptlinux-ohos. This change was backported from GNU config commit5d8be4275fe9066e3322386213120e1d93af6020.oh-uni-package.jsonmetadata and record it asOHOS_API_LEVEL, since OpenHarmony does not provide an API-level compiler macro like Android's__ANDROID_API__.ohos-26-aarch64) and the corresponding wheel tag (for example,ohos_26_aarch64).platform.ohos_ver()to report the OS release and runtime API level.No existing branches for other platforms are changed.
Scope
This PR targets the three architectures supported by the OpenHarmony SDK: aarch64, arm, and x86_64.
Native compilation is detected automatically by
config.guess, so no explicit target triple is required:For cross-compilation, explicitly specify the target triple and provide the build machine's triple and
--with-build-pythonas required by CPython:Testing
I validated CPython's
mainbranch using both native compilation on aarch64 OpenHarmony and cross-compilation from x86_64 Linux with the official OpenHarmony SDK. I ran the resulting interpreters on aarch64 OpenHarmony and verified:sys.platform == "ohos".sysconfig.get_platform() == "ohos-26-aarch64".sysconfig.get_config_var("OHOS_API_LEVEL") == 26.build-details.jsoncontains"platform": "ohos-26-aarch64".platform.ohos_ver()returnsOhosVer(release='7.0.0.109', api_level=26).I also ran the full test suite for both configurations:
The remaining failures involve platform and libc differences and are outside the scope of this PR. Tests for unavailable optional modules are skipped.