-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
135 lines (102 loc) · 4.1 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import os
from typing import List
from pathlib import Path
from setuptools import setup
from setuptools import find_packages
def get_requirements(file_path: str) -> List[str]:
"""
Read the content of a text file at the specified 'file_path' and return its requirements as a list.
Parameters:
file_path (str): The file path of the text file to be read.
Returns:
List[str]: A list of requirements extracted from the text file.
Raises:
FileNotFoundError: If the specified 'file_path' does not exist.
Note:
- The text file should contain requirements, each listed on a separate line.
- This function reads the file content, splits it by newline character ('\n'),
and returns a list of requirements.
Example:
# Example text file: requirements.txt
# ------------------------------
# numpy
# pandas
# matplotlib
# scikit-learn
# -e .
requirements_list = get_requirements("requirements.txt")
print(requirements_list)
# Output: ['numpy', 'pandas', 'matplotlib', 'scikit-learn']
Comment:
The 'get_requirements' function takes a 'file_path' as input, reads the specified
text file, and returns a list of requirements extracted from that file. It assumes
that each requirement is listed on a separate line in the text file. The function
reads the file content using 'open' and 'read' methods, splits it by newline ('\n')
character to get individual requirements, and then returns the list of requirements.
If the 'file_path' does not exist, a 'FileNotFoundError' will be raised.
"""
# Use try block to avoid any error
try:
# open requirements.txt as file if exist at given path
with open(file_path, 'r') as file:
# Read the file and save requirements in a list
requirements = file.read().split('\n')
# If error occured then catch the error
except Exception as e:
# Print error to debug and return empty list
print(e)
return []
# finally return a list of requirements excluding last elements if -e in requirements else return full list
if '-e .' in requirements:
return requirements[:-1]
else:
return requirements
DIR_NAME = Path(__file__).parent
VERSION = '1.0.2'
AUTHOR = 'Saqib Shaikh'
REPO_NAME = 'LinkedList'
PROJECT_NAME = 'LinkedList_575'
AUTHOR_USER_NAME = 'Saqibs575'
AUTHOR_EMAIL = '[email protected]'
LICENSE = 'GNU General Public License v3.0'
LONG_DESCRIPTION = (DIR_NAME / "README.md").read_text()
URL = 'https://github.com/Saqibs575/LinkedList'
DESCRIPTION = 'A Python package for LinkedList data structure.'
REQUIREMENTS_FILE_PATH = os.path.join(os.getcwd(), 'requirements.txt')
setup(
url=URL,
author=AUTHOR,
version=VERSION,
license=LICENSE,
name=PROJECT_NAME,
python_requires='>=3.6',
description=DESCRIPTION,
packages=find_packages(),
author_email=AUTHOR_EMAIL,
long_description=LONG_DESCRIPTION,
long_description_content_type='text/markdown',
install_requires=get_requirements(REQUIREMENTS_FILE_PATH),
keywords=['LinkedList', 'linkedlist', 'linked list', 'linkedlist in python ',
'linked list data-structure python package'],
project_urls={
'Source': URL,
'Bug Reports': f'{URL}/issues',
},
classifiers=[
"License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Operating System :: OS Independent"
],
platforms=[
'win32', 'win-amd64', 'win-arm32', 'win-arm64', 'linux-x86',
'linux-x86_64', 'linux-armv6l', 'linux-armv7l', 'linux-aarch64',
'darwin', 'darwin-arm64', 'any'
]
)