From 7fb40e0676346c7174960de4b4f5f2913bf17ae2 Mon Sep 17 00:00:00 2001 From: Alexander Dunkel Date: Wed, 29 Jan 2020 09:30:06 +0100 Subject: [PATCH] refactor: remove remnants of pyproj < 2.0.0 compatibility --- cx_setup.py | 46 +++++++++++++++++++++----------------- tagmaps/classes/cluster.py | 5 +++-- tagmaps/classes/utils.py | 6 ++++- 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/cx_setup.py b/cx_setup.py index 0b6b860..995b47f 100644 --- a/cx_setup.py +++ b/cx_setup.py @@ -10,18 +10,36 @@ Has been tested with conda environment (Windows 10) Prerequisites: - - install cx_freeze - - install matplotlib (instead of matplotlib-base) from conda-forge - - install [OSGeosW64][1], add C:/OSGeo4W64/bin (e.g.) to PATH - - set variable [EPSG_SHARE][2] to where GDAL gcs.csv is stored - - install [mkl-service][3] + +- use conda, create environment, e.g.: + `conda create -n tagmaps_cx` +- install tagmaps dependencies and tagmaps +- install cx_freeze +- install matplotlib (instead of matplotlib-base) from conda-forge +- install [OSGeosW64][1], add C:/OSGeo4W64/bin (e.g.) to PATH +- install [mkl-service][2] +- fix hdbscan-joblib-parallel (see note below): + - install hdbscan regularly with: + `conda install hdbscan -c conda-forge` + - then remove hdbscan without removing dependencies: + `conda remove hdbscan -c conda-forge --force` + - clone [4], install without dependencies into conda-environment: + `python setup.py develop --no-deps` + + +[Joblib-freeze-issue][3]: as of 2020-01-29, joblib.Parallel +can only be run in frozen apps when prefer="threads" is used. This +has been changed in a fork of HDBSCAN found [here][4] Run build with: - python cx_setup.py build +``` +python cx_setup.py build +``` [1]: https://trac.osgeo.org/osgeo4w/ -[2]: e.g. SET EPSG_SHARE=C:\OSGeo4W64\share\epsg_csv -[3]: e.g. conda install mkl-service -c conda-forge +[2]: e.g. conda install mkl-service -c conda-forge +[3]: https://github.com/joblib/joblib/issues/1002 +[4]: https://github.com/Sieboldianus/hdbscan """ import glob @@ -45,13 +63,6 @@ PYTHON_VERSION = f'{sys.version_info.major}.{sys.version_info.minor}' print(f"Running cx_freeze for Python {PYTHON_VERSION}") -try: - EPSG_SHARE = os.environ['EPSG_SHARE'] -except KeyError: - raise ValueError( - "Please set environment variable EPSG_SHARE to " - "where GDAL gcs.csv is stored.") - # opcode is not a virtualenv module, # so we can use it to find the stdlib; this is the same # trick used by distutils itself it installs itself into the virtualenv @@ -125,11 +136,6 @@ (os.path.join(PYTHON_INSTALL_DIR, 'Library', 'bin', 'geos_c.dll'), os.path.join('geos_c.dll') ), - (os.path.join(PYTHON_INSTALL_DIR, 'Library', 'share', 'proj'), - os.path.join('proj') - ), - # os.path.join(PYTHON_INSTALL_DIR, 'Library', 'plugins', 'platforms'), - os.path.join(os.environ['EPSG_SHARE'], 'gcs.csv'), 'resources/01_Input/', 'resources/00_Config/', 'resources/00_generateClusters_OnlyEmoji.cmd', diff --git a/tagmaps/classes/cluster.py b/tagmaps/classes/cluster.py index 09b0763..218a833 100644 --- a/tagmaps/classes/cluster.py +++ b/tagmaps/classes/cluster.py @@ -171,8 +171,9 @@ def __init__(self, bounds: AnalysisBounds, self._update_bounds() self.bound_points_shapely = Utils.get_shapely_bounds( self.bounds) - # verify that PROJ_LIB exists - Utils.set_proj_dir() + # verify that PROJ_LIB exists, + # only necessary for pyproj < 2.0.0 + # Utils.set_proj_dir() # input data always in lat/lng WGS1984 # define input and UTM projections self.crs_wgs = "epsg:4326" diff --git a/tagmaps/classes/utils.py b/tagmaps/classes/utils.py index d99deb7..42317b2 100644 --- a/tagmaps/classes/utils.py +++ b/tagmaps/classes/utils.py @@ -109,7 +109,11 @@ def split_topic(term_concat): @staticmethod def set_proj_dir(): - """Update PROJ_LIB location if not found.""" + """Update PROJ_LIB location if not found + + Leftover from pyproj < 2.0.0 compatibility, + PROJ_LIB not needed anymore + """ if not os.environ.get('PROJ_LIB'): local_proj_path = Path.cwd() / "proj" if not local_proj_path.exists():