Skip to content

Commit e2bdefa

Browse files
authored
Add detailed build instructions to Readme (#235)
1 parent c9d281f commit e2bdefa

File tree

1 file changed

+83
-9
lines changed

1 file changed

+83
-9
lines changed

README.md

Lines changed: 83 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,89 @@ updating the typesystems as well.
3333

3434
# Building
3535

36-
## Building on Windows with MinGW
36+
## General
3737

38-
To build PythonQt, you need to set the environment variable `PYTHON_PATH` to
39-
point to the root dir of the python installation. Then you should set the
40-
`PYTHON_VERSION` variable to the Python version number.
38+
Building PythonQt requires a couple of steps.
39+
Follow these instructions in order to get a correctly built PythonQt runtime and Qt bindings.
4140

42-
When using the prebuild Python installer, this will be:
41+
### Recommendations
4342

44-
```cmd
45-
set PYTHON_PATH=c:\Python310
46-
set PYTHON_VERSION=3.10
47-
```
43+
It is recommended to build the Qt bindings yourself instead of using the pregenerated ones.
44+
This ensures the bindings are compatible with your Qt version.
45+
Do not build `PythonQt.pro` directly because it will only use the pregenerated bindings!
46+
47+
### Environment
48+
49+
First, you need to set a couple of environment variables, which depend on your Python and Qt installation.
50+
51+
- `PYTHON_VERSION`
52+
53+
Set the version of your Python interpreter. The syntax is `<major>.<minor>`, e.g., `3.10`.
54+
55+
- `PYTHON_PATH`
56+
57+
This is the absolute path to the root directory of your Python installation.
58+
59+
- `PYTHON_LIB`
60+
61+
The absolute path to the `libs` directory in your python installation `$PYTHON_PATH/libs`.
62+
63+
- `PYTHON_DIR`
64+
65+
The `PYTHON_DIR` is required for non-Windows installations to find the `python-config` executable.
66+
This should have the same value as `PYTHON_PATH`.
67+
68+
- `QTDIR`
69+
70+
The absolute path to the root directory of your Qt installation.
71+
72+
### Binding Generator
73+
74+
1. cd into the `generator` directory
75+
2. Run qmake on `generator.pro`
76+
77+
`qmake CONFIG+=Release generator.pro`
78+
79+
3. Make the generator
80+
81+
Use `nmake` for MSVC (Visual Studio; make sure to have the environment variables set for Visual Studio beforehand). Otherwise, use `make`.
82+
83+
4. Generate the bindings
84+
85+
We use the generator executable from step 3 to generate the bindings.
86+
The location of the generator executable can vary depending on your platform (the subdirectory is named after the current configuration, e.g., `release`).
87+
On Windows, the generator is named `pythonqt_generator.exe`; on all other platforms, it is named `pythonqt_generator`.
88+
89+
`<generator-executable> qtscript_masterinclude.h build_all.txt`
90+
91+
### PythonQt Runtime
92+
93+
Next, we need the PythonQt runtime.
94+
95+
1. cd into the `src` directory
96+
2. qmake `src.pro`
97+
98+
`qmake CONFIG+=Release src.pro`
99+
100+
3. Make the runtime
101+
102+
Use `nmake` for MSVC (Visual Studio; make sure to have the environment variables set for Visual Studio beforehand). Otherwise, use `make`.
103+
104+
### Extensions
105+
106+
As a last step, we need to build the extensions.
107+
108+
1. cd into `extensions`
109+
2. qmake `src.pro`
110+
111+
`qmake CONFIG+=Release extensions.pro`
112+
113+
3. Make the extensions
114+
115+
Use `nmake` for MSVC (Visual Studio; make sure to have the environment variables set for Visual Studio beforehand). Otherwise, use `make`.
116+
117+
After all these steps, you should now have a fully working PythonQt runtime and Qt bindings for your Python/Qt installation 🎉.
118+
119+
## MinGW
120+
121+
It is possible to build PythonQt with MinGW on Windows instead of using MSVC.

0 commit comments

Comments
 (0)