From a7b914235679a7f22ccd145f63865de1d722e5ac Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Mon, 24 Oct 2022 21:09:26 -0700 Subject: [PATCH 1/4] ENH: move to platformdirs from appdirs (WIP) --- libpysal/examples/base.py | 2 +- libpysal/examples/tests/test_available.py | 22 ++++++++++++++++++++-- requirements.txt | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/libpysal/examples/base.py b/libpysal/examples/base.py index 771ec9017..aa20f7a5f 100644 --- a/libpysal/examples/base.py +++ b/libpysal/examples/base.py @@ -10,7 +10,7 @@ import webbrowser from os import environ, makedirs from os.path import exists, expanduser, join -from appdirs import user_data_dir +from platformdirs import user_data_dir import zipfile import requests import pandas diff --git a/libpysal/examples/tests/test_available.py b/libpysal/examples/tests/test_available.py index a67708e30..3471c7329 100644 --- a/libpysal/examples/tests/test_available.py +++ b/libpysal/examples/tests/test_available.py @@ -1,20 +1,38 @@ #!/usr/bin/env python3 import os +import platform import unittest import numpy as np import pandas from .. import available +from ..base import get_data_home -class Testavailable(unittest.TestCase): +os_name = platform.system() + +class Testexamples(unittest.TestCase): def test_available(self): examples = available() self.assertEqual(type(examples), pandas.core.frame.DataFrame) + def test_data_home(self): + pth = get_data_home() + head, tail = os.path.split(pth) + self.assertEqual(tail, 'pysal') + if os_name == 'Linux': + heads = head.split("/") + self.assertEqual(heads[1], 'home') + self.assertEqual(heads[-1], 'share') + self.assertEqual(heads[-2], '.local') + elif os_name == 'Darwin': + heads = head.split("/") + self.assertEqual(heads[1], 'Users') + self.assertEqual(heads[-1], 'Application Support') + self.assertEqual(heads[-2], 'Library') -suite = unittest.TestLoader().loadTestsFromTestCase(Testavailable) +suite = unittest.TestLoader().loadTestsFromTestCase(Testexamples) if __name__ == "__main__": runner = unittest.TextTestRunner() diff --git a/requirements.txt b/requirements.txt index f149a6c29..e07a6ecd4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -appdirs +platformdirs beautifulsoup4 jinja2 numpy>=1.3 From 6cfd3532d048d2c41f9b1b6e45174c288e735ab2 Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Wed, 26 Oct 2022 19:53:27 -0700 Subject: [PATCH 2/4] ENH: add tests for Windows --- libpysal/examples/tests/test_available.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libpysal/examples/tests/test_available.py b/libpysal/examples/tests/test_available.py index 3471c7329..902fba034 100644 --- a/libpysal/examples/tests/test_available.py +++ b/libpysal/examples/tests/test_available.py @@ -31,6 +31,11 @@ def test_data_home(self): self.assertEqual(heads[1], 'Users') self.assertEqual(heads[-1], 'Application Support') self.assertEqual(heads[-2], 'Library') + elif os_name == 'Windows': + heads = head.split("\\") + self.assertEqual(heads[1], 'Users') + self.assertEqual(heads[-1], 'Local') + self.assertEqual(heads[-2], 'AppData') suite = unittest.TestLoader().loadTestsFromTestCase(Testexamples) From d7896e009d9f8d89fab7c587403de7b8914a2703 Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Wed, 26 Oct 2022 20:02:44 -0700 Subject: [PATCH 3/4] ENH: update ci for platformdirs swap --- ci/310.yaml | 2 +- ci/37-minimal.yaml | 2 +- ci/37.yaml | 2 +- ci/38.yaml | 2 +- ci/39.yaml | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ci/310.yaml b/ci/310.yaml index 3a1982de0..213025ff1 100644 --- a/ci/310.yaml +++ b/ci/310.yaml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - python=3.10 - - appdirs + - platformdirs - beautifulsoup4 - jinja2 - pandas>=1.0 diff --git a/ci/37-minimal.yaml b/ci/37-minimal.yaml index 1c13f5268..e8ff14647 100644 --- a/ci/37-minimal.yaml +++ b/ci/37-minimal.yaml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - python=3.7 - - appdirs + - platformdirs - beautifulsoup4 - jinja2 - pandas>=1.0 diff --git a/ci/37.yaml b/ci/37.yaml index 297fbd81a..dfa28134d 100644 --- a/ci/37.yaml +++ b/ci/37.yaml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - python=3.7 - - appdirs + - platformdirs - beautifulsoup4 - jinja2 - pandas>=1.0 diff --git a/ci/38.yaml b/ci/38.yaml index 5023f9adc..be0fdb73b 100644 --- a/ci/38.yaml +++ b/ci/38.yaml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - python=3.8 - - appdirs + - platformdirs - beautifulsoup4 - jinja2 - pandas>=1.0 diff --git a/ci/39.yaml b/ci/39.yaml index aad680e4f..02df18e0e 100644 --- a/ci/39.yaml +++ b/ci/39.yaml @@ -3,7 +3,7 @@ channels: - conda-forge dependencies: - python=3.9 - - appdirs + - platformdirs - beautifulsoup4 - jinja2 - pandas>=1.0 From 3ebd86fae228d58249d5891ae9bf9f4465302312 Mon Sep 17 00:00:00 2001 From: Serge Rey Date: Wed, 26 Oct 2022 20:16:38 -0700 Subject: [PATCH 4/4] ENH: windows ci path splitting (blind) --- libpysal/examples/tests/test_available.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libpysal/examples/tests/test_available.py b/libpysal/examples/tests/test_available.py index 902fba034..1592c39c8 100644 --- a/libpysal/examples/tests/test_available.py +++ b/libpysal/examples/tests/test_available.py @@ -34,8 +34,8 @@ def test_data_home(self): elif os_name == 'Windows': heads = head.split("\\") self.assertEqual(heads[1], 'Users') - self.assertEqual(heads[-1], 'Local') - self.assertEqual(heads[-2], 'AppData') + self.assertEqual(heads[-2], 'Local') + self.assertEqual(heads[-3], 'AppData') suite = unittest.TestLoader().loadTestsFromTestCase(Testexamples)