Add plugin loader.
This commit is contained in:
parent
429570323e
commit
5b2ab34232
@ -1,11 +1,43 @@
|
|||||||
"""ProtoTorch package."""
|
"""ProtoTorch package."""
|
||||||
|
|
||||||
__version__ = '0.1.1-rc0'
|
# #############################################
|
||||||
|
# Core Setup
|
||||||
|
# #############################################
|
||||||
|
__version_core__ = "0.2.0-dev0"
|
||||||
|
|
||||||
from prototorch import datasets, functions, modules
|
from prototorch import datasets, functions, modules
|
||||||
|
|
||||||
__all__ = [
|
__all_core__ = [
|
||||||
'datasets',
|
"datasets",
|
||||||
'functions',
|
"functions",
|
||||||
'modules',
|
"modules",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# #############################################
|
||||||
|
# Plugin Loader
|
||||||
|
# #############################################
|
||||||
|
import pkg_resources
|
||||||
|
|
||||||
|
|
||||||
|
def discover_plugins():
|
||||||
|
return {
|
||||||
|
entry_point.name: entry_point.load()
|
||||||
|
for entry_point in pkg_resources.iter_entry_points("prototorch.plugins")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
discovered_plugins = discover_plugins()
|
||||||
|
locals().update(discovered_plugins)
|
||||||
|
|
||||||
|
# Generate combines __version__ and __all__
|
||||||
|
__version_plugins__ = "\n".join(
|
||||||
|
[
|
||||||
|
"- " + name + ": v" + plugin.__version__
|
||||||
|
for name, plugin in discovered_plugins.items()
|
||||||
|
]
|
||||||
|
)
|
||||||
|
if __version_plugins__ != "":
|
||||||
|
__version_plugins__ = "\nPlugins: \n" + __version_plugins__
|
||||||
|
|
||||||
|
__version__ = "core: v" + __version_core__ + __version_plugins__
|
||||||
|
__all__ = __all_core__ + list(discovered_plugins.keys())
|
113
setup.py
113
setup.py
@ -1,8 +1,42 @@
|
|||||||
"""Install ProtoTorch."""
|
"""
|
||||||
|
_____ _ _______ _
|
||||||
|
| __ \ | | |__ __| | |
|
||||||
|
| |__) | __ ___ | |_ ___ | | ___ _ __ ___| |__
|
||||||
|
| ___/ '__/ _ \| __/ _ \| |/ _ \| '__/ __| '_ \
|
||||||
|
| | | | | (_) | || (_) | | (_) | | | (__| | | |
|
||||||
|
|_| |_| \___/ \__\___/|_|\___/|_| \___|_| |_|
|
||||||
|
|
||||||
|
ProtoTorch Core Package
|
||||||
|
"""
|
||||||
|
|
||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools import find_packages
|
from setuptools import find_packages
|
||||||
|
|
||||||
|
from pkg_resources import safe_name
|
||||||
|
|
||||||
|
import ast
|
||||||
|
import importlib.util
|
||||||
|
|
||||||
|
PKG_DIR = "prototorch"
|
||||||
|
|
||||||
|
|
||||||
|
def find_version():
|
||||||
|
"""Return value of __version__.
|
||||||
|
|
||||||
|
Reference: https://stackoverflow.com/a/42269185/
|
||||||
|
"""
|
||||||
|
file_path = importlib.util.find_spec(PKG_DIR).origin
|
||||||
|
with open(file_path) as file_obj:
|
||||||
|
root_node = ast.parse(file_obj.read())
|
||||||
|
for node in ast.walk(root_node):
|
||||||
|
if isinstance(node, ast.Assign):
|
||||||
|
if len(node.targets) == 1 and node.targets[0].id == "__version_core__":
|
||||||
|
return node.value.s
|
||||||
|
raise RuntimeError("Unable to find version string.")
|
||||||
|
|
||||||
|
|
||||||
|
version = find_version()
|
||||||
|
|
||||||
PROJECT_URL = "https://github.com/si-cim/prototorch"
|
PROJECT_URL = "https://github.com/si-cim/prototorch"
|
||||||
DOWNLOAD_URL = "https://github.com/si-cim/prototorch.git"
|
DOWNLOAD_URL = "https://github.com/si-cim/prototorch.git"
|
||||||
|
|
||||||
@ -32,40 +66,43 @@ EXAMPLES = [
|
|||||||
TESTS = ["pytest"]
|
TESTS = ["pytest"]
|
||||||
ALL = DOCS + DATASETS + EXAMPLES + TESTS
|
ALL = DOCS + DATASETS + EXAMPLES + TESTS
|
||||||
|
|
||||||
setup(name="prototorch",
|
setup(
|
||||||
version="0.1.1-rc0",
|
name=safe_name(PKG_DIR),
|
||||||
description="Highly extensible, GPU-supported "
|
version=version,
|
||||||
"Learning Vector Quantization (LVQ) toolbox "
|
description="Highly extensible, GPU-supported "
|
||||||
"built using PyTorch and its nn API.",
|
"Learning Vector Quantization (LVQ) toolbox "
|
||||||
long_description=long_description,
|
"built using PyTorch and its nn API.",
|
||||||
long_description_content_type="text/markdown",
|
long_description=long_description,
|
||||||
author="Jensun Ravichandran",
|
long_description_content_type="text/markdown",
|
||||||
author_email="jjensun@gmail.com",
|
author="Jensun Ravichandran",
|
||||||
url=PROJECT_URL,
|
author_email="jjensun@gmail.com",
|
||||||
download_url=DOWNLOAD_URL,
|
url=PROJECT_URL,
|
||||||
license="MIT",
|
download_url=DOWNLOAD_URL,
|
||||||
install_requires=INSTALL_REQUIRES,
|
license="MIT",
|
||||||
extras_require={
|
install_requires=INSTALL_REQUIRES,
|
||||||
"docs": DOCS,
|
extras_require={
|
||||||
"datasets": DATASETS,
|
"docs": DOCS,
|
||||||
"examples": EXAMPLES,
|
"datasets": DATASETS,
|
||||||
"tests": TESTS,
|
"examples": EXAMPLES,
|
||||||
"all": ALL,
|
"tests": TESTS,
|
||||||
},
|
"all": ALL,
|
||||||
classifiers=[
|
},
|
||||||
"Development Status :: 2 - Pre-Alpha",
|
classifiers=[
|
||||||
"Environment :: Console",
|
"Development Status :: 2 - Pre-Alpha",
|
||||||
"Intended Audience :: Developers",
|
"Environment :: Console",
|
||||||
"Intended Audience :: Education",
|
"Intended Audience :: Developers",
|
||||||
"Intended Audience :: Science/Research",
|
"Intended Audience :: Education",
|
||||||
"License :: OSI Approved :: MIT License",
|
"Intended Audience :: Science/Research",
|
||||||
"Natural Language :: English",
|
"License :: OSI Approved :: MIT License",
|
||||||
"Programming Language :: Python :: 3.6",
|
"Natural Language :: English",
|
||||||
"Programming Language :: Python :: 3.7",
|
"Programming Language :: Python :: 3.6",
|
||||||
"Programming Language :: Python :: 3.8",
|
"Programming Language :: Python :: 3.7",
|
||||||
"Operating System :: OS Independent",
|
"Programming Language :: Python :: 3.8",
|
||||||
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
"Operating System :: OS Independent",
|
||||||
"Topic :: Software Development :: Libraries",
|
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
||||||
"Topic :: Software Development :: Libraries :: Python Modules",
|
"Topic :: Software Development :: Libraries",
|
||||||
],
|
"Topic :: Software Development :: Libraries :: Python Modules",
|
||||||
packages=find_packages())
|
],
|
||||||
|
packages=find_packages(),
|
||||||
|
zip_safe=False,
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user