Skip to content

Commit

Permalink
Merge pull request #144 from gee-community/extlibs_refactoring
Browse files Browse the repository at this point in the history
External libraries refactoring
  • Loading branch information
gena authored Nov 3, 2024
2 parents 8c5450f + e851771 commit 30ecdc3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/qgis-plugin-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7"]
os: [macos-latest, windows-latest, ubuntu-latest]
python-version: ["3.10"]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ __pycache__
*.qgs~

help/build
extlibs_darwin
extlibs_linux
extlibs_windows
extlibs
media/

*.qgs~

ee_plugin.zip
23 changes: 8 additions & 15 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,18 @@
# -*- coding: utf-8 -*-
import os
import platform
import site
import pkg_resources


def pre_init_plugin():
if platform.system() == "Windows":
extlib_path = "extlibs_windows"
if platform.system() == "Darwin":
extlib_path = "extlibs_darwin"
if platform.system() == "Linux":
extlib_path = "extlibs_linux"
extra_libs_path = os.path.abspath(
os.path.join(os.path.dirname(__file__), extlib_path)
)

# add to python path
site.addsitedir(extra_libs_path)
# pkg_resources doesn't listen to changes on sys.path.
pkg_resources.working_set.add_entry(extra_libs_path)

extra_libs_path = os.path.abspath(os.path.join(os.path.dirname(__file__), 'extlibs'))

if os.path.isdir(extra_libs_path):
# add to python path
site.addsitedir(extra_libs_path)
# pkg_resources doesn't listen to changes on sys.path.
pkg_resources.working_set.add_entry(extra_libs_path)


# noinspection PyPep8Naming
Expand Down
31 changes: 20 additions & 11 deletions pavement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,49 @@
import os
import platform
import fnmatch
import shutil
import zipfile

from paver.easy import *


def get_extlibs():
if platform.system() == "Windows":
return 'extlibs_windows'
if platform.system() == "Darwin":
return 'extlibs_macos'
if platform.system() == "Linux":
return 'extlibs_linux'


options(
plugin=Bunch(
name='ee_plugin',
ext_libs=path(get_extlibs()),
ext_libs=path('extlibs'),
source_dir=path('.'),
package_dir=path('.'),
tests=['test', 'tests'],
excludes=[
"*.pyc",
".git",
".github",
".idea",
".gitignore",
".travis.yml",
"__pycache__",
"docs",
"help",
"test",
"media",
"ee_plugin.zip"
]
),
)


def clean_extlibs():
# delete the binary files in the extlibs directory
for root, dirs, files in os.walk(options.plugin.ext_libs):
for f in files:
if f.endswith(".so") or f.endswith(".pyd") or f.endswith(".dylib"):
os.remove(os.path.join(root, f))
# delete all __pycache__ directories
for root, dirs, files in os.walk(options.plugin.ext_libs):
for d in dirs:
if d == "__pycache__":
shutil.rmtree(os.path.join(root, d), ignore_errors=True)


@task
@cmdopts([('clean', 'c', 'clean out dependencies first')])
def setup():
Expand All @@ -53,6 +61,7 @@ def setup():
sh('pip install -U -t "{ext_libs}" "{dep}"'.format(ext_libs=ext_libs.abspath(), dep=req))
else:
sh('pip3 install -U -t "{ext_libs}" "{dep}"'.format(ext_libs=ext_libs.abspath(), dep=req))
clean_extlibs()

@task
def install(options):
Expand Down
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
ratelim
pyCrypto
earthengine-api
earthengine-api>=0.1.335
six>=1.13
httplib2

0 comments on commit 30ecdc3

Please sign in to comment.