Skip to content

Commit

Permalink
Fixed rendering of pypi image (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
karan6181 committed Oct 24, 2022
1 parent 7d4fe8f commit bc8a3b5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
<a href="https://github.com/mosaicml/streaming#gh-light-mode-only" class="only-light">
<img src="https://storage.googleapis.com/docs.mosaicml.com/images/streaming-logo-light-mode.png" width="50%"/>
</a>
<!--pypi website does not support dark mode and does not understand GitHub tag. Hence, it renders both the images.
The below tag is being used to remove the dark mode image on pypi website.-->
<!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_BEGIN -->
<a href="https://github.com/mosaicml/streaming#gh-dark-mode-only" class="only-dark">
<img src="https://storage.googleapis.com/docs.mosaicml.com/images/streaming-logo-dark-mode.png" width="50%"/>
Expand Down
22 changes: 18 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@
exec(f.read(), version_globals, version_locals)
streaming_version = version_locals['__version__']

# Use repo README for PyPi description
with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()

# Hide the content between <!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_BEGIN --> and
# <!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_END --> tags in the README
while True:
start_tag = '<!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_BEGIN -->'
end_tag = '<!-- SETUPTOOLS_LONG_DESCRIPTION_HIDE_END -->'
start = long_description.find(start_tag)
end = long_description.find(end_tag)
if start == -1:
assert end == -1, 'there should be a balanced number of start and ends'
break
else:
assert end != -1, 'there should be a balanced number of start and ends'
long_description = long_description[:start] + long_description[end + len(end_tag):]

classifiers = [
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
Expand Down Expand Up @@ -77,10 +95,6 @@
if package_name != 'mosaicml-streaming':
print(f'Building mosaicml-streaming as {package_name}')

# Use repo README for PyPi description
with open('README.md', 'r', encoding='utf-8') as fh:
long_description = fh.read()

setup(
name=package_name,
version=streaming_version,
Expand Down

0 comments on commit bc8a3b5

Please sign in to comment.