Skip to content

Commit

Permalink
Update version loading code and bump version
Browse files Browse the repository at this point in the history
Update version loading code in setup.py to use importlib instead of
using exec() to load the version module. Bump version to 0.4.0a1.
  • Loading branch information
tylertian123 committed Oct 6, 2020
1 parent b0e9bb4 commit fb31a4a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyryver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
this way the version can be obtained without having to import everything else, which may
not be possible due to missing dependencies, thus breaking `setup.py install`.
"""
__version__ = "0.4.0a0"
__version__ = "0.4.0a1"
19 changes: 15 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import importlib
import os
import setuptools

with open("README.md", "r") as fh:
Expand All @@ -6,13 +8,22 @@
with open("requirements.txt", "r") as fh:
install_requires = fh.read().splitlines()

__version__ = ""
with open("pyryver/version.py", "r") as fh:
exec(fh.read()) # pylint: disable=exec-used

def get_lib_ver():
"""
Magical function that loads the version from pyryver/version.py.
Credits to @mincrmatt12.
"""
spec = importlib.util.spec_from_file_location("pyryver.version", os.path.join(os.path.dirname(__file__), "pyryver/version.py"))
version = importlib.util.module_from_spec(spec)
spec.loader.exec_module(version)
return version.__version__


setuptools.setup(
name="pyryver",
version=__version__,
version=get_lib_ver(),
author="Tyler Tian, Matthew Mirvish",
author_email="tylertian123@gmail.com, matthew@mm12.xyz",
description="An unofficial async Python library for Ryver.",
Expand Down

0 comments on commit fb31a4a

Please sign in to comment.