Skip to main content

Tool to create a virtual python environment for QGIS plugin development

Project description

QGIS Venv Creator

PyPI - Version PyPI - Python Version Tests and Style check


Single file and zero dependency tool to create a Python virtual environment for QGIS plugin development.

Table of Contents

Installation

The recommended way to install qgis-venv-creator (and other Python cli tools) is to install it with pipx. Pipx will install the application in an isolated environment and make it available as a command line utility. To install pipx, follow the instructions provided at https://github.com/pypa/pipx#install-pipx.

$ pipx install qgis-venv-creator

Alternatively, to install in your current Python environment:

$ pip install qgis-venv-creator

Copy as a script

qgis-venv-creator is a single Python script that can be downloaded and copied to your project root, or any other location from which you wish to use it.

Usage

Quick start

On your plugin root directory, run:

$ create-qgis-venv

Note:
If you have copied the script file to your project root, you can run it with python create-qgis-venv.py.

On a system where there might be multiple QGIS installations (ie. Windows, MacOs), you are asked to select the one you want to use for development.

After the virtual environment is created, you can activate it and it will have access to the QGIS Python environment.

Options

create-qgis-venv [-h] [--venv-parent VENV_PARENT] [--venv-name VENV_NAME]
                    [--qgis-installation QGIS_INSTALLATION]
                    [--qgis-installation-search-path-pattern QGIS_INSTALLATION_SEARCH_PATH_PATTERN]
                    [--python-executable PYTHON_EXECUTABLE] [--debug]
Option Available on platform Description
-h, --help ALL Show this help message and exit
--venv-parent ALL Path to the parent directory of the virtual environment to be created. Most likely your project directory. Default current directory.
--venv-name ALL Name of the virtual environment
--qgis-installation Windows Path to the QGIS installation to use for development. Installations made with official msi and Osgeo4W installers are supported. Give the path to the 'qgis' directory inside the 'apps' directory. If not given, the user is prompted to select one.
--qgis-installation-search-path-pattern Windows Custom glob pattern for QGIS installations to be selected. Can be set also with environment variable QGIS_INSTALLATION_SEARCH_PATH_PATTERN. For example "C:\qgis\*\apps\qgis*\" to find installations from "C:\qgis\3.32\apps\qgis\" and "C:\qgis\3.28\apps\qgis-ltr\"
--python-executable Windows Path to the Python executable used by the QGIS installation. If not given, the Python executable is searched from the QGIS installation.
--debug ALL Enable debug logging

Development

This project uses Hatch for development and packaging. Install instructions can be found at the project's website https://hatch.pypa.io/latest/install.

To facilitate development with VS Code, it is recommended to create hatch environments in the project folder. You can configure hatch to do so by running:

hatch config set dirs.env.virtual ".hatch"

After Hatch has created the environment, you can set your Python interpreter to use the one located in .hatch/qgis-venv-creator.

Pre-commit hook

This project uses pre-commit to run code checks and tests before committing. You can install pre-commit with:

pipx install pre-commit

Install pre-commit hooks to your repo with:

pre-commit install

License

qgis-venv-creator is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

qgis_venv_creator-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

qgis_venv_creator-0.1.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file qgis_venv_creator-0.1.0.tar.gz.

File metadata

  • Download URL: qgis_venv_creator-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for qgis_venv_creator-0.1.0.tar.gz
Algorithm Hash digest
SHA256 927a323368461910f7965edc7d0083ea905227f43c2bd793e6bb926263ea3555
MD5 d372215960c47ec12635b4cfd1a6d5ab
BLAKE2b-256 74c8c2ef78e7a24f383e69fab7c740fc9281e8e0942b1669a043316a47b86e26

See more details on using hashes here.

File details

Details for the file qgis_venv_creator-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for qgis_venv_creator-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 affa8e48068141a892eeaa29732d839784fdf585e780fe1a55cacdb02a14d7b8
MD5 50a1077a0012bddfc5de4b5bfd70bc4f
BLAKE2b-256 a487c834b966c860b5f1d1cd40b91d66d45236555362e394dd3ec5c25f3e0ccb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page