hook-mpl_toolkits.basemap.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # ------------------------------------------------------------------
  2. # Copyright (c) 2020 PyInstaller Development Team.
  3. #
  4. # This file is distributed under the terms of the GNU General Public
  5. # License (version 2.0 or later).
  6. #
  7. # The full license is available in LICENSE, distributed with
  8. # this software.
  9. #
  10. # SPDX-License-Identifier: GPL-2.0-or-later
  11. # ------------------------------------------------------------------
  12. from PyInstaller.utils.hooks import collect_data_files
  13. from PyInstaller.compat import is_win, base_prefix
  14. import os
  15. # mpl_toolkits.basemap (tested with v.1.0.7) is shipped with auxiliary data,
  16. # usually stored in mpl_toolkits\basemap\data and used to plot maps
  17. datas = collect_data_files('mpl_toolkits.basemap', subdir='data')
  18. # check if the data has been effectively found
  19. if len(datas) == 0:
  20. # - conda-specific
  21. if is_win:
  22. tgt_basemap_data = os.path.join('Library', 'share', 'basemap')
  23. src_basemap_data = os.path.join(base_prefix, 'Library', 'share', 'basemap')
  24. else: # both linux and darwin
  25. tgt_basemap_data = os.path.join('share', 'basemap')
  26. src_basemap_data = os.path.join(base_prefix, 'share', 'basemap')
  27. if os.path.exists(src_basemap_data):
  28. datas.append((src_basemap_data, tgt_basemap_data))