feat: prepare PyPi upload

This commit is contained in:
relikd
2023-02-21 20:53:43 +01:00
parent 4e9e70f341
commit f7ea272c7d
8 changed files with 125 additions and 2 deletions

25
.gitignore vendored
View File

@@ -1,2 +1,25 @@
.DS_Store
/env-publish/
__pycache__/ __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

29
Makefile Normal file
View File

@@ -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/*

7
abcddb2vcard/__init__.py Normal file
View File

@@ -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

2
abcddb2vcard/__main__.py Normal file
View File

@@ -0,0 +1,2 @@
#!/usr/bin/env python3
from . import abcddb2vcard # execute sub-module code

View File

@@ -4,9 +4,12 @@ Extract data from AddressBook database (.abcddb) to Contacts VCards file (.vcf)
''' '''
import os import os
import sys import sys
from ABCDDB import ABCDDB
from pathlib import Path from pathlib import Path
from argparse import ArgumentParser 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( DB_FILE = str(Path.home().joinpath(
@@ -41,3 +44,5 @@ with open(args.output, 'w') as f:
for rec in contacts: for rec in contacts:
f.write(rec.makeVCard()) f.write(rec.makeVCard())
print(len(contacts), 'contacts.') print(len(contacts), 'contacts.')
exit()

View File

@@ -51,3 +51,4 @@ for line in args.input.readlines():
fw.write(b64decode(img)) fw.write(b64decode(img))
print(c1, 'contacts.', c2, 'images.') print(c1, 'contacts.', c2, 'images.')
exit()

56
setup.py Normal file
View File

@@ -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',
],
)