Skip to content

Commit 621b4d6

Browse files
committed
Refactored creation of qt.conf into it's own module; util.py.
1 parent 4a86162 commit 621b4d6

File tree

2 files changed

+26
-25
lines changed

2 files changed

+26
-25
lines changed

setup.py

+2-25
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import util
34

45
from setuptools import setup, find_packages
56

@@ -46,27 +47,6 @@ def get_readme():
4647
return readme
4748

4849

49-
def createqtconf():
50-
"""Create a qt.conf file next to the current executable"""
51-
52-
template = """[Paths]
53-
Prefix = {path}
54-
Binaries = {path}
55-
"""
56-
57-
import PyQt5
58-
59-
exedir = os.path.dirname(sys.executable)
60-
qtpath = os.path.join(exedir, "qt.conf")
61-
binpath = os.path.dirname(PyQt5.__file__).replace("\\", "/")
62-
63-
try:
64-
with open(qtpath, "w") as f:
65-
f.write(template.format(path=binpath))
66-
except:
67-
pass
68-
69-
7050
classifiers = [
7151
'Development Status :: 4 - Beta',
7252
'Intended Audience :: Developers',
@@ -93,7 +73,4 @@ def createqtconf():
9373
classifiers=classifiers,
9474
package_data=get_package_data(),
9575
data_files=get_data_files()
96-
)
97-
98-
# Attempt to automatically create a qt.conf
99-
createqtconf()
76+
)

util.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import os
2+
import sys
3+
4+
5+
def createqtconf():
6+
"""Create a qt.conf file next to the current executable"""
7+
8+
template = """[Paths]
9+
Prefix = {path}
10+
Binaries = {path}
11+
"""
12+
13+
import PyQt5
14+
15+
exedir = os.path.dirname(sys.executable)
16+
qtpath = os.path.join(exedir, "qt.conf")
17+
pyqt5path = os.path.abspath(PyQt5.__file__)
18+
binpath = os.path.dirname(pyqt5path).replace("\\", "/")
19+
20+
try:
21+
with open(qtpath, "w") as f:
22+
f.write(template.format(path=binpath))
23+
except:
24+
pass

0 commit comments

Comments
 (0)