Skip to content

Commit

Permalink
refactor: remove remnants of pyproj < 2.0.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieboldianus committed Jan 29, 2020
1 parent f224de2 commit 7fb40e0
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
46 changes: 26 additions & 20 deletions cx_setup.py
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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',
Expand Down
5 changes: 3 additions & 2 deletions tagmaps/classes/cluster.py
Expand Up @@ -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"
Expand Down
6 changes: 5 additions & 1 deletion tagmaps/classes/utils.py
Expand Up @@ -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():
Expand Down

0 comments on commit 7fb40e0

Please sign in to comment.