forked from neo4j-contrib/py2neo
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
121 lines (101 loc) · 3.51 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
115
116
117
118
119
120
121
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Copyright 2011-2021, Nigel Small
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from os import getenv, path
from warnings import warn
from setuptools import setup, find_packages
from py2neo.meta import VERSION_FILE, get_metadata, parse_version_string
README_FILE = path.join(path.dirname(__file__), "README.rst")
def get_readme():
with open(README_FILE) as f:
return f.read()
class Release(object):
def __init__(self):
self.__original = None
def __enter__(self):
self.__original = parse_version_string(self._read_version())
if self.__original["dev"]:
patched = parse_version_string(self._read_patched())
self._check_compatible(self.__original, patched)
self._patch_version(patched["string"])
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self._patch_version(self.__original["string"])
@classmethod
def _read_version(cls):
with open(VERSION_FILE, "r") as f:
return f.read()
@classmethod
def _read_patched(cls):
patched = getenv("RELEASE")
if patched:
return patched
else:
warn("RELEASE environment variable not set - assuming development release")
return cls._read_version()
@classmethod
def _check_compatible(cls, original, patched):
if original == patched:
return
compatible = True
if patched["epoch"] != original["epoch"]:
compatible = False
if patched["release"][:2] != original["release"][:2]:
compatible = False
if patched["dev"] is not None:
compatible = False
if not compatible:
raise SystemExit("Patched version string %r is not compatible with original version "
"string %r" % (patched["string"], original["string"]))
@classmethod
def _patch_version(cls, value):
with open(VERSION_FILE, "w") as f:
f.write(value)
with Release():
setup(**dict(get_metadata(), **{
"long_description": get_readme(),
"long_description_content_type": "text/x-rst",
"entry_points": {
"console_scripts": [
],
"pygments.lexers": [
"py2neo.cypher = py2neo.cypher.lexer:CypherLexer",
],
},
"packages": find_packages(exclude=("docs", "test", "test.*")),
"package_data": {
"py2neo": ["VERSION"],
"py2neo.movies": [
"data/*",
"static/*",
"views/*.tpl",
"movies.ini",
"README.md",
],
},
"py_modules": [],
"install_requires": [
"certifi",
"interchange~=2021.0.4",
"monotonic",
"packaging",
"pansi>=2020.7.3",
"pygments>=2.0.0",
"six>=1.15.0",
"urllib3",
],
"extras_require": {
},
}))