From 8b563c3a8f70a84afc9ab932e17bfa4b221c6417 Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Mon, 2 May 2016 08:43:38 -0600 Subject: [PATCH] Add initial setup file with dependencies and simple readme This is just to start sketching out the repository and how we go about installing it --- README.md | 10 +++ bin/vanth | 0 setup.py | 135 +++++++++++++++++++++++++++++++++++++ vanth/__init__.py | 0 vanth/api/__init__.py | 0 vanth/backend/__init__.py | 0 vanth/platform/__init__.py | 0 vanth/version.py | 1 + 8 files changed, 146 insertions(+) create mode 100644 README.md create mode 100644 bin/vanth create mode 100644 setup.py create mode 100644 vanth/__init__.py create mode 100644 vanth/api/__init__.py create mode 100644 vanth/backend/__init__.py create mode 100644 vanth/platform/__init__.py create mode 100644 vanth/version.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a80d43 --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +Vanth +----- + +Vanth is a way to track your expenses. It's primary goals are the following: + +1 - You can host it yourself so you don't have to trust any third party with your financial data +2 - It minimizes the amount of effort and human input required to maximally track your expenses +3 - It seeks to maximize information available about your expenses + +Vanth is released under the Affero GPL (http://www.affero.org/oagpl.html) diff --git a/bin/vanth b/bin/vanth new file mode 100644 index 0000000..e69de29 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..95c7204 --- /dev/null +++ b/setup.py @@ -0,0 +1,135 @@ +import contextlib +import imp +import os +import re +import subprocess + +from setuptools import setup +from setuptools.command.sdist import sdist + +DATA_ROOTS = ['alembic'] +PROJECT = 'vanth' +VERSION_FILE = 'vanth/version.py' + +def _get_output_or_none(args): + try: + return subprocess.check_output(args).decode('utf-8').strip() + except subprocess.CalledProcessError: + return None + +def _get_git_description(): + return _get_output_or_none(['git', 'describe']) + +def _get_git_branches_for_this_commit(): + branches = _get_output_or_none(['git', 'branch', '-r', '--contains', 'HEAD']) + split = branches.split('\n') if branches else [] + return [branch.strip() for branch in split] + +def _is_on_releasable_branch(branches): + return any([branch == 'origin/master' or branch.startswith('origin/hotfix') for branch in branches]) + +def _git_to_version(git): + match = re.match(r'(?P[\d\.]+)-(?P[\d]+)-(?P\w{8})', git) + if not match: + version = git + else: + version = "{tag}.post0.dev{offset}".format(**match.groupdict()) + return version + +@contextlib.contextmanager +def write_version(): + git_description = _get_git_description() + git_branches = _get_git_branches_for_this_commit() + version = _git_to_version(git_description) if git_description else None + if git_branches and not _is_on_releasable_branch(git_branches): + print("Forcing version to 0.0.1 because this commit is on branches {} and not a whitelisted branch".format(git_branches)) + version = '0.0.1' + if version: + with open(VERSION_FILE, 'r') as version_file: + old_contents = version_file.read() + with open(VERSION_FILE, 'w') as version_file: + version_file.write('VERSION = "{}"\n'.format(version)) + yield + if version: + with open(VERSION_FILE, 'w') as version_file: + version_file.write(old_contents) + +def _get_version_from_file(): + basedir = os.path.abspath(os.path.dirname(__file__)) + root = imp.load_source('version', os.path.join(basedir, PROJECT, 'version.py')) + return root.VERSION + +def _get_version_from_git(): + git_description = _get_git_description() + git_branches = _get_git_branches_for_this_commit() + version = _git_to_version(git_description) if git_description else None + if git_branches and not _is_on_releasable_branch(git_branches): + print("Forcing version to 0.0.1 because this commit is on branches {} and not a whitelisted branch".format(git_branches)) + version = '0.0.1' + return version + +def get_version(): + file_version = _get_version_from_file() + git_version = _get_version_from_git() + return (file_version == 'development' and git_version) or file_version + +def get_data_files(): + data_files = [] + for data_root in DATA_ROOTS: + for root, _, files in os.walk(data_root): + data_files.append((os.path.join(PROJECT, root), [os.path.join(root, f) for f in files])) + return data_files + +class CustomSDistCommand(sdist): # pylint: disable=no-init + def run(self): + with write_version(): + sdist.run(self) + +def main(): + setup( + name = "vanth", + version = get_version(), + description = "A system for tracking expenses", + url = "https://github.com/EliRibble/vanth", + long_description = open('README.md', 'r').read(), + author = "Eli Ribble", + author_email = "junk@theribbles.org", + cmdclass = { + 'sdist' : CustomSDistCommand, + }, + install_requires = [ + 'chryso==1.3', + 'sepiida==5.27', + ], + extras_require = { + 'develop': [ + 'astroid==1.4.4', + 'coverage==3.7.1', + 'mothermayi>=0.4', + 'mothermayi-isort>=0.8', + 'mothermayi-pylint>=0.5', + 'py==1.4.31', + 'pylint==1.5.4', + 'pytest==2.8.2', + 'pytest-cov==1.8.1', + ] + }, + packages = [ + "vanth", + "vanth.api", + "vanth.backend", + "vanth.platform", + ], + package_data = { + "vanth" : ["vanth/*"], + "vanth.backend" : ["vanth/backend/*"], + "vanth.api" : ["vanth/api/*"], + "vanth.platform" : ["vanth/platform/*"], + }, + data_files = get_data_files(), + scripts = ["bin/vanth"], + include_package_data = True, + ) + +if __name__ == "__main__": + main() diff --git a/vanth/__init__.py b/vanth/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vanth/api/__init__.py b/vanth/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vanth/backend/__init__.py b/vanth/backend/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vanth/platform/__init__.py b/vanth/platform/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vanth/version.py b/vanth/version.py new file mode 100644 index 0000000..3c53fed --- /dev/null +++ b/vanth/version.py @@ -0,0 +1 @@ +VERSION = 'development'