| 1 |
Installing from source: |
| 2 |
---------------------- |
| 3 |
|
| 4 |
I. General Notes |
| 5 |
II. UNIX |
| 6 |
III. MS-Windows |
| 7 |
|
| 8 |
I. General Notes: |
| 9 |
----------------- |
| 10 |
|
| 11 |
If your platform comes without OpenGL or Forms support, or you just get |
| 12 |
into troubles using the default setup script, it is possible to disable |
| 13 |
Forms and OpenGl support from the pyFltk build. The following command |
| 14 |
line switches are provided for this: |
| 15 |
|
| 16 |
--disable-gl : will disable OpenGL support |
| 17 |
--disable-forms : will disable Forms support |
| 18 |
|
| 19 |
In general, however, setup.py will take the proper settings from your Fltk |
| 20 |
installation, to be used for the compilation of pyFltk. |
| 21 |
|
| 22 |
II. LINUX: |
| 23 |
--------- |
| 24 |
|
| 25 |
We've only tested it under GNU/Linux Debian |
| 26 |
|
| 27 |
Installation: |
| 28 |
1) Fast and easy from package manager: |
| 29 |
sudo apt install python3-fltk |
| 30 |
|
| 31 |
Optional: |
| 32 |
Building pyfltk from source: |
| 33 |
|
| 34 |
1) Prerequisites |
| 35 |
FLTK and SWIG and compiler |
| 36 |
Install FLTK and Swig with package manager: |
| 37 |
1.1) #apt install libfltk1.4-dev |
| 38 |
1.2) #apt install swig |
| 39 |
1.3) #apt install g++ |
| 40 |
|
| 41 |
|
| 42 |
2) Or build FLTK from source as a shared library using cmake: |
| 43 |
|
| 44 |
2.1) Install cmake (#apt install cmake) |
| 45 |
2.2) Install g++ (#apt install g++) |
| 46 |
|
| 47 |
2.3) Extract fltk to some local directory, e.g. ~\fltk-1.4.x |
| 48 |
2.4) Open a terminal and navigate to ~\fltk-1.4.x (or wherever you installed fltk) |
| 49 |
2.5) mkdir build |
| 50 |
2.6) cd build |
| 51 |
2.7) cmake -D FLTK_BUILD_SHARED_LIBS=ON -D CMAKE_POSITION_INDEPENDENT_CODE=ON -D CMAKE_BUILD_TYPE=Release .. |
| 52 |
2.8) make |
| 53 |
2.9) sudo make install |
| 54 |
|
| 55 |
3) Building pyFltk |
| 56 |
3.1) Create a Python virtual environment. |
| 57 |
mkdir venv |
| 58 |
cd venv |
| 59 |
python3 -m venv . |
| 60 |
source bin/activate |
| 61 |
|
| 62 |
3.2) Install python dependencies |
| 63 |
pip3 install setuptools build |
| 64 |
|
| 65 |
3.3) Build pyFltk |
| 66 |
Download and extract the pyFltk source distribution (pyfltk-1.4.x.x.tar.gz) |
| 67 |
|
| 68 |
Now you can build the installable wheel file with the command: |
| 69 |
python3 -m build --wheel |
| 70 |
|
| 71 |
Now the dist/ dir should contain the .whl file which can be installed using |
| 72 |
pip3 install dist/pyfltk-1.4.x.x-cp3xx-cp3xx-linux_x86_64.whl |
| 73 |
|
| 74 |
Note: you may have to use --break-system-packages if you are not using a virtual environment |
| 75 |
and you want to install it in the main operating system. Be careful not to |
| 76 |
install this way if you have already installed it from the package manager. |
| 77 |
|
| 78 |
The benefit of installing with pip is that the library can be uninstalled easily with the command: |
| 79 |
pip3 list |
| 80 |
pip3 uninstall pyfltk |
| 81 |
|
| 82 |
or you can even build and install directly from the source distribution with command |
| 83 |
python3 -m pip install pyfltk-1.4.x.x.tar.gz |
| 84 |
|
| 85 |
You should then be able to change directory to fltk/test/ and run the demos |
| 86 |
by typing: python3 xxx.py |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
III. MS-Windows: |
| 91 |
---------------- |
| 92 |
|
| 93 |
Install prebuilt wheels from PyPi in powershell: |
| 94 |
pip install pyfltk |
| 95 |
|
| 96 |
|
| 97 |
or build from source: |
| 98 |
|
| 99 |
MS-Visual C++ under Windows11: |
| 100 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 101 |
|
| 102 |
The preferred way of building extensions is with the Microsoft compiler. For this to work you will need the the Microsoft Visaul C++ compiler V14 or later, which can be installed as a free version. |
| 103 |
See https://wiki.python.org/moin/WindowsCompilers for how to install this. |
| 104 |
|
| 105 |
1) Pre-requisites |
| 106 |
1.1) Install Visual Studio 2019 Community edition (or later) |
| 107 |
1.2) Install Python V3.12 64bit (or later) |
| 108 |
1.3) Install swigwin-4.2.x or later |
| 109 |
1.4) Add swigwin install directory to user or system path |
| 110 |
1.5) Download fltk-1.4.x (or later) |
| 111 |
1.6) Download pyFltk-1.4.x (or later) |
| 112 |
|
| 113 |
2) Building fltk (using CMake) |
| 114 |
2.1) Extract fltk to some local directory, e.g. C:\work\fltk-1.4.x |
| 115 |
2.2) Start Visual Studio and select "Open a local folder" |
| 116 |
2.3) Navigate to C:\work\fltk-1.4.x (or wherever you installed fltk) and press select |
| 117 |
2.4) Visual Studio will now initialize the CMake environment, this might take a few moments |
| 118 |
2.5) Create a Release configuration by selecting "Manage Configurations", press "+" and select "x64 Release" |
| 119 |
2.6) Build the project for the x64-Release: "Build" -- "Build All" |
| 120 |
2.7) After compilation finished, install the project by selecting "Build" -- "Install FLTK" |
| 121 |
|
| 122 |
3) Building pyFltk |
| 123 |
3.1) Extract pyFltk to some local directory, e.g. C:\work\pyFltk-1.4.x |
| 124 |
3.2) Open a powershell command prompt and change to directory C:\work\pyFltk-1.4.x (or wherever you installed pyFltk) |
| 125 |
3.3) Set the following environment variable by typing: set FLTK_HOME=C:\work\fltk-1.4.x\out\install\x64-Release |
| 126 |
3.4) Install the wrapper by typing: |
| 127 |
pip install build |
| 128 |
pip install setuptools |
| 129 |
|
| 130 |
python -m build --wheel |
| 131 |
(make sure the swig installation directory is in your path in Windows) |
| 132 |
|
| 133 |
cd dist |
| 134 |
Note: check if you have a previous version |
| 135 |
pip list |
| 136 |
|
| 137 |
if you do then uinstall with: |
| 138 |
pip uninstall pyfltk |
| 139 |
|
| 140 |
Now install the new version: |
| 141 |
pip install xxx.whl |
| 142 |
|
| 143 |
(where xxx.whl is the newly created wheel filename) |
| 144 |
|
| 145 |
3.5) open a new powershell instance and you should then be able to switch to test/ and run the demos |
| 146 |
by typing: python demos.py |
| 147 |
|
| 148 |
|
| 149 |
MinGW |
| 150 |
~~~~~ |
| 151 |
|
| 152 |
Since Python3.4 we do not support MinGW anymore, please use the approch with MS Visual C++ instead. |
| 153 |
|
| 154 |
IV. MacOS |
| 155 |
--------- |
| 156 |
|
| 157 |
Installation: |
| 158 |
install Python from python.org for macos. |
| 159 |
install Homebrew package manager from brew.sh |
| 160 |
brew install fltk |
| 161 |
pip3 install pyfltk |
| 162 |
|
| 163 |
V. Other Platforms: |
| 164 |
--------------------- |
| 165 |
|
| 166 |
Proceed according to the above outline. |
| 167 |
We would be glad about any feedback if you succeeded with building |
| 168 |
pyFltk on any other platform. |
| 169 |
|
| 170 |
Robert Arkiletian |
| 171 |
Andreas Held |
| 172 |
pyfltk.sourceforge.net |
| 173 |
|