Skip to content

Commit

Permalink
Fix: module did not expose __version__ (#75)
Browse files Browse the repository at this point in the history
Solution: declare `__version__` in `__init__.py` and parse the file with a regex to determine the version in `setup.py`.
  • Loading branch information
1yam authored Jul 12, 2023
1 parent 599fd56 commit dd8037c
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 27 deletions.
1 change: 1 addition & 0 deletions aleph_message/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .models import MessagesResponse, parse_message

__all__ = ["parse_message", "MessagesResponse"]
__version__ = "0.4.0"
76 changes: 49 additions & 27 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,60 @@
"""

import os
import re


def get_version():
version_file = os.path.join("aleph_message", "__init__.py")
initfile_lines = open(version_file, "rt").readlines()
version = r"^__version__ = ['\"]([^'\"]*)['\"]"

for line in initfile_lines:
mo = re.search(version, line, re.M)
if mo:
return mo.group(1)
raise RuntimeError(f"Unable to find version string in {version_file}.")


from setuptools import setup

# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))

with open('README.md') as file:
with open("README.md") as file:
long_description = file.read()

setup(name='aleph-message',
version='0.4.0',
description='Aleph.im message specification ',
long_description=long_description,
long_description_content_type='text/markdown',
author='Hugo Herter',
author_email='[email protected]',
url='https://github.com/aleph-im/aleph-message',
packages=['aleph_message', 'aleph_message.models', 'aleph_message.models.execution'],
package_data={"aleph_message": ["py.typed"],
"aleph_message.models": ["py.typed"],
"aleph_message.models.execution": ["py.typed"]},
data_files=[],
install_requires=[
'pydantic~=1.10.5',
'typing_extensions~=4.5.0',
],
license='MIT',
platform='any',
keywords="aleph.im message validation specification",
classifiers=['Development Status :: 5 - Production/Stable',
'Programming Language :: Python :: 3',
'Intended Audience :: Developers',
'Topic :: System :: Distributed Computing',
],
)
setup(
name="aleph-message",
version=get_version(),
description="Aleph.im message specification ",
long_description=long_description,
long_description_content_type="text/markdown",
author="Hugo Herter",
author_email="[email protected]",
url="https://github.com/aleph-im/aleph-message",
packages=[
"aleph_message",
"aleph_message.models",
"aleph_message.models.execution",
],
package_data={
"aleph_message": ["py.typed"],
"aleph_message.models": ["py.typed"],
"aleph_message.models.execution": ["py.typed"],
},
data_files=[],
install_requires=[
"pydantic~=1.10.5",
"typing_extensions~=4.5.0",
],
license="MIT",
platform="any",
keywords="aleph.im message validation specification",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3",
"Intended Audience :: Developers",
"Topic :: System :: Distributed Computing",
],
)

0 comments on commit dd8037c

Please sign in to comment.