From 1a454d573b90ff7c3391b89231d68c7e453aa7fd Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Thu, 19 Nov 2026 18:19:14 +0100 Subject: [PATCH] Generate CITATION.cff from codemeta.json CITATION.cff listed only the authors of the 2008 article, with the wrong year (the article was published in January 2009), although its type is "software". It is now generated from codemeta.json by tools/codemeta2cff.py, with all the contributors, the RRID, and the article as the preferred citation. --- CITATION.cff | 163 +++++++++++++++++++++++++++++------------- codemeta.json | 62 +++++++++++++++- tools/codemeta2cff.py | 136 +++++++++++++++++++++++++++++++++++ 3 files changed, 310 insertions(+), 51 deletions(-) create mode 100644 tools/codemeta2cff.py diff --git a/CITATION.cff b/CITATION.cff index 28f862c2..19213194 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -1,55 +1,118 @@ -cff-version: 1.2.0 -message: If you use this software, please cite the accompanying publication (preferred-citation below). -type: software -title: 'PyNN: A Common Interface for Neuronal Network Simulators' +# This file is generated from codemeta.json by tools/codemeta2cff.py. Do not edit it. +cff-version: "1.2.0" +message: "If you use PyNN in your work, please cite the article given in preferred-citation, and give its Research Resource Identifier (RRID:SCR_002715)." +type: "software" +title: "PyNN" +abstract: "PyNN (pronounced 'pine') is a simulator-independent language for building neuronal network models." authors: -- family-names: Davison - given-names: Andrew P -- family-names: Bruderle - given-names: Daniel -- family-names: Eppler - given-names: Jochen -- family-names: Kremkow - given-names: Jens -- family-names: Muller - given-names: Eilif -- family-names: Pecevski - given-names: Dejan -- family-names: Perrinet - given-names: Laurent U - orcid: https://orcid.org/0000-0002-9536-010X -- family-names: Yger - given-names: Pierre -repository-code: https://github.com/NeuralEnsemble/PyNN +- given-names: "Andrew P." + family-names: "Davison" + orcid: "https://orcid.org/0000-0002-4793-7541" +- given-names: "Pierre" + family-names: "Yger" +- given-names: "Eilif" + family-names: "Muller" +- given-names: "Jens" + family-names: "Kremkow" +- given-names: "Daniel" + family-names: "Brüderle" +- given-names: "Laurent" + family-names: "Perrinet" + orcid: "https://orcid.org/0000-0002-9536-010X" +- given-names: "Jochen" + family-names: "Eppler" +- given-names: "Dejan" + family-names: "Pecevski" +- given-names: "Nicolas" + family-names: "Debeissat" +- given-names: "Mikael" + family-names: "Djurfeldt" +- given-names: "Michael" + family-names: "Schmuker" +- given-names: "Bernhard" + family-names: "Kaplan" +- given-names: "Thomas" + family-names: "Natschlaeger" +- given-names: "Subhasis" + family-names: "Ray" +- given-names: "Yury" + family-names: "Zaytsev" +- given-names: "Ján" + family-names: "Antolík" +- given-names: "Alexandre" + family-names: "Gravier" +- given-names: "Thomas" + family-names: "Close" +- given-names: "Oliver" + family-names: "Breitwieser" +- given-names: "Jannis" + family-names: "Schücker" +- given-names: "Maximilian" + family-names: "Schmidt" +- given-names: "Christian" + family-names: "Roessert" +- given-names: "Shailesh" + family-names: "Appukuttan" +- given-names: "Elodie" + family-names: "Legouée" +- given-names: "Joffrey" + family-names: "Gonin" +- given-names: "Ankur" + family-names: "Sinha" +- given-names: "Håkon" + family-names: "Mørk" +- given-names: "Andrei" + family-names: "Moise" +- given-names: "Onur" + family-names: "Ates" +- given-names: "Rémy" + family-names: "Cagnol" +- given-names: "Lungsi" + family-names: "Sharma" +- given-names: "Alexandre" + family-names: "Detiste" +- given-names: "Charl A.P." + family-names: "Linssen" +- given-names: "Tom" + family-names: "Gilke" +- given-names: "Goran" + family-names: "Jelic-Cizmek" +version: "0.13.0" +license: "CECILL-2.1" +repository-code: "https://github.com/NeuralEnsemble/PyNN" +identifiers: +- type: "other" + value: "RRID:SCR_002715" + description: "Research Resource Identifier" keywords: -- neural-simulation -- neuromorphic-computing -- pynn -- spiking-neural-networks +- "neural simulation" +- "neuromorphic computing" +- "spiking neural networks" preferred-citation: - type: article - title: 'PyNN: A Common Interface for Neuronal Network Simulators' + type: "article" + title: "PyNN: A Common Interface for Neuronal Network Simulators" authors: - - family-names: Davison - given-names: Andrew P - - family-names: Bruderle - given-names: Daniel - - family-names: Eppler - given-names: Jochen - - family-names: Kremkow - given-names: Jens - - family-names: Muller - given-names: Eilif - - family-names: Pecevski - given-names: Dejan - - family-names: Perrinet - given-names: Laurent U - orcid: https://orcid.org/0000-0002-9536-010X - - family-names: Yger - given-names: Pierre - journal: Frontiers in Neuroinformatics + - given-names: "Andrew P." + family-names: "Davison" + orcid: "https://orcid.org/0000-0002-4793-7541" + - given-names: "Daniel" + family-names: "Brüderle" + - given-names: "Jochen" + family-names: "Eppler" + - given-names: "Jens" + family-names: "Kremkow" + - given-names: "Eilif" + family-names: "Muller" + - given-names: "Dejan" + family-names: "Pecevski" + - given-names: "Laurent" + family-names: "Perrinet" + orcid: "https://orcid.org/0000-0002-9536-010X" + - given-names: "Pierre" + family-names: "Yger" + journal: "Frontiers in Neuroinformatics" volume: 2 - start: '11' - doi: 10.3389/neuro.11.011.2008 - year: 2008 - url: https://laurentperrinet.github.io/publication/davison-08/ + start: "11" + year: 2009 + month: 1 + doi: "10.3389/neuro.11.011.2008" diff --git a/codemeta.json b/codemeta.json index fb3d3ab2..4c6c02ee 100644 --- a/codemeta.json +++ b/codemeta.json @@ -15,11 +15,70 @@ "releaseNotes": "http://neuralensemble.org/docs/PyNN/releases/0.13.0.html", "funding": "https://cordis.europa.eu/project/id/945539", "developmentStatus": "active", - "referencePublication": "https://doi.org/10.3389/neuro.11.011.2008", + "referencePublication": { + "@type": "ScholarlyArticle", + "@id": "https://doi.org/10.3389/neuro.11.011.2008", + "name": "PyNN: A Common Interface for Neuronal Network Simulators", + "author": [ + { + "@type": "Person", + "@id": "https://orcid.org/0000-0002-4793-7541", + "givenName": "Andrew P.", + "familyName": "Davison" + }, + { + "@type": "Person", + "givenName": "Daniel", + "familyName": "Brüderle" + }, + { + "@type": "Person", + "givenName": "Jochen", + "familyName": "Eppler" + }, + { + "@type": "Person", + "givenName": "Jens", + "familyName": "Kremkow" + }, + { + "@type": "Person", + "givenName": "Eilif", + "familyName": "Muller" + }, + { + "@type": "Person", + "givenName": "Dejan", + "familyName": "Pecevski" + }, + { + "@type": "Person", + "@id": "https://orcid.org/0000-0002-9536-010X", + "givenName": "Laurent", + "familyName": "Perrinet" + }, + { + "@type": "Person", + "givenName": "Pierre", + "familyName": "Yger" + } + ], + "datePublished": "2009-01-27", + "isPartOf": { + "@type": "PublicationVolume", + "volumeNumber": "2", + "isPartOf": { + "@type": "Periodical", + "name": "Frontiers in Neuroinformatics" + } + }, + "pagination": "11" + }, "funder": { "@type": "Organization", "name": "European Commission" }, + "keywords": ["neural simulation", "neuromorphic computing", "spiking neural networks"], "programmingLanguage": ["Python"], "operatingSystem": ["Linux", "Windows", "macOS"], "softwareRequirements": [ @@ -59,6 +118,7 @@ }, { "@type": "Person", + "@id": "https://orcid.org/0000-0002-9536-010X", "givenName": "Laurent", "familyName": "Perrinet" }, diff --git a/tools/codemeta2cff.py b/tools/codemeta2cff.py new file mode 100644 index 00000000..8fc80aaf --- /dev/null +++ b/tools/codemeta2cff.py @@ -0,0 +1,136 @@ +""" +Generate CITATION.cff from codemeta.json. + +codemeta.json is the source of the software metadata; CITATION.cff is generated from it, +so that GitHub can show "Cite this repository". Run from the root of the repository: + + python tools/codemeta2cff.py # write CITATION.cff + python tools/codemeta2cff.py --check # exit with an error if CITATION.cff is out of date + +Only the standard library is used. The YAML is written by hand: all strings are written +as JSON strings, which are valid YAML double-quoted scalars. + +:copyright: Copyright 2006-2026 by the PyNN team, see AUTHORS. +:license: CeCILL, see LICENSE for details. +""" + +import argparse +import json +import sys +from pathlib import Path + +CODEMETA = Path("codemeta.json") +CITATION = Path("CITATION.cff") +HEADER = "# This file is generated from codemeta.json by tools/codemeta2cff.py. Do not edit it.\n" + + +def orcid(person): + pid = person.get("@id", "") + if "orcid.org/" in pid: + return "https://orcid.org/" + pid.split("orcid.org/")[1] + return None + + +def cff_person(person): + entry = {"given-names": person["givenName"], "family-names": person["familyName"]} + if orcid(person): + entry["orcid"] = orcid(person) + return entry + + +def doi(identifier): + return identifier.split("doi.org/")[1] + + +def spdx_id(license_url): + return license_url.rstrip("/").split("/")[-1] + + +def build_citation(codemeta): + rrid = codemeta["identifier"] + article = codemeta["referencePublication"] + year, month, _ = article["datePublished"].split("-") + volume = article["isPartOf"] + cff = { + "cff-version": "1.2.0", + "message": (f"If you use {codemeta['name']} in your work, please cite the article given " + f"in preferred-citation, and give its Research Resource Identifier ({rrid})."), + "type": "software", + "title": codemeta["name"], + "abstract": codemeta["description"].split("\n\n")[0], + "authors": [cff_person(p) for p in codemeta["author"]], + "version": codemeta["version"], + "license": spdx_id(codemeta["license"]), + "repository-code": codemeta["codeRepository"], + "identifiers": [ + {"type": "other", "value": rrid, "description": "Research Resource Identifier"}, + ], + "keywords": codemeta["keywords"], + "preferred-citation": { + "type": "article", + "title": article["name"], + "authors": [cff_person(p) for p in article["author"]], + "journal": volume["isPartOf"]["name"], + "volume": int(volume["volumeNumber"]), + "start": article["pagination"], + "year": int(year), + "month": int(month), + "doi": doi(article["@id"]), + }, + } + if codemeta.get("datePublished"): + cff["date-released"] = codemeta["datePublished"] + return cff + + +def scalar(value): + if isinstance(value, bool) or not isinstance(value, (int, str)): + raise TypeError(f"Unsupported value: {value!r}") + if isinstance(value, int): + return str(value) + return json.dumps(value, ensure_ascii=False) + + +def to_yaml(obj, indent=0): + pad = " " * indent + lines = [] + if isinstance(obj, dict): + for key, value in obj.items(): + if isinstance(value, dict): + lines.append(f"{pad}{key}:") + lines.extend(to_yaml(value, indent + 2)) + elif isinstance(value, list): + lines.append(f"{pad}{key}:") + lines.extend(to_yaml(value, indent)) + else: + lines.append(f"{pad}{key}: {scalar(value)}") + elif isinstance(obj, list): + for item in obj: + if isinstance(item, dict): + item_lines = to_yaml(item, indent + 2) + lines.append(f"{pad}- {item_lines[0].lstrip()}") + lines.extend(item_lines[1:]) + else: + lines.append(f"{pad}- {scalar(item)}") + return lines + + +def main(): + parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) + parser.add_argument("--check", action="store_true", + help="check that CITATION.cff is up to date, rather than writing it") + args = parser.parse_args() + codemeta = json.loads(CODEMETA.read_text(encoding="utf-8")) + text = HEADER + "\n".join(to_yaml(build_citation(codemeta))) + "\n" + if args.check: + if not CITATION.exists() or CITATION.read_text(encoding="utf-8") != text: + sys.exit(f"{CITATION} is out of date: run 'python tools/codemeta2cff.py' " + f"after changing {CODEMETA}") + print(f"{CITATION} is up to date") + else: + CITATION.write_text(text, encoding="utf-8") + print(f"Wrote {CITATION}") + + +if __name__ == "__main__": + main()