Index: html/bind.html ================================================================== --- html/bind.html +++ html/bind.html @@ -99,11 +99,11 @@

Module should be a package, as in a directory and init plugins/__init__.py. Ideally this module was already imported in main. But parameter may be a string.

This could be invoked multiple times for the package name to append further path= arguments (=./contrib/, =/usr/share/app/extenstions/, or a .pyz). Which -is functionally identical to delcaring __path__ in the package/__init__.py.

+is functionally identical to declaring __path__ in the package/__init__.py.

def defaults(conf)
Index: html/setup.html ================================================================== --- html/setup.html +++ html/setup.html @@ -29,22 +29,10 @@

Functions

-
-def get_readme() -
-
-

get README.md contents

-
-
-def name_to_fn(name) -
-
-

find primary entry point.py from package name

-
def setup(filename=None, debug=False, **kwargs)

Wrapper around setuptools.setup() which adds some defaults @@ -99,10 +87,22 @@ def datafiles_man()

data_files=

+
+def get_readme(prefix='long_') +
+
+

get README.md contents

+
+
+def name_to_fn(name) +
+
+

find primary entry point.py from package name

+

Methods

def classifiers(self) @@ -133,11 +133,11 @@

depends: python:module, pip:module

-def plugin_doc(self) +def plugin_doc(self, prefix='long_')

use comment block

@@ -180,12 +180,10 @@
  • pluginconf
  • Functions

  • Classes

      @@ -195,11 +193,13 @@
    • classifiers
    • datafiles_man
    • entry_points
    • extras_require
    • get_keywords
    • +
    • get_readme
    • install_requires
    • +
    • name_to_fn
    • plugin_doc
    • project_urls
    • python_requires
    • trove_license
    • trove_status
    • Index: pluginconf/__init__.py ================================================================== --- pluginconf/__init__.py +++ pluginconf/__init__.py @@ -2,11 +2,11 @@ # api: python ##type: extract # category: config # title: Plugin configuration # description: Read meta data, pyz/package contents, module locating -# version: 0.8.0 +# version: 0.8.1 # state: stable # classifiers: documentation # depends: python >= 2.7 # suggests: python:flit, python:PySimpleGUI # license: PD Index: pluginconf/bind.py ================================================================== --- pluginconf/bind.py +++ pluginconf/bind.py @@ -169,11 +169,11 @@ Module should be a package, as in a directory and init `plugins/__init__.py`. Ideally this module was already imported in main. But parameter may be a string. This could be invoked multiple times for the package name to append further path= arguments (=./contrib/, =/usr/share/app/extenstions/, or a .pyz). Which - is functionally identical to delcaring `__path__` in the `package/__init__.py`. + is functionally identical to declaring `__path__` in the `package/__init__.py`. """ # if supplied as string, instead of active module if isinstance(module, str): module = sys.modules.get(module) or __import__(module) Index: pluginconf/flit.py ================================================================== --- pluginconf/flit.py +++ pluginconf/flit.py @@ -153,15 +153,13 @@ "provides_extra": [], } #print(meta) # comment/readme - for docs in pmd.plugin_doc(), psetup.get_readme(): - if docs["long_description"]: - meta.update({ # with "long_" prefix cut off - key[5:]: value for key, value in docs.items() - }) + for docs in pmd.plugin_doc(prefix=""), pmd.get_readme(prefix=""): + if docs["description"]: + meta.update(docs) # entry_points are in ini file for section, entries in pmd.entry_points().items(): ini.entrypoints[section] = ini.entrypoints.get(section, {}) for script in entries: Index: pluginconf/setup.py ================================================================== --- pluginconf/setup.py +++ pluginconf/setup.py @@ -52,45 +52,47 @@ import glob import pprint import pluginconf -def name_to_fn(name): - """ find primary entry point.py from package name """ - for pfx in "", "src/", "src/"+name+"/": - for sfx in ".py", "/__init__.py": - if os.path.exists(pfx+name+sfx): - return pfx+name+sfx - return "" - -def get_readme(): - """ get README.md contents """ - for filename, mime in ("README.md", "text/markdown"), ("README.rst", "text/x-rst"), ("README.txt", "text/plain"): - if os.path.exists(filename): - with open(filename, "r") as read: - return { - "long_description": read.read(), - "long_description_content_type": mime, - } - return { - "long_description": "", - "long_description_content_type": "text/plain", - } - class MetaUtils(dict): """ Convenience access to PMD fields and conversion functions """ def __getattr__(self, name): """ dict into properties """ return self.get(name, "") - def plugin_doc(self): + @staticmethod + def name_to_fn(name): + """ find primary entry point.py from package name """ + for pfx in "", "src/", "src/"+name+"/": + for sfx in ".py", "/__init__.py": + if os.path.exists(pfx+name+sfx): + return pfx+name+sfx + return "" + + @staticmethod + def get_readme(prefix="long_"): + """ get README.md contents """ + for filename, mime in ("README.md", "text/markdown"), ("README.rst", "text/x-rst"), ("README.txt", "text/plain"): + if os.path.exists(filename): + with open(filename, "r") as read: + return { + prefix+"description": read.read(), + prefix+"description_content_type": mime, + } + return { + prefix+"description": "", + prefix+"description_content_type": "text/plain", + } + + def plugin_doc(self, prefix="long_"): """ use comment block """ return { - "long_description": self.doc, - "long_description_content_type": self.doc_format or "text/plain" + prefix+"description": self.doc, + prefix+"description_content_type": self.doc_format or "text/plain" } def python_requires(self): """ depends: python >= 3.5 """ deps = re.findall(r"python\s*\(?(>=?\s?[\d.]+)", self.get("depends", "")) @@ -236,17 +238,14 @@ # package name if "name" not in kwargs and kwargs.get("packages"): kwargs["name"] = kwargs["packages"][0] - # read README if field empty or says `@README` - if re.match("^$|^[@./]*README.{0,5}$", kwargs.get("long_description", "")): - kwargs.update(get_readme()) # search name= package if no filename= given if not filename and kwargs.get("name"): - filename = name_to_fn(kwargs["name"]) + filename = MetaUtils.name_to_fn(kwargs["name"]) # read plugin meta data (PMD) pmd = MetaUtils( pluginconf.plugin_meta(filename=filename) ) @@ -270,10 +269,13 @@ if "depends" in pmd and not kwargs["install_requires"]: kwargs["install_requires"] = pmd.install_requires() # suggests: if "suggests" in pmd and not kwargs["extras_require"]: kwargs["extras_require"].update(pmd.extras_require()) + # read README if field empty or says `@README` + if re.match("^$|^[@./]*README.{0,5}$", kwargs.get("long_description", "")): + kwargs.update(pmd.get_readme()) # doc: if not kwargs.get("long_description"): kwargs.update(pmd.plugin_doc()) # keywords=