diff --git a/.github/workflows/packager.yml b/.github/workflows/packager.yml index c3f51ac..eeb242d 100644 --- a/.github/workflows/packager.yml +++ b/.github/workflows/packager.yml @@ -37,6 +37,7 @@ jobs: run: | python -m pip install -U pip setuptools wheel python -m pip install -U -r requirements/packaging.txt + python -m pip install --no-deps -U -r requirements/embedded.txt -t roof_classify/embedded_external_libs - name: Update translations run: pylupdate5 -noobsolete -verbose ${{ env.PROJECT_FOLDER }}/resources/i18n/plugin_translation.pro diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index faba956..0e1f9d9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -37,6 +37,7 @@ jobs: run: | python -m pip install -U pip setuptools wheel python -m pip install -U -r requirements/packaging.txt + python -m pip install --no-deps -U -r requirements/embedded.txt -t roof_classify/embedded_external_libs - name: Compile translations run: lrelease roof_classify/resources/i18n/*.ts diff --git a/.github/workflows/tester.yml b/.github/workflows/tester.yml index ea6e4b7..bc4e10d 100644 --- a/.github/workflows/tester.yml +++ b/.github/workflows/tester.yml @@ -42,6 +42,7 @@ jobs: - name: Install Python requirements run: | python3 -m pip install -U pip setuptools wheel + python -m pip install --no-deps -U -r requirements/embedded.txt -t roof_classify/embedded_external_libs python3 -m pip install -U -r requirements/testing.txt - name: Run Unit tests diff --git a/.gitignore b/.gitignore index 0f86389..6342e73 100644 --- a/.gitignore +++ b/.gitignore @@ -136,4 +136,5 @@ dmypy.json # *.qm *.zip -.vscode/ +roof_classify/embedded_external_libs/ + diff --git a/docs/development/environment.md b/docs/development/environment.md index ae6eca8..bfe769e 100644 --- a/docs/development/environment.md +++ b/docs/development/environment.md @@ -16,9 +16,17 @@ In your virtual environment: ```bash # use the latest pip version -python -m pip install -U pip setuptools wheel +python -m pip install -U pip # install development tools python -m pip install -U -r requirements/development.txt +# install external dependencies +python -m pip install --no-deps -U -r requirements/embedded.txt -t roof_classify/embedded_external_libs # install pre-commit to respect common development guidelines pre-commit install ``` + +## Additionnal external dependencies + +This plugin has external dependencies listed in this specific file: + +Because it's still hard to install Python 3rd party packages from an index (for example ), especially on Windows or Mac systems (or even on Linux if we want to do it properly in a virtual environment), those required packages are stored in the `embedded_external_libs` folder. diff --git a/requirements/development.txt b/requirements/development.txt index d0c10ea..aaf8e4a 100644 --- a/requirements/development.txt +++ b/requirements/development.txt @@ -1,5 +1,7 @@ -# Develoment dependencies -# ----------------------- +# Development dependencies +# ------------------------ + +-r base.txt black flake8>=3.8,<3.10 diff --git a/requirements/embedded.txt b/requirements/embedded.txt new file mode 100644 index 0000000..05a0c4a --- /dev/null +++ b/requirements/embedded.txt @@ -0,0 +1,8 @@ +# Embedded requirements +# +# Typical command to install: +# python -m pip install --no-deps -U -r requirements/embedded.txt -t roof_classify/embedded_external_libs +# ----------------------- + +joblib>=0.11 +scikit-learn==0.24.* diff --git a/roof_classify/roof_classify.py b/roof_classify/roof_classify.py index cce02bd..9440fb6 100644 --- a/roof_classify/roof_classify.py +++ b/roof_classify/roof_classify.py @@ -34,14 +34,23 @@ #IMPORT PER CLASSIFICATORE import shapefile from osgeo import gdal -from PyQt4.QtCore import QCoreApplication, QSettings, QTranslator, qVersion -from PyQt4.QtGui import QAction, QFileDialog, QIcon - -# Import the code for the dialog -from roof_classify_dialog import RoofClassifyDialog -from sklearn import metrics -from sklearn.ensemble import RandomForestClassifier -from sklearn.svm import SVC +from qgis.PyQt.QtCore import QCoreApplication, QSettings, QTranslator +from qgis.PyQt.QtGui import QIcon +from qgis.PyQt.QtWidgets import QAction, QFileDialog + +try: + from sklearn.ensemble import RandomForestClassifier + from sklearn.svm import SVC +except Exception: + import site + + from roof_classify.__about__ import DIR_PLUGIN_ROOT + site.addsitedir(DIR_PLUGIN_ROOT / "embedded_external_libs") + # from roof_classify.embedded_external_libs import joblib + from roof_classify.embedded_external_libs.sklearn.ensemble import ( + RandomForestClassifier, + ) + from roof_classify.embedded_external_libs.sklearn.svm import SVC from roof_classify.__about__ import DIR_PLUGIN_ROOT, __title__ from roof_classify.toolbelt import PlgLogger