Installing from source:
----------------------

I.   General Notes
II.  UNIX
III. MS-Windows

I. General Notes:
-----------------

If your platform comes without OpenGL or Forms support, or you just get
into troubles using the default setup script, it is possible to disable 
Forms and OpenGl support from the pyFltk build. The following command 
line switches are provided for this:

--disable-gl		: will disable OpenGL support
--disable-forms		: will disable Forms support

In general, however, setup.py will take the proper settings from your Fltk 
installation, to be used for the compilation of pyFltk.

II. LINUX:
---------

We've only tested it under GNU/Linux Debian 

Installation:
1) Fast and easy from package manager:
sudo apt install python3-fltk

Optional:
Building pyfltk from source:

    1) Prerequisites
    FLTK and SWIG and compiler
    Install FLTK and Swig with package manager:
    1.1)    #apt install libfltk1.4-dev
    1.2)    #apt install swig
    1.3)    #apt install g++


    2) Or build FLTK from source as a shared library using cmake:

    2.1) Install cmake  (#apt install cmake) 
    2.2) Install g++    (#apt install g++)
       
    2.3) Extract fltk to some local directory, e.g. ~\fltk-1.4.x
    2.4) Open a terminal and navigate to ~\fltk-1.4.x (or wherever you installed fltk)
    2.5) mkdir build
    2.6) cd build
    2.7) cmake -D FLTK_BUILD_SHARED_LIBS=ON -D CMAKE_POSITION_INDEPENDENT_CODE=ON -D CMAKE_BUILD_TYPE=Release .. 
    2.8) make
    2.9) sudo make install

    3) Building pyFltk
    3.1) Create a Python virtual environment. 
            mkdir venv
            cd venv
            python3 -m venv .
            source bin/activate

    3.2) Install python dependencies
            pip3 install setuptools build

    3.3) Build pyFltk
        Download and extract the pyFltk source distribution (pyfltk-1.4.x.x.tar.gz)
        
        Now you can build the installable wheel file with the command:
        python3 -m build --wheel
        
        Now the dist/ dir should contain the .whl file which can be installed using 
        pip3 install dist/pyfltk-1.4.x.x-cp3xx-cp3xx-linux_x86_64.whl

        Note: you may have to use --break-system-packages if you are not using a virtual environment
        and you want to install it in the main operating system. Be careful not to
        install this way if you have already installed it from the package manager.

        The benefit of installing with pip is that the library can be uninstalled easily with the command:
        pip3 list
        pip3 uninstall pyfltk
        
        or you can even build and install directly from the source distribution with command
        python3 -m pip install pyfltk-1.4.x.x.tar.gz
     
        You should then be able to change directory to fltk/test/ and run the demos 
        by typing:  python3 xxx.py

	

III. MS-Windows:
----------------

Install prebuilt wheels from PyPi in powershell:
pip install pyfltk


or build from source:

MS-Visual C++ under Windows11:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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.
See https://wiki.python.org/moin/WindowsCompilers for how to install this.

    1) Pre-requisites
    1.1) Install Visual Studio 2019 Community edition (or later)
    1.2) Install Python V3.12 64bit (or later)
    1.3) Install swigwin-4.2.x or later
    1.4) Add swigwin install directory to user or system path
    1.5) Download fltk-1.4.x (or later)
    1.6) Download pyFltk-1.4.x (or later)

    2) Building fltk (using CMake)
    2.1) Extract fltk to some local directory, e.g. C:\work\fltk-1.4.x
    2.2) Start Visual Studio and select "Open a local folder"
    2.3) Navigate to C:\work\fltk-1.4.x (or wherever you installed fltk) and press select
    2.4) Visual Studio will now initialize the CMake environment, this might take a few moments
    2.5) Create a Release configuration by selecting "Manage Configurations", press "+" and select "x64 Release"
    2.6) Build the project for the x64-Release: "Build" -- "Build All"
    2.7) After compilation finished, install the project by selecting "Build" -- "Install FLTK"

    3) Building pyFltk
    3.1) Extract pyFltk to some local directory, e.g. C:\work\pyFltk-1.4.x
    3.2) Open a powershell command prompt and change to directory C:\work\pyFltk-1.4.x (or wherever you installed pyFltk)
    3.3) Set the following environment variable by typing: set FLTK_HOME=C:\work\fltk-1.4.x\out\install\x64-Release
    3.4) Install the wrapper by typing:
        pip install build
        pip install setuptools

        python -m build --wheel
        (make sure the swig installation directory is in your path in Windows)
        
        cd dist
        Note: check if you have a previous version
        pip list

        if you do then uinstall with:
        pip uninstall pyfltk

        Now install the new version:
        pip install xxx.whl

        (where xxx.whl is the newly created wheel filename) 

     3.5) open a new powershell instance and you should then be able to switch to test/ and run the demos 
     by typing:  python demos.py


MinGW
~~~~~

Since Python3.4 we do not support MinGW anymore, please use the approch with MS Visual C++ instead.

IV. MacOS
---------

Installation:
install Python from python.org for macos.
install Homebrew package manager from brew.sh
brew install fltk
pip3 install pyfltk

V. Other Platforms:
---------------------

Proceed according to the above outline.
We would be glad about any feedback if you succeeded with building
pyFltk on any other platform.

Robert Arkiletian
Andreas Held
pyfltk.sourceforge.net

