From 2366985ce124eb3dfc0b26b075f9692bbc696be2 Mon Sep 17 00:00:00 2001 From: Mark Blakeney Date: Mon, 11 Nov 2019 15:59:51 +1000 Subject: [PATCH] Fix installation issues --- Makefile | 21 ++++++++++---------- README.md | 5 +++-- install.sh | 56 ------------------------------------------------------ setup.py | 18 +++++++++--------- 4 files changed, 23 insertions(+), 77 deletions(-) delete mode 100755 install.sh diff --git a/Makefile b/Makefile index 55b9643..301e166 100644 --- a/Makefile +++ b/Makefile @@ -12,36 +12,37 @@ # General Public License at for more # details. -DOC = README.md - NAME = b2restore -SCRIPTS = b2restore-create-dummy-files b2restore-create-git +SCRIPTS = $(NAME)-create-dummy-files $(NAME)-create-git + +DOC = README.md DOCOUT = $(DOC:.md=.html) all: - @echo "Type sudo make install|uninstall, or make doc|check|clean" + @echo "Type sudo make install|uninstall" + @echo "or make sdist|upload|doc|check|clean" install: - @./install.sh -d "$(DESTDIR)" + pip3 install . uninstall: - @./install.sh -d "$(DESTDIR)" -u $(NAME) + pip3 uninstall $(NAME) sdist: python3 setup.py sdist upload: sdist - twine upload dist/* + twine3 upload dist/* doc: $(DOCOUT) +$(DOCOUT): $(DOC) + markdown $< >$@ + check: flake8 $(NAME).py $(NAME) setup.py vermin -i -q $(NAME).py $(NAME) setup.py shellcheck $(SCRIPTS) -$(DOCOUT): $(DOC) - markdown $< >$@ - clean: @rm -vrf $(DOCOUT) *.egg-info build/ dist/ __pycache__/ diff --git a/README.md b/README.md index bc76881..607b606 100644 --- a/README.md +++ b/README.md @@ -12,12 +12,13 @@ Arch users can install [b2restore from the AUR](https://aur.archlinux.org/packages/b2restore/). Requires python 3.5 or later. Note [b2restore is on -PyPI](https://pypi.org/project/b2restore/) so you can `sudo pip install +PyPI](https://pypi.org/project/b2restore/) so you can `sudo pip3 install b2restore` or: ``` $ git clone http://github.com/bulletmark/b2restore -$ sudo make install +$ cd b2restore +$ sudo pip3 install . ``` ### CREATION OF INITIAL RCLONE COPY diff --git a/install.sh b/install.sh deleted file mode 100755 index 518728a..0000000 --- a/install.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -# Script to install or uninstall python package in current dir - -usage() { - echo "Usage: $(basename $0) [-options]" - echo "Options:" - echo "-d (alternative root dir)" - echo "-u (uninstall given package name)" - echo "-o (default=1)" - exit 1 -} - -DESTDIR="" -NAME="" -OPTLEVEL="1" -while getopts d:u:o:\? c; do - case $c in - d) DESTDIR="$OPTARG";; - u) NAME="$OPTARG";; - o) OPTLEVEL="$OPTARG";; - ?) usage;; - esac -done - -shift $((OPTIND - 1)) - -if [[ $# -ne 0 ]]; then - usage -fi - -if [[ -z "$NAME" ]]; then - if [[ -n "$DESTDIR" ]]; then - DESTDIR="--root=$DESTDIR" - fi - if [[ -n "$OPTLEVEL" ]]; then - OPTLEVEL="--optimize=$OPTLEVEL" - fi - exec python3 setup.py install $DESTDIR $OPTLEVEL -fi - -rm -vrf $DESTDIR/etc/$NAME.conf $DESTDIR/usr/local/etc/$NAME.conf - -for d in "" "/local"; do - rm -vrf \ - $DESTDIR/usr$d/bin/$NAME \ - $DESTDIR/usr$d/bin/$NAME-* \ - $DESTDIR/usr$d/share/doc/$NAME \ - ; - for sd in site dist; do - rm -vrf \ - $DESTDIR/usr$d/lib/python*/$sd-packages/$NAME.* \ - $DESTDIR/usr$d/lib/python*/$sd-packages/$NAME-* \ - $DESTDIR/usr$d/lib/python*/$sd-packages/__pycache__/$NAME.* \ - ; - done -done diff --git a/setup.py b/setup.py index 1fc7424..af53c3e 100644 --- a/setup.py +++ b/setup.py @@ -2,35 +2,35 @@ # Setup script to install this package. # M.Blakeney, Mar 2018. -import re, stat +import stat from pathlib import Path from setuptools import setup +name = 'b2restore' +module = name.replace('-', '_') here = Path(__file__).resolve().parent -name = re.sub(r'-.*', '', here.stem) -readme = here.joinpath('README.md').read_text() executable = stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH setup( name=name, - version='1.9.3', + version='1.9.4', description='Program to recreate Backblaze B2 file archive at' 'specified date+time', - long_description=readme, + long_description=here.joinpath('README.md').read_text(), long_description_content_type='text/markdown', url='https://github.com/bulletmark/{}'.format(name), author='Mark Blakeney', author_email='mark@irsaere.net', keywords='backblaze b2', license='GPLv3', - py_modules=[name], + py_modules=[module], python_requires='>=3.5', classifiers=[ 'Programming Language :: Python :: 3', ], data_files=[ - ('share/doc/{}'.format(name), ['README.md']), + ('share/{}'.format(name), ['README.md']), ], - scripts=[f.name for f in here.iterdir() - if f.is_file() and f.stat().st_mode & executable] + scripts=[f.name for f in here.iterdir() if f.name.startswith(name) + and f.is_file() and f.stat().st_mode & executable], )