Skip to content

Commit

Permalink
added pypi packaging support and a version number scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
0xabu committed Aug 11, 2021
1 parent 9c05366 commit 33fb82b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
14 changes: 9 additions & 5 deletions pdfannots.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import pdfminer.settings
import pdfminer.utils

__version__ = '0.1'

pdfminer.settings.STRICT = False

SUBSTITUTIONS = {
Expand Down Expand Up @@ -563,9 +565,11 @@ def process_file(fh, emit_progress=False):
return (allannots, outlines)


def parse_args(argv):
def parse_args():
p = argparse.ArgumentParser(description=__doc__)

p.add_argument('--version', action='version', version='%(prog)s ' + __version__)

p.add_argument("input", metavar="INFILE", type=argparse.FileType("rb"),
help="PDF files to process", nargs='+')

Expand All @@ -591,11 +595,11 @@ def parse_args(argv):
g.add_argument("-w", "--wrap", metavar="COLS", type=int,
help="wrap text at this many output columns")

return p.parse_args(argv)
return p.parse_args()


def main(argv):
args = parse_args(argv)
def main():
args = parse_args()

global COLUMNS_PER_PAGE
COLUMNS_PER_PAGE = args.cols
Expand All @@ -615,4 +619,4 @@ def main(argv):


if __name__ == "__main__":
main(sys.argv[1:])
main()
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# pip requirements for pdfannots
# Use as: pip3 install -r requirements.txt

pdfminer.six == 20201018
pdfminer.six == 20201018
31 changes: 30 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,42 @@
from setuptools import setup
import os.path
import pathlib

here = pathlib.Path(__file__).parent.resolve()

def get_version_from_file(filename):
with open(here / filename, 'r') as fh:
for line in fh.readlines():
if line.startswith('__version__'):
delim = '"' if '"' in line else "'"
return line.split(delim)[1]

raise RuntimeError("Unable to find version string in " + filename)

def main():
name = 'pdfannots'
setup(
name=name,
version=get_version_from_file(name + '.py'),
description='Tool to extract PDF annotations as markdown for reviewing',
long_description=(here/'README.md').read_text(),
long_description_content_type='text/markdown',
url='https://github.com/0xabu/pdfannots',
classifiers=[
'Intended Audience :: Science/Research',
'Topic :: Text Processing',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3',
],
zip_safe=False,
py_modules=[name],
install_requires=open('requirements.txt').read().splitlines(),
entry_points={
'console_scripts': [
'pdfannots=pdfannots:main',
],
},
python_requires='>=3',
install_requires=['pdfminer.six'],
)


Expand Down

0 comments on commit 33fb82b

Please sign in to comment.