GitHub supports multiple ways to have a logo displayed depending on dark/light mode. Somehow, any of these options do not seem to work well when the GitHub repository is a Python project uploaded to PyPi.
Here is what I tried, and the effects in PyPi:

Which seems to show the same effect as here on Stack overflow:


I.e., both logos are displayed at the same time on the PyPi page.
Option 2:
<p align="center">
<picture>
<source srcset="https://github.com/coguardio/coguard-cli/raw/master/logo_dark_mode.png" media="(prefers-color-scheme: dark)">
<img src="https://github.com/coguardio/coguard-cli/raw/master/logo.png" alt="Light mode logo" width="500">
</picture>
</p>
This looks in PyPi like the following:
Okay, here is my overarching question to the community: What is the right way to have dark/light logos AND have them correctly displayed in both GitHub and PyPi?

I figured out a work-around. I created a second README file, and then added to my setup.cfg of the python project the second, PYPI friendly, README.
Then I added an additional test to my pipeline which ensured that there is no diff between those files after the logo section by ensuring that this diff is empty:
diff <(tail -n +8 README.md) <(tail -n +3 README_PYPI.md)