-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
132 lines (117 loc) · 4.14 KB
/
setup.py
File metadata and controls
132 lines (117 loc) · 4.14 KB
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
#!/usr/bin/env python
"""Setup script for GoRequests library."""
from setuptools import setup, find_packages
import os
import shutil
# Read the README file
with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
# Read the version
def get_version():
version_file = os.path.join("gorequests", "__init__.py")
if os.path.exists(version_file):
with open(version_file, "r") as f:
for line in f:
if line.startswith("__version__"):
return line.split("=")[1].strip().strip('"').strip("'")
return "2.0.0"
# Copy necessary files
def copy_library_files():
"""Copy the Go library and Python files to the package directory."""
src_dir = os.path.dirname(os.path.abspath(__file__))
# Create gorequests package directory if it doesn't exist
pkg_dir = os.path.join(src_dir, "gorequests")
os.makedirs(pkg_dir, exist_ok=True)
# Copy the main Python file
python_src = os.path.join(src_dir, "..", "python", "gorequests_v2.py")
python_dst = os.path.join(pkg_dir, "__init__.py")
if os.path.exists(python_src):
shutil.copy2(python_src, python_dst)
print(f"Copied {python_src} to {python_dst}")
# Copy the Go library
dll_src = os.path.join(src_dir, "..", "python", "libgorequests.dll")
dll_dst = os.path.join(pkg_dir, "libgorequests.dll")
if os.path.exists(dll_src):
shutil.copy2(dll_src, dll_dst)
print(f"Copied {dll_src} to {dll_dst}")
# Create exceptions module
exceptions_content = '''"""GoRequests exceptions module."""
class GoRequestsError(Exception):
"""Base exception for GoRequests."""
pass
class TimeoutError(GoRequestsError):
"""Timeout exception."""
pass
class ConnectionError(GoRequestsError):
"""Connection error exception."""
pass
class HTTPError(GoRequestsError):
"""HTTP error exception."""
pass
'''
exceptions_path = os.path.join(pkg_dir, "exceptions.py")
with open(exceptions_path, "w") as f:
f.write(exceptions_content)
print(f"Created {exceptions_path}")
# Prepare the package
copy_library_files()
setup(
name="gorequests",
version=get_version(),
author="GoRequests Team",
author_email="team@gorequests.io",
description="High-performance HTTP client library powered by Go FastHTTP",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/coffeecms/gorequests",
project_urls={
"Bug Tracker": "https://github.com/coffeecms/gorequests/issues",
"Documentation": "https://gorequests.readthedocs.io",
"Source Code": "https://github.com/coffeecms/gorequests",
},
packages=find_packages(),
package_data={
"gorequests": ["*.dll", "*.so", "*.dylib"],
},
include_package_data=True,
classifiers=[
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"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",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Networking",
],
python_requires=">=3.7",
keywords="http requests client fasthttp go performance async web api networking fast",
install_requires=[],
extras_require={
"dev": [
"pytest>=6.0",
"pytest-cov>=2.0",
"black>=21.0",
"flake8>=3.8",
"mypy>=0.900",
"requests>=2.25.0",
],
"test": [
"pytest>=6.0",
"pytest-cov>=2.0",
"requests>=2.25.0",
],
},
zip_safe=False,
entry_points={
"console_scripts": [
"gorequests-benchmark=gorequests.benchmark:main",
],
},
)