-
Notifications
You must be signed in to change notification settings - Fork 71
/
setup.py
114 lines (96 loc) · 3.67 KB
/
setup.py
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
46
47
48
49
50
51
52
53
54
55
56
57
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import io
import re
from os.path import dirname
from setuptools import setup
ROOT = dirname(__file__)
RE_REQUIREMENT = re.compile(r"^\s*-r\s*(?P<filename>.*)$")
RE_MD_CODE_BLOCK = re.compile(r"```(?P<language>\w+)?\n(?P<lines>.*?)```", re.S)
RE_SELF_LINK = re.compile(r"\[(.*?)\]\[\]")
RE_LINK_TO_URL = re.compile(r"\[(?P<text>.*?)\]\((?P<url>.*?)\)")
RE_LINK_TO_REF = re.compile(r"\[(?P<text>.*?)\]\[(?P<ref>.*?)\]")
RE_LINK_REF = re.compile(r"^\[(?P<key>[^!].*?)\]:\s*(?P<url>.*)$", re.M)
RE_TITLE = re.compile(r"^(?P<level>#+)\s*(?P<title>.*)$", re.M)
CUT = "<!-- CUT HERE -->"
RST_TITLE_LEVELS = ["=", "-", "*"]
def md2pypi(filename):
"""
Load .md (markdown) file and sanitize it for PyPI.
Remove unsupported github tags:
- travis ci build badges
"""
content = io.open(filename).read().split(CUT)[0]
for match in RE_MD_CODE_BLOCK.finditer(content):
rst_block = "\n".join(
[".. code-block:: {language}".format(**match.groupdict()), ""]
+ [" {0}".format(l) for l in match.group("lines").split("\n")]
+ [""]
)
content = content.replace(match.group(0), rst_block)
refs = dict(RE_LINK_REF.findall(content))
content = RE_LINK_REF.sub(".. _\g<key>: \g<url>", content)
content = RE_SELF_LINK.sub("`\g<1>`_", content)
content = RE_LINK_TO_URL.sub("`\g<text> <\g<url>>`_", content)
for match in RE_LINK_TO_REF.finditer(content):
content = content.replace(
match.group(0),
"`{text} <{url}>`_".format(
text=match.group("text"), url=refs[match.group("ref")]
),
)
for match in RE_TITLE.finditer(content):
underchar = RST_TITLE_LEVELS[len(match.group("level")) - 1]
title = match.group("title")
underline = underchar * len(title)
full_title = "\n".join((title, underline))
content = content.replace(match.group(0), full_title)
return content
name = "rdflib-jsonld"
version = __import__("rdflib_jsonld").__version__
setup(
name=name,
version=version,
description="rdflib extension adding JSON-LD parser and serializer",
long_description=md2pypi("README.md"),
maintainer="RDFLib Team",
maintainer_email="[email protected]",
url="https://github.com/RDFLib/rdflib-jsonld",
license="BSD",
packages=["rdflib_jsonld"],
zip_safe=False,
platforms=["any"],
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"License :: OSI Approved :: BSD License",
"Topic :: Software Development :: Libraries :: Python Modules",
"Operating System :: OS Independent",
"Natural Language :: English",
],
test_suite="nose.collector",
install_requires=["rdflib>=5.0.0"],
tests_require=["nose"],
command_options={
"build_sphinx": {
"project": ("setup.py", name),
"version": ("setup.py", ".".join(version.split(".")[:2])),
"release": ("setup.py", version),
}
},
entry_points={
"rdf.plugins.parser": [
"json-ld = rdflib_jsonld.parser:JsonLDParser",
"application/ld+json = rdflib_jsonld.parser:JsonLDParser",
],
"rdf.plugins.serializer": [
"json-ld = rdflib_jsonld.serializer:JsonLDSerializer",
"application/ld+json = rdflib_jsonld.serializer:JsonLDSerializer",
],
},
)