Skip to content

Commit 332f794

Browse files
committed
added support for deps imported from whl
1 parent 0a82b8f commit 332f794

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ __pycache__/
33
*.egg
44
*.egg-info
55
dist
6-
*build
6+
*build
7+
*.whl
8+
.idea

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Mergin python client
22

3-
Repo for mergin client and basic utils.
3+
Repo for mergin client and basic utils.
4+
5+
For using mergin client with its dependencies locally run:
6+
7+
python3 setup.py sdist bdist_wheel
8+
mkdir -p mergin/deps
9+
pip wheel -r mergin_client.egg-info/requires.txt -w mergin/deps

mergin/client.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,30 @@
11
import os
22
import re
33
import json
4-
import pytz
54
import zlib
65
import base64
76
import shutil
87
import urllib.parse
98
import urllib.request
10-
import dateutil.parser
119
from datetime import datetime
12-
from requests_toolbelt import MultipartEncoder
10+
11+
this_dir = os.path.dirname(os.path.realpath(__file__))
12+
13+
try:
14+
from requests_toolbelt import MultipartEncode
15+
import pytz
16+
import dateutil.parser
17+
except ImportError:
18+
# this is to import all dependencies shipped with package (e.g. to use in qgis-plugin)
19+
deps_dir = os.path.join(this_dir, 'deps')
20+
if os.path.exists(deps_dir):
21+
import sys
22+
for f in os.listdir(os.path.join(deps_dir)):
23+
sys.path.append(os.path.join(deps_dir, f))
24+
25+
from requests_toolbelt import MultipartEncode
26+
import pytz
27+
import dateutil.parser
1328

1429
from .utils import save_to_file, generate_checksum, move_file
1530
from .multipart import MultipartReader, parse_boundary

0 commit comments

Comments
 (0)