Skip to content

Commit

Permalink
Create a _metadata.py file to re-use version number and author
Browse files Browse the repository at this point in the history
This makes it so the version number only needs to be bumped in one
location (and it's named clearly) instead of 3.

Can be modified in the future if we want to add more fields,
like a date. There's also the possibility to auto-update that file with
git tags but might be a bit overkill for now.
  • Loading branch information
OrangeChannel authored and kageru committed Sep 2, 2020
1 parent b6bac1d commit 605eb66
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
5 changes: 4 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

sys.path.insert(0, os.path.abspath('..'))

meta = {}
exec(open(os.path.abspath('../vsutil/_metadata.py')).read(), meta)


# -- Project information -----------------------------------------------------

Expand All @@ -23,7 +26,7 @@
author = 'Irrational Encoding Wizardry'

# The full version, including alpha/beta/rc tags
version = release = '0.5.0'
version = release = meta['__version__']


# -- General configuration ---------------------------------------------------
Expand Down
20 changes: 17 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
from setuptools import setup, find_packages
from setuptools.command.test import test
from distutils.util import convert_path

# We can't import the submodule normally as that would "run" the main module
# code while the setup script is meant to *build* the module.

# Besides preventing a whole possible mess of issues with an un-built package,
# this also prevents the vapoursynth import which breaks the docs on RTD.

# convert_path is used here because according to the distutils docs:
# '...filenames in the setup script are always supplied in Unix
# style, and have to be converted to the local convention before we can
# actually use them in the filesystem.'
meta = {}
exec(open(convert_path('vsutil/_metadata.py')).read(), meta)


class DiscoverTest(test):
Expand All @@ -20,15 +34,15 @@ def run_tests(self):

setup(
name='vsutil',
version='0.5.0',
version=meta['__version__'],
packages=find_packages(exclude=['tests']),
package_data={
'vsutil': ['py.typed']
},
url='https://encode.moe/vsutil',
license='MIT',
author='kageru',
author_email='[email protected]',
author=meta['__author__'].split()[0],
author_email=meta['__author__'].split()[1][1:-1],
description='A collection of general-purpose Vapoursynth functions to be reused in modules and scripts.',
install_requires=[
"vapoursynth"
Expand Down
5 changes: 5 additions & 0 deletions vsutil/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@
__all__ = []
for _pkg in _mods:
__all__ += __import__(__name__ + '.' + _pkg, fromlist=_mods).__all__

try:
from ._metadata import __author__, __version__
except ImportError:
__author__ = __version__ = 'unknown'
2 changes: 2 additions & 0 deletions vsutil/_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__author__ = 'kageru <[email protected]>'
__version__ = '0.5.0'

0 comments on commit 605eb66

Please sign in to comment.