Gaphor en Windows¶
Gaphor can be installed as with our installer. Check out the Gaphor download page for details.
Las versiones anteriores están disponibles en GitHub.
También están disponibles construcciones CI.
Entorno de desarrollo¶
WinGet¶
We recommend using WinGet as a package manager in Windows. It is available on Windows 11 and modern versions of Windows 10 as a part of the App Installer.
If you have a slightly older version of Windows, you can alternatively use Chocolatey as a
package manager. After it is installed, execute choco install instead of the winget install commands below.
Git¶
To set up a development environment in Windows first install Git by executing as an administrator:
winget install git.git
GTK and Python with Gvsbuild¶
Gvsbuild provides pre-built GTK libraries for Windows. We will install these libraries and Python.
Instalar la última versión de Python¶
En Windows, el instalador completo contiene todos los componentes de Python y es la mejor opción para los desarrolladores que usen Python para cualquier tipo de proyecto.
Para más información sobre cómo usar el instalador oficial, consulte las instrucciones completas del instalador. Las opciones de instalación predeterminadas deberían ser adecuadas para Gaphor.
Instale la última versión de Python usando el instalador oficial.
Abra un terminal PowerShell como usuario normal y compruebe la versión de python:
py -3.13 --version
Instalar Graphviz¶
Gaphor usa Graphviz para dar formato automático a los diagramas.
Install from WinGet with administrator PowerShell:
winget install graphviz
Instalar pipx¶
Desde el terminal PowerShell del usuario normal ejecutar:
py -3.13 -m pip install --user pipx
py -3.13 -m pipx ensurepath
Download GTK¶
Download the latest release asset at https://github.com/wingtk/gvsbuild/releases. The file will be
called GTK4_Gvsbuild_VERSION_x64.zip, where VERSION is the latest released version.
Unzip the GTK4_Gvsbuild_VERSION_x64.zip file to C:\gtk. For example with 7Zip:
7z x GTK4_Gvsbuild_*.zip -oC:\gtk -y
The resulting directory structure should look like:
C:\gtk
├── bin
├── include
├── lib
├── python
├── share
└── wheels
Configurar Gaphor¶
En el mismo terminal PowerShell, clone el repositorio:
cd (to the location you want to put Gaphor)
git clone https://github.com/gaphor/gaphor.git
cd gaphor
Install Poetry:
pipx install poetry
Añada GTK a sus variables de entorno:
$env:Path = $env:Path + ";C:\gtk\bin;C:\Program Files\Graphviz\bin"
$env:LIB = "C:\gtk\lib"
$env:INCLUDE = "C:\gtk\include;C:\gtk\include\cairo;C:\gtk\include\glib-2.0;C:\gtk\include\gobject-introspection-1.0;C:\gtk\lib\glib-2.0\include;"
$env:GI_TYPELIB_PATH = "C:\gtk\lib\girepository-1.0"
$env:XDG_DATA_HOME = "$env:userprofile\.local\share"
También puede editar las variables de entorno de su cuenta para que persistan en todas las sesiones de PowerShell.
Install Gaphor’s dependencies:
poetry install
Reinstall PyGObject and pycairo using gvsbuild wheels:
poetry run pip install --force-reinstall (Resolve-Path C:\gtk\wheels\PyGObject*.whl)
poetry run pip install --force-reinstall (Resolve-Path C:\gtk\wheels\pycairo*.whl)
¡Inicie Gaphor!
poetry run gaphor
Setting Up A Plugin Workspace for Gaphor¶
When setting up a plugin workspace you need to perform the following steps:
cd (your project's workspace)
If your project does not already have a pyproject.toml file, create one. For details see the Poetry documentation. If you already have a .toml file, make sure you have gaphor as a development dependency. For details see the Gaphor Hello World Plugin.
poetry init
Install your project’s dependencies. If you have made your project dependent upon Gaphor, this will pull in Gaphor.
poetry install
Reinstall PyGObject and pycairo using gvsbuild wheels:
poetry run pip install --force-reinstall (Resolve-Path C:\gtk\wheels\PyGObject*.whl)
poetry run pip install --force-reinstall (Resolve-Path C:\gtk\wheels\pycairo*.whl)
Note that if you have forgotten to reinstall PyGObject and pycairo, the first time you add an element to a diagram that has text, gaphor will crash!
¡Inicie Gaphor!
poetry run gaphor
Depuración con Visual Studio Code¶
Inicie un nuevo terminal PowerShell y establezca el directorio actual en la carpeta del proyecto:
cd (to the location you put gaphor)
Asegúrese de que la variable de entorno path está activada:
$env:Path = "C:\gtk\bin;" + $env:Path
Inicie Visual Studio Code:
code .
Para iniciar el depurador, ejecute los siguientes pasos:
Abra el archivo
__main__.pyde la carpetagaphorAñada un punto de interrupción en la línea
main(sys.argv)En el menú, seleccione Ejecutar → Iniciar depuración
Elija Seleccionar módulo de la lista
Introduzca
gaphorcomo nombre del módulo
Visual Studio Code iniciará la aplicación en modo de depuración y se detendrá en main.
Debugging Your Plugin Using Visual Studio Code¶
cd (your project's workspace)
Start gaphor:
In the VSCode menu, select Run → Start debugging
Elija Seleccionar módulo de la lista
Introduzca
gaphorcomo nombre del módulo
Your plugin should appear under the Tools menu.
Empaquetado para Windows¶
Para crear un paquete de instalación exe para Windows, usamos PyInstaller que analiza Gaphor para encontrar todas las dependencias y agruparlas en una única carpeta. A continuación, usamos un script bash personalizado que crea un instalador de Windows usando NSIS y un instalador portable usando 7-Zip. Para instalarlos, abra PowerShell como administrador y ejecute:
winget install nsis 7zip
Luego construya su instalador usando:
poetry install --only main,packaging,automation
poetry run pip install --force-reinstall (Resolve-Path C:\gtk\wheels\PyGObject*.whl)
poetry run pip install --force-reinstall (Resolve-Path C:\gtk\wheels\pycairo*.whl)
poetry build
poetry run poe package
poetry run poe win-installer
Limited Anaconda Install¶
Sometimes, it may be helpful to call Gaphor functionality from a python console on computers without the ability for a full development install (e.g., without administrative privileges). Because not all necessary Gaphor build dependencies (specifically, gtksourceview5 and libadwaita) are not available as anaconda packages, you will not be able to build the program or instantiate/run application classes like Application and Session.
However, this setup can still be helpful if you want to use or call Gaphor as a library in the context of a larger project. In these cases, Gaphor can be installed as a package in an anaconda environment using the following process:
Create new anaconda environment¶
If you use anaconda for other projects, it’s a good idea to create a new environment for Gaphor, so that its dependencies don’t end up conflicting with your pre-existing development environment. To do this, run the following command from anaconda prompt:
conda create -n "gaphor"
conda activate gaphor
where gaphor can be any name desired for the environment.
Update packages in the new environment¶
Get the most recent packages using:
conda update --all
Install dependencies¶
The following Gaphor dependencies are installable from anaconda:
conda install graphviz
conda install -c conda-forge gobject-introspection gtk4 pygobject pycairo hicolor-icon-theme adwaita-icon-theme
Unfortunately, the gtksourceview5 and libadwaita dependencies are not available as anaconda packages. So you may not be able to fully build/run the program in this environment.
Set up your development environment¶
Now, to develop with Gaphor, you will want to set it up with your development. If you want to work with ipython, install it below:
conda install ipython ipykernel
VSCode Tips¶
VSCode should work out-of-the box if it is already installed. Just set “gaphor” as the kernel in your VSCode Profile or notebook.
Spyder Tips¶
You can install spyder in this environment using conda install spyder.
If this does not work, (i.e., if conda install spyder reveals conflicts), you can instead use the following workaround:
conda install spyder-kernels=2.4
Then, in spyder, set “gaphor” as your python interpreter
Install Gaphor¶
From a python console running within your new anaconda environment, you may then install Gaphor using pip:
pip install gaphor