#!/usr/bin/env python

# Template File:  "/bisos/apps/defaults/begin/templates/purposed/pyModule/python/setup.py"
# Blee Panel: /bisos/git/auth/bxRepos/blee-binders/bisos-core/bisos-pip/bisos.pycs/pipPackaging/_nodeBase_/fullUsagePanel-en.org

# b:py3:pypi:setup/pkgName Arguments  :pkgName "somePkg" :pkgNameSpace "bisos"
####+BEGINNOT: b:py3:pypi:setup/pkgName :comment "Not Auto Detected" :pkgName "graphviz" :pkgNameSpace "bisos"

import setuptools
import re
import inspect
import pathlib

def pkgName():
        return 'bisos.graphviz'

def description():
    ''' Extract title from ./_description.org which is expected to have a title: line. '''
    try:
        with open('./_description.org') as file:
            while line := file.readline():
                if match := re.search(r'^#\+title: (.*)',  line.rstrip()):
                    return match.group(1)
                return 'MISSING TITLE in ./_description.org'
    except IOError:
        return  'ERROR: Could not read ./_description.org file.'

def longDescription():
    ''' Convert _description.org to .rst. '''
    result = ""
    try:
        with open('./README.rst') as file:
            while line := file.readline():
                result = result + line
        return result
    except IOError:
        return  'ERROR: Could not read ./_description.org file.'

####+END:


# b:py3:pypi:setup/version Arguments  :forSys t :forPyPi t :constant "666"
####+BEGIN: b:py3:pypi:setup/version :comment "Auto Detected"

# ./pypiUploadVer EXISTED -- forPypiVersion=0.17 -- forSysVersion=0.17 -- constant=NA
def pkgVersion():
        return '0.17'

####+END:

####+BEGIN: b:py3:pypi:setup/requires :extras ()

requires = [
"blee",
"blee.icmPlayer",
"bisos",
"bisos.b",
"bisos.common",
]
####+END:

####+BEGIN: b:py3:pypi:setup/scripts :comment ""

scripts = [
'./bin/exmpl-graphviz.cs',
'./bin/seedGraphviz.cs',
]
####+END:

#
# Data files would be  specified in ./MANIFEST.in as: # recursive-include bisos/pkgName *
#

data_files = [
]

# :pkgName "--auto--"  --- results in use of name=pkgName(),
####+BEGIN: b:py3:pypi:setup/funcArgs :comment "defaults to --auto--"

setuptools.setup(
    name=pkgName(),  # bisos.graphviz
    version=pkgVersion(),
    packages=setuptools.find_packages(),
    scripts=scripts,
    #data_files=data_files,
    include_package_data=True,
    zip_safe=False,
    author='Mohsen Banan',
    author_email='libre@mohsen.1.banan.byname.net',
    maintainer='Mohsen Banan',
    maintainer_email='libre@mohsen.1.banan.byname.net',
    url='http://www.by-star.net/PLPC/180047',
    license='AGPL',
    description=description(),
    long_description=longDescription(),
    download_url='http://www.by-star.net/PLPC/180047',
    install_requires=requires,
    classifiers=[
        'Development Status :: 5 - Production/Stable',
        'Intended Audience :: Developers',
        'License :: OSI Approved :: GNU Affero General Public License v3',
        'Operating System :: POSIX',
        'Programming Language :: Python',
        'Topic :: Software Development :: Libraries',
        'Topic :: Software Development :: Libraries :: Python Modules',
        ]
    )

####+END:
