-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
118 lines (103 loc) · 3.56 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
"""
Setup.py file to build and install package
"""
import codecs
import os
from setuptools import setup
with open(os.path.join(os.path.dirname(__file__), "README.md"), encoding='utf-8') as readme:
README = readme.read()
# allow setup.py to be run from any path
os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
def read(filename):
"""
read some file
"""
with open(filename, "r", encoding="utf-8") as file:
return file.read()
# PACKAGE_PYPI_NAME = 'find-similar'
PACKAGE_NAME = "find_similar"
def open_local(paths, mode="r", encoding="utf8"):
"""
Open local package file
:param paths: list of paths to file
:param mode: read, write, ...
:param encoding: Encoding
:return: file object
"""
path = os.path.join(os.path.abspath(os.path.dirname(__file__)), *paths)
return codecs.open(path, mode, encoding)
def get_value_from_package_info(line, value, old_value):
"""
Get value from text line
:param line: file text line
:param value: value to parse
:param old_value: if value has already founded
:return:
"""
if old_value:
return old_value
if line.startswith(value):
_, val = line.split('=')
return val.strip().replace("'", '')
return None
with open_local([PACKAGE_NAME, "package.py"]) as fp:
package_pypi_name, package_version, package_status = None, None, None
for file_line in fp:
package_pypi_name = get_value_from_package_info(file_line, 'name', package_pypi_name)
package_version = get_value_from_package_info(file_line, 'version', package_version)
package_status = get_value_from_package_info(file_line, 'status', package_status)
if not (package_pypi_name and package_version and package_status):
raise RuntimeError("Unable to determine Package Info.")
PROJECT_URLS = {
'Documentation': 'https://findsimilar.craftsman.lol',
'Source': 'https://github.com/findsimilar/find-similar',
'Tracker': 'https://github.com/findsimilar/find-similar/issues',
'Release notes': 'https://github.com/findsimilar/find-similar/releases',
'Changelog': 'https://github.com/findsimilar/find-similar/releases',
'Download': 'https://pypi.org/project/find-similar/',
}
setup(
name=package_pypi_name,
version=package_version,
packages=[PACKAGE_NAME],
package_data={
PACKAGE_NAME: ['*', '*/*', '*/*/*']
},
include_package_data=True,
license="MIT",
description="User-friendly library to find similar objects",
long_description=read("README.md"),
long_description_content_type="text/markdown",
url="https://github.com/findsimilar/find-similar",
author="findsimilar",
author_email="[email protected]",
keywords=[
'python',
'search',
'machine-learning',
'natural-language-processing',
'find',
'words',
'texts',
'similar'
],
install_requires=[
'setuptools',
'nltk == 3.8.1',
'pymorphy3 == 1.2.1',
'PyYAML == 6.0.1',
],
python_requires=">=3",
classifiers=[
f'Development Status :: {package_status}',
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
"Topic :: Scientific/Engineering :: Information Analysis",
"Topic :: Text Processing",
"Topic :: Text Processing :: Linguistic",
],
project_urls= PROJECT_URLS,
)