Skip to content

Commit 4a86162

Browse files
committed
Moving qt.conf creation to setup.py
1 parent efba7de commit 4a86162

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

PyQt5/__init__.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,3 @@
3535
qt_version_info = (5, 4, 0)
3636
qt_version = "%s.%s.%s" % qt_version_info
3737
__qt_version__ = qt_version
38-
39-
40-
def __createqtconf():
41-
"""Create a qt.conf file next to the current executable"""
42-
43-
template = """[Paths]
44-
Prefix = {path}
45-
Binaries = {path}
46-
"""
47-
48-
exedir = os.path.dirname(sys.executable)
49-
qtpath = os.path.join(exedir, "qt.conf")
50-
binpath = os.path.dirname(__file__).replace("\\", "/")
51-
52-
if not os.path.exists(qtpath):
53-
try:
54-
with open(qtpath, "w") as f:
55-
f.write(template.format(path=binpath))
56-
except Exception as e:
57-
sys.stderr.write("Could not write qt.conf: %s" % e)
58-
59-
__createqtconf()

setup.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ def get_readme():
4646
return readme
4747

4848

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+
4970
classifiers = [
5071
'Development Status :: 4 - Beta',
5172
'Intended Audience :: Developers',
@@ -73,3 +94,6 @@ def get_readme():
7394
package_data=get_package_data(),
7495
data_files=get_data_files()
7596
)
97+
98+
# Attempt to automatically create a qt.conf
99+
createqtconf()

0 commit comments

Comments
 (0)