Overview
Comment: | update commentary, force dynamic= fields, skip field if set via ini, adapt to .setup changes |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
ff3080056a273c2d13f46f94e803fbaa |
User & Date: | mario on 2022-10-28 07:11:51 |
Other Links: | manifest | tags |
Context
2022-10-28
| ||
07:14 | update docs check-in: 3f778d96b7 user: mario tags: trunk | |
07:11 | update commentary, force dynamic= fields, skip field if set via ini, adapt to .setup changes check-in: ff3080056a user: mario tags: trunk | |
07:09 | depends version cleanup, fixate filename= instead of fn=, drop nested Util results check-in: 1cd99def48 user: mario tags: trunk | |
Changes
Modified pluginconf/flit.py from [dff91eb86b] to [3f2ace3082].
1 2 3 4 | # encoding: utf-8 # api: pep517 # title: flit backend # description: wraps flit_core.buildapi | | < | | < | | | | | > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | # encoding: utf-8 # api: pep517 # title: flit backend # description: wraps flit_core.buildapi # version: 0.3 # depends: python:flit (>=3.0, <4.0) # license: BSD-3-Clause # priority: extra # pylint: disable=unused-import, wrong-import-position, wrong-import-order # # As alternative to pluginconf.setup, this module is using flit as # pep517 build backend. But adding automagic field lookup of course. # # It can be invoked per `flit-pluginconfig build` and advises # a `pyproject.toml` like: # # [build-system] # requires = ["pluginconf>=0.8", "flit>=3.2", "setuptools"] # build-backend = "pluginconf.flit" # # [project] # name = "foobar" # dynamic = ["version", "description"] # # Injecting attributes between ini reading and parameter collection # turned out easier than expanding on flit_core.buildapi functions. # And lastly, this just chains to flit.main() to handle collect and # build tasks. # # Dynamic handling currently violates all the package tool requirements: # <https://packaging.python.org/en/latest/specifications/declaring-project-metadata/#dynamic> # But it does have some interesting side effects. # * mixes the override text and file inclusion # license = { file = "LICENSE" } # * for setuptools compat a long dynamic field is required (but flit hates it) # dynamic = ["version", "description", "readme", "requires-python", # "license", "keywords", "classifiers", "urls", "entry-points"] # Not sure yet if the pyproject.toml specs allow for reconcilation here. # """ monkeypatches flint to use pluginconf sources for packaging """ import sys import re |
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 | """ monkeypatch into module """ def wrapped(func): setattr(where, func.__name__, func) wrapped.__doc__ = func.__doc__ return func return wrapped @inject(flit_core.config) def read_flit_config(path): | > | | < | > < | > | | | | | | | | | | | | < | | > > | > > > > > | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 | """ monkeypatch into module """ def wrapped(func): setattr(where, func.__name__, func) wrapped.__doc__ = func.__doc__ return func return wrapped # patch_flit_config @inject(flit_core.config) def read_flit_config(path): """ @inject patch_flit_config() with forced dynamic fields """ ini = flit_core.config.tomli.loads(path.read_text('utf-8')) # make fields dynamic (exactly the fields flit allows) ini["project"]["dynamic"] = ["version", "description"] # maybe also record orig list to omit from pmd_meta update? (in addition to ini.MD.get check) for dyn in ['description', 'version']: if dyn in ini["project"]: del ini["project"][dyn] if not dyn in ini["project"]["dynamic"]: ini["project"]["dynamic"].append(dyn) # turn it into LoadedConfig return flit_core.config.prep_toml_config(ini, path) # patch_metadata @inject(flit_core.common) def make_metadata(module, ini_info): """ @inject different sourcing order to apply plugin meta fields """ meta = { "name": module.name, "provides": [module.name] } meta.update(ini_info.metadata) meta.update( pmd_meta( pluginconf.plugin_meta(filename=module.file), ini_info ) ) if not meta.get("version"): meta.update( flit_core.common.get_info_from_module(module.file, ['version']) ) #print(meta) return flit_core.common.Metadata(meta) # map plugin meta to flit Metadata def pmd_meta(pmd, ini): """ enjoin PMD fields with flit.common.MetaData """ pmd = psetup.MetaUtils(pmd) meta = { "summary": pmd.description, "version": pmd.version, "home_page": pmd.url, "author": pmd.author, # should split this into mail and name "author_email": None, "maintainer": None, "maintainer_email": None, "license": pmd.license, # {name=…} "keywords": pmd.get_keywords(), "download_url": None, "requires_python": pmd.python_requires(), "platform": [], "supported_platform": pmd.architecture, "classifiers": list(pmd.classifiers()) + pmd.trove_license() + pmd.trove_status(), "provides": [], "requires": [], # supposed to override requires_dist if present "obsoletes": [], "project_urls": [f"{k}, {v}" for k, v in pmd.project_urls().items()], "provides_dist": [], "requires_dist": pmd.install_requires() or [], "obsoletes_dist": [], "requires_external": [], "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() }) # 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: ini.entrypoints[section].update( dict(re.findall("(.+)=(.+)", script)) ) #print(ini.entrypoints) #print(dir(ini)) #print((ini.metadata)) # strip empty entries return { key: value for key, value in meta.items() if value and not ini.metadata.get(key) #? } #-- buildapi from flit_core.buildapi import ( # These have to be late imports; else they'll get_requires_for_build_wheel, # bind with the original buildapi functions. get_requires_for_build_sdist, get_requires_for_build_editable, prepare_metadata_for_build_wheel, prepare_metadata_for_build_editable, build_wheel, build_editable, build_sdist, ) del inject # omit from docs #-- invocation point from flit import main if __name__ == "__main__": main(sys.argv) |