From ae102749eda2a9f7c4af66be6beab4c3f759d75e Mon Sep 17 00:00:00 2001 From: deadc0de6 Date: Sat, 23 Dec 2017 17:52:53 +0100 Subject: [PATCH] update for pypi --- MANIFEST.in | 1 + dotdrop.sh | 3 +-- dotdrop/__init__.py | 15 ++++++++++++ dotdrop/action.py | 4 +++- dotdrop/config.py | 8 ++++--- dotdrop/dotdrop.py | 28 ++++++++++++---------- dotdrop/installer.py | 6 +++-- dotdrop/templategen.py | 4 +++- dotdrop/utils.py | 4 +++- setup.cfg | 11 +++++++++ setup.py | 54 ++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 115 insertions(+), 23 deletions(-) create mode 100644 MANIFEST.in create mode 100644 setup.cfg create mode 100644 setup.py diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..b2cc4f5 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include README.md LICENSE requirements.txt diff --git a/dotdrop.sh b/dotdrop.sh index 784e505..75300f5 100755 --- a/dotdrop.sh +++ b/dotdrop.sh @@ -18,7 +18,6 @@ fi args=("$@") cur=$(dirname "$(${rl} "${0}")") opwd=$(pwd) -bin="${cur}/dotdrop/dotdrop.py" cfg="${cur}/config.yaml" # pivot @@ -26,6 +25,6 @@ cd "${cur}" || { echo "Folder \"${cur}\" doesn't exist, aborting." && exit; } # init the submodule git submodule update --init --recursive # launch dotdrop -python3 "${bin}" --cfg="${cfg}" "${args[@]}" +python3 -m dotdrop.dotdrop --cfg="${cfg}" "${args[@]}" # pivot back cd "${opwd}" || { echo "Folder \"${opwd}\" doesn't exist, aborting." && exit; } diff --git a/dotdrop/__init__.py b/dotdrop/__init__.py index e69de29..31e7e54 100644 --- a/dotdrop/__init__.py +++ b/dotdrop/__init__.py @@ -0,0 +1,15 @@ +""" +author: deadc0de6 (https://github.com/deadc0de6) +Copyright (c) 2017, deadc0de6 +""" + +import sys + +__version__ = '0.6' + + +def main(): + import dotdrop.dotdrop + if dotdrop.dotdrop.main(): + sys.exit(0) + sys.exit(1) diff --git a/dotdrop/action.py b/dotdrop/action.py index 3cc5396..e463f4d 100644 --- a/dotdrop/action.py +++ b/dotdrop/action.py @@ -5,7 +5,9 @@ Represent an action in dotdrop """ import subprocess -from logger import Logger + +# local imports +from dotdrop.logger import Logger class Action: diff --git a/dotdrop/config.py b/dotdrop/config.py index 49e1332..4e8fa72 100644 --- a/dotdrop/config.py +++ b/dotdrop/config.py @@ -6,9 +6,11 @@ config file manager import yaml import os -from dotfile import Dotfile -from logger import Logger -from action import Action + +# local import +from dotdrop.dotfile import Dotfile +from dotdrop.logger import Logger +from dotdrop.action import Action class Cfg: diff --git a/dotdrop/dotdrop.py b/dotdrop/dotdrop.py index cd27f54..c661eff 100755 --- a/dotdrop/dotdrop.py +++ b/dotdrop/dotdrop.py @@ -7,15 +7,17 @@ entry point import os import sys import subprocess -import utils from docopt import docopt -from logger import Logger -from templategen import Templategen -from installer import Installer -from dotfile import Dotfile -from config import Cfg -VERSION = '0.6' +# local imports +from . import __version__ as VERSION +from .logger import Logger +from .templategen import Templategen +from .installer import Installer +from .dotfile import Dotfile +from .config import Cfg +from .utils import * + CUR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) LOG = Logger() HOSTNAME = os.uname()[1] @@ -40,7 +42,7 @@ Usage: Options: --profile= Specify the profile to use [default: %s]. - -c --cfg= Path to the config [default: %s/config.yaml]. + -c --cfg= Path to the config [default: config.yaml]. --files= Comma separated list of files to compare. -n --nodiff Do not diff when installing. -l --link Import and link. @@ -50,7 +52,7 @@ Options: -v --version Show version. -h --help Show this screen. -""" % (BANNER, HOSTNAME, CUR) +""" % (BANNER, HOSTNAME) ########################################################### # entry point @@ -147,16 +149,16 @@ def importer(opts, conf, paths): if opts['dry']: LOG.dry('would run: %s' % (' '.join(cmd))) else: - utils.run(cmd, raw=False, log=False) + run(cmd, raw=False, log=False) cmd = ['cp', '-R', '-L', dst, srcf] if opts['dry']: LOG.dry('would run: %s' % (' '.join(cmd))) if opts['link']: LOG.dry('would symlink %s to %s' % (srcf, dst)) else: - utils.run(cmd, raw=False, log=False) + run(cmd, raw=False, log=False) if opts['link']: - utils.remove(dst) + remove(dst) os.symlink(srcf, dst) if retconf: LOG.sub('\"%s\" imported' % (path)) @@ -226,7 +228,7 @@ def main(): elif args['compare']: # compare local dotfiles with dotfiles stored in dotdrop - tmp = utils.get_tmpdir() + tmp = get_tmpdir() if compare(opts, conf, tmp, args['--files']): LOG.raw('\ntemporary files available under %s' % (tmp)) else: diff --git a/dotdrop/installer.py b/dotdrop/installer.py index 58a9ea9..ff5d0b5 100644 --- a/dotdrop/installer.py +++ b/dotdrop/installer.py @@ -5,8 +5,10 @@ handle the installation of dotfiles """ import os -import utils -from logger import Logger + +# local imports +from dotdrop.logger import Logger +import dotdrop.utils as utils class Installer: diff --git a/dotdrop/templategen.py b/dotdrop/templategen.py index d84b9c1..c5d3fbe 100644 --- a/dotdrop/templategen.py +++ b/dotdrop/templategen.py @@ -5,9 +5,11 @@ jinja2 template generator """ import os -import utils from jinja2 import Environment, FileSystemLoader +# local imports +import dotdrop.utils as utils + BLOCK_START = '{%@@' BLOCK_END = '@@%}' VAR_START = '{{@@' diff --git a/dotdrop/utils.py b/dotdrop/utils.py index 8c2f450..afd46aa 100644 --- a/dotdrop/utils.py +++ b/dotdrop/utils.py @@ -7,9 +7,11 @@ utilities import subprocess import tempfile import os -from logger import Logger from shutil import rmtree +# local import +from dotdrop.logger import Logger + LOG = Logger() diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..2590684 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,11 @@ +[metadata] +description-file = README.md +license_file = LICENSE + +[bdist_wheel] +python-tag = py3 + +[files] +extra_files = + LICENSE + README.md diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..1bfbb24 --- /dev/null +++ b/setup.py @@ -0,0 +1,54 @@ +from setuptools import setup, find_packages +from codecs import open +from os import path +import dotdrop + +readme = 'README.md' +here = path.abspath(path.dirname(__file__)) + +try: + from pypandoc import convert + read_readme = lambda f: convert(f, 'rst') +except ImportError: + print('\n[WARNING] pypandoc not found, could not convert \"{}\"\n'.format(readme)) + read_readme = lambda f: open(f, 'r').read() + +VERSION = dotdrop.__version__ + +setup( + name='dotdrop', + version=VERSION, + + description='Save your dotfiles once, deploy them everywhere', + long_description=read_readme(readme), + url='https://github.com/deadc0de6/dotdrop', + download_url = 'https://github.com/deadc0de6/dotdrop/archive/v'+VERSION+'.tar.gz', + + author='deadc0de6', + author_email='deadc0de6@foo.bar', + + license='GPLv3', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', + ], + + keywords='dotfiles jinja2', + packages=find_packages(exclude=['tests*']), + install_requires=['docopt', 'Jinja2', 'PyYAML'], + + extras_require={ + 'dev': ['check-manifest'], + 'test': ['coverage', 'pytest', 'pytest-cov'], + }, + + entry_points={ + 'console_scripts': [ + 'dotdrop=dotdrop:main', + ], + }, +)