Spaces:
Sleeping
Sleeping
changeling setup.py
Browse files
setup.py
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
from urllib.request import urlopen
|
3 |
+
from urllib.error import URLError, HTTPError
|
4 |
+
from setuptools import setup
|
5 |
+
from pathlib import Path
|
6 |
+
import zipfile
|
7 |
+
import io
|
8 |
+
|
9 |
+
# raise NotImplementedError()
|
10 |
+
|
11 |
+
|
12 |
+
def download_real_code(zip_url: str, dest: Path, overwrite=False):
|
13 |
+
# download zip_url
|
14 |
+
# extract files into dest, but strip 1st path component like tar --strip-components=1
|
15 |
+
try:
|
16 |
+
# Open the URL with built-in urllib
|
17 |
+
with urlopen(zip_url) as response:
|
18 |
+
# Read the content
|
19 |
+
zip_content = response.read()
|
20 |
+
|
21 |
+
# Create the destination directory if it doesn't exist
|
22 |
+
dest.mkdir(parents=True, exist_ok=True)
|
23 |
+
|
24 |
+
# Create a ZipFile object from the downloaded content
|
25 |
+
with zipfile.ZipFile(io.BytesIO(zip_content)) as zip_ref:
|
26 |
+
# Extract files, stripping the first path component
|
27 |
+
for member in zip_ref.infolist():
|
28 |
+
# Skip the first path component
|
29 |
+
parts = member.filename.split("/", 1)
|
30 |
+
if len(parts) > 1:
|
31 |
+
new_filename = parts[1]
|
32 |
+
else:
|
33 |
+
new_filename = member.filename
|
34 |
+
|
35 |
+
# Skip directories and empty filenames
|
36 |
+
if not new_filename or new_filename.endswith("/"):
|
37 |
+
continue
|
38 |
+
|
39 |
+
# Extract the file to the destination
|
40 |
+
source = zip_ref.open(member)
|
41 |
+
target = dest / new_filename
|
42 |
+
|
43 |
+
# Skip existing file
|
44 |
+
if target.exists() and not overwrite:
|
45 |
+
continue
|
46 |
+
|
47 |
+
# Ensure the target directory exists
|
48 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
49 |
+
|
50 |
+
# Write the file content
|
51 |
+
with target.open("wb") as f:
|
52 |
+
f.write(source.read())
|
53 |
+
|
54 |
+
except HTTPError as e:
|
55 |
+
print(f"HTTP Error {e.code}: {e.reason}")
|
56 |
+
raise
|
57 |
+
except URLError as e:
|
58 |
+
print(f"URL Error: {e.reason}")
|
59 |
+
raise
|
60 |
+
|
61 |
+
|
62 |
+
download_real_code(
|
63 |
+
"https://github.com/moeflow-com/manga-image-translator/archive/6b4294bb7b04e037f303d34d46dbc49491b9460f.zip",
|
64 |
+
Path(__file__).parent.joinpath("."),
|
65 |
+
)
|
66 |
+
|
67 |
+
version_main = "0.1.0"
|
68 |
+
version = f"{version_main}"
|
69 |
+
|
70 |
+
setup(
|
71 |
+
name="mit_gradio_loader",
|
72 |
+
version=version,
|
73 |
+
author="jokester",
|
74 |
+
author_email="[email protected]",
|
75 |
+
description="transforms",
|
76 |
+
# long_description=open('README.md').read(),
|
77 |
+
# long_description_content_type='text/markdown',
|
78 |
+
url="https://github.com/moeflow-com/manga-image-translator",
|
79 |
+
project_urls={
|
80 |
+
"Bug Tracker": "https://github.com/moeflow-com/manga-image-translator/issues",
|
81 |
+
},
|
82 |
+
classifiers=[],
|
83 |
+
package_data={},
|
84 |
+
packages=["mit_gradio_loader"],
|
85 |
+
# package_dir={"": "mit_gradio_loader"},
|
86 |
+
include_package_data=False,
|
87 |
+
python_requires=">=3.10,<3.13",
|
88 |
+
setup_requires=["setuptools>=61.0"],
|
89 |
+
)
|