Skip to content

Commit 7ebdb66

Browse files
authored
Merge pull request #17 from han-nwin/wip/python-version
Removed requirement version in requirements.txt
2 parents 6cee9e7 + b33cbaa commit 7ebdb66

File tree

4 files changed

+45
-23
lines changed

4 files changed

+45
-23
lines changed

datatorch/api/client.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from typing import List, Union, cast, IO
2-
import requests, glob, os, cgi
2+
import requests, glob, os #, cgi
33
from urllib.parse import urlencode
44

55
from gql import Client as GqlClient, gql
@@ -12,6 +12,8 @@
1212
from datatorch.core import user_settings
1313
from typing import Any, TypeVar, Type
1414

15+
from email.parser import HeaderParser
16+
1517
T = TypeVar("T")
1618

1719

@@ -97,10 +99,6 @@ def api_url(self) -> str:
9799
def graphql_url(self) -> str:
98100
return self._graphql_url
99101

100-
@property
101-
def graphql_url(self) -> str:
102-
return self.transport.url
103-
104102
def execute_files(
105103
self, paths: List[str], *args, params: dict = {}, **kwargs
106104
) -> dict:
@@ -152,7 +150,7 @@ def download_file(
152150
skip: bool = True
153151
# For now, skip does nothing
154152
):
155-
## If it exists and skip is true, do not download
153+
# If it exists and skip is true, do not download
156154
# name = os.path.join(directory, name)
157155
# name = os.path.abspath(name)
158156
# This name overwrites the value into name
@@ -176,9 +174,19 @@ def download_file(
176174
)
177175

178176
content = result.headers["content-disposition"]
179-
_, value = cgi.parse_header(content)
180-
181-
name = name or value["filename"]
177+
# _, value = cgi.parse_header(content)
178+
parser = HeaderParser()
179+
headers = parser.parsestr(f"Content-Disposition: {content}")
180+
filename_param = headers.get_param("filename")
181+
# Ensure filename is a string
182+
if isinstance(filename_param, tuple):
183+
filename = filename_param[0] or "" # Use the first element of the tuple if present
184+
elif isinstance(filename_param, str):
185+
filename = filename_param
186+
else:
187+
filename = "" # Default to an empty string if None or unexpected type
188+
189+
name = name or filename
182190
name = os.path.join(directory, name)
183191
name = os.path.abspath(name)
184192

datatorch/utils/package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import json
33
import subprocess
44
import urllib.request
5-
import pkg_resources
5+
from importlib.metadata import version
66

77

88
def get_latest() -> str:
@@ -12,7 +12,7 @@ def get_latest() -> str:
1212

1313

1414
def get_version() -> str:
15-
return pkg_resources.get_distribution("datatorch").version
15+
return version("datatorch")
1616

1717

1818
def upgrade():

requirements.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1-
Click~=7.0
1+
Click==8.0.0
2+
gql
3+
websockets
4+
websocket-client
5+
requests
6+
typing_extensions
7+
psutil
8+
aiodocker
9+
Jinja2
10+
PyYAML
11+
aiostream
12+
markupsafe
13+
requests_toolbelt
14+
imantics
15+
shapely
16+
tqdm
17+
urllib3
218
numpy
3-
pycocotools
19+
docker
20+
python-magic
21+
pycocotools

setup.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from setuptools import setup, find_packages
22
import sys
33

4-
assert sys.version_info >= (3, 7, 0), "DataTorch requires Python 3.7+"
4+
# Ensure the Python version is 3.13 or higher
5+
assert sys.version_info >= (3, 13, 0), "DataTorch requires Python 3.13+"
56

67
with open("README.md", "r", encoding="utf-8") as fp:
78
long_description = fp.read()
@@ -21,16 +22,15 @@
2122
"markupsafe==2.0.1",
2223
"requests_toolbelt==0.10.1",
2324
"imantics==0.1.12",
24-
"shapely==2.0.1",
25+
"shapely==2.0.6", # Compatible Python 3.13
2526
"tqdm~=4.65.0",
2627
"urllib3==1.26.15",
2728
"numpy",
2829
"docker",
2930
"python-magic",
31+
"pycocotools",
3032
]
3133

32-
requirements_agents = []
33-
3434
setup(
3535
name="datatorch",
3636
version="0.4.8.4",
@@ -45,8 +45,7 @@
4545
long_description=long_description,
4646
long_description_content_type="text/markdown",
4747
install_requires=requirements,
48-
extras_require={"agent": requirements_agents},
49-
python_requires=">=3.7",
48+
python_requires=">=3.13",
5049
license="MIT license",
5150
zip_safe=False,
5251
include_package_data=True,
@@ -56,10 +55,7 @@
5655
"Framework :: Pytest",
5756
"Intended Audience :: Developers",
5857
"Natural Language :: English",
59-
"Programming Language :: Python :: 3.7",
60-
"Programming Language :: Python :: 3.8",
61-
"Programming Language :: Python :: 3.9",
62-
"Programming Language :: Python :: 3.10",
58+
"Programming Language :: Python :: 3.13",
6359
"Topic :: Scientific/Engineering :: Artificial Intelligence",
6460
"Topic :: Software Development :: Libraries :: Python Modules",
6561
],

0 commit comments

Comments
 (0)