From f7ea272c7d2cbeeee1bb44cfedce9a0ac1909470 Mon Sep 17 00:00:00 2001 From: relikd Date: Tue, 21 Feb 2023 20:53:43 +0100 Subject: [PATCH] feat: prepare PyPi upload --- .gitignore | 25 ++++++++- Makefile | 29 ++++++++++ ABCDDB.py => abcddb2vcard/ABCDDB.py | 0 abcddb2vcard/__init__.py | 7 +++ abcddb2vcard/__main__.py | 2 + .../abcddb2vcard.py | 7 ++- vcard2image.py => abcddb2vcard/vcard2img.py | 1 + setup.py | 56 +++++++++++++++++++ 8 files changed, 125 insertions(+), 2 deletions(-) create mode 100644 Makefile rename ABCDDB.py => abcddb2vcard/ABCDDB.py (100%) create mode 100644 abcddb2vcard/__init__.py create mode 100644 abcddb2vcard/__main__.py rename abcddb2vcard.py => abcddb2vcard/abcddb2vcard.py (89%) rename vcard2image.py => abcddb2vcard/vcard2img.py (99%) create mode 100644 setup.py diff --git a/.gitignore b/.gitignore index 5155e00..6de22df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,25 @@ +.DS_Store +/env-publish/ + __pycache__/ -*.DS_Store +*.py[cod] + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..62930f9 --- /dev/null +++ b/Makefile @@ -0,0 +1,29 @@ +.PHONY: install +install: + [ -z "$${VIRTUAL_ENV}" ] \ + && python3 -m pip install -e . --user \ + || python3 -m pip install -e . + +.PHONY: uninstall +uninstall: + python3 -m pip uninstall abcddb2vcard + rm -rf ./*.egg-info/ + -rm -i "$$(which abcddb2vcard)" "$$(which vcard2img)" + +dist: setup.py abcddb2vcard/* + [ -z "$${VIRTUAL_ENV}" ] # you can not do this inside a virtual environment. + @echo Building... + python3 setup.py sdist bdist_wheel + rm -rf ./*.egg-info/ ./build/ MANIFEST + +env-publish: + @echo Creating virtual environment... + @python3 -m venv 'env-publish' + @source env-publish/bin/activate && pip install twine + +.PHONY: publish +publish: dist env-publish + [ -z "$${VIRTUAL_ENV}" ] # you can not do this inside a virtual environment. + @echo Publishing... + @echo "\033[0;31mEnter PyPI token in password prompt:\033[0m" + @source env-publish/bin/activate && export TWINE_USERNAME='__token__' && twine upload dist/* diff --git a/ABCDDB.py b/abcddb2vcard/ABCDDB.py similarity index 100% rename from ABCDDB.py rename to abcddb2vcard/ABCDDB.py diff --git a/abcddb2vcard/__init__.py b/abcddb2vcard/__init__.py new file mode 100644 index 0000000..f8554f4 --- /dev/null +++ b/abcddb2vcard/__init__.py @@ -0,0 +1,7 @@ +#!/usr/bin/env python3 +''' +Convert AddressBook database (.abcddb) to Contacts VCards file (.vcf) +''' +__version__ = '1.0.0' + +from .ABCDDB import ABCDDB diff --git a/abcddb2vcard/__main__.py b/abcddb2vcard/__main__.py new file mode 100644 index 0000000..ed0e1b7 --- /dev/null +++ b/abcddb2vcard/__main__.py @@ -0,0 +1,2 @@ +#!/usr/bin/env python3 +from . import abcddb2vcard # execute sub-module code diff --git a/abcddb2vcard.py b/abcddb2vcard/abcddb2vcard.py similarity index 89% rename from abcddb2vcard.py rename to abcddb2vcard/abcddb2vcard.py index 81c8467..e0711e5 100755 --- a/abcddb2vcard.py +++ b/abcddb2vcard/abcddb2vcard.py @@ -4,9 +4,12 @@ Extract data from AddressBook database (.abcddb) to Contacts VCards file (.vcf) ''' import os import sys -from ABCDDB import ABCDDB from pathlib import Path from argparse import ArgumentParser +try: + from .ABCDDB import ABCDDB +except ImportError: # fallback if not run as module + from ABCDDB import ABCDDB # type: ignore[import, no-redef] DB_FILE = str(Path.home().joinpath( @@ -41,3 +44,5 @@ with open(args.output, 'w') as f: for rec in contacts: f.write(rec.makeVCard()) print(len(contacts), 'contacts.') + +exit() diff --git a/vcard2image.py b/abcddb2vcard/vcard2img.py similarity index 99% rename from vcard2image.py rename to abcddb2vcard/vcard2img.py index 16c9685..22c64fe 100755 --- a/vcard2image.py +++ b/abcddb2vcard/vcard2img.py @@ -51,3 +51,4 @@ for line in args.input.readlines(): fw.write(b64decode(img)) print(c1, 'contacts.', c2, 'images.') +exit() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..95f9425 --- /dev/null +++ b/setup.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +from setuptools import setup +from abcddb2vcard import __doc__, __version__ + +with open('README.md') as fp: + longdesc = fp.read() + +setup( + name='abcddb2vcard', + description=__doc__.strip(), + version=__version__, + author='relikd', + url='https://github.com/relikd/abcddb2vcard', + license='MIT', + packages=['abcddb2vcard'], + entry_points={ + 'console_scripts': [ + 'abcddb2vcard=abcddb2vcard.abcddb2vcard', + 'vcard2img=abcddb2vcard.vcard2img', + ] + }, + long_description_content_type="text/markdown", + long_description=longdesc, + python_requires='>=3.5', + keywords=[ + 'abcddb', + 'abcd', + 'address book', + 'vcard', + 'contacts', + 'converter', + 'export', + 'backup', + ], + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Environment :: MacOS X', + 'License :: OSI Approved :: MIT License', + 'Operating System :: OS Independent', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: SQL', + 'Topic :: Communications :: Email :: Address Book', + 'Topic :: Software Development :: Libraries :: Python Modules', + 'Topic :: System :: Archiving :: Backup', + 'Topic :: Utilities', + ], +)