From 56524607c9d708c15288c3a9bd57919b2ba3d510 Mon Sep 17 00:00:00 2001 From: shunyi Date: Thu, 7 Dec 2017 17:21:58 +0800 Subject: [PATCH 1/6] [#148] Fix the bug when getting user home dir on Windows Use `os.path.expanduser` instead of using `os.path.join` directly, since the formmer is better handled for Windows. ref: --- zdict/constants.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zdict/constants.py b/zdict/constants.py index bb2cb54a..57fa50d1 100644 --- a/zdict/constants.py +++ b/zdict/constants.py @@ -4,7 +4,7 @@ VERSION = '0.10.1' BASE_DIR_NAME = '.zdict' -BASE_DIR = os.path.join(os.getenv('HOME'), BASE_DIR_NAME) +BASE_DIR = os.path.join(os.path.expanduser("~"), BASE_DIR_NAME) DB_NAME = 'zdict.db' DB_FILE = os.path.join(BASE_DIR, DB_NAME) From 18dfd9ddae8ba96f72991e9b108e3b9159195032 Mon Sep 17 00:00:00 2001 From: shunyi Date: Sat, 24 Feb 2018 20:34:52 +0800 Subject: [PATCH 2/6] [#148] Added example appveyor.yml ref: --- appveyor.yml | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..bacf70f6 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,52 @@ +environment: + + matrix: + + # For Python versions available on Appveyor, see + # http://www.appveyor.com/docs/installed-software#python + # The list here is complete (excluding Python 2.6, which + # isn't covered by this document) at the time of writing. + + - PYTHON: "C:\\Python27" + - PYTHON: "C:\\Python33" + - PYTHON: "C:\\Python34" + - PYTHON: "C:\\Python35" + - PYTHON: "C:\\Python27-x64" + - PYTHON: "C:\\Python33-x64" + DISTUTILS_USE_SDK: "1" + - PYTHON: "C:\\Python34-x64" + DISTUTILS_USE_SDK: "1" + - PYTHON: "C:\\Python35-x64" + - PYTHON: "C:\\Python36-x64" + +install: + # We need wheel installed to build wheels + - "%PYTHON%\\python.exe -m pip install wheel" + +build: off + +test_script: + # Put your test command here. + # If you don't need to build C extensions on 64-bit Python 3.3 or 3.4, + # you can remove "build.cmd" from the front of the command, as it's + # only needed to support those cases. + # Note that you must use the environment variable %PYTHON% to refer to + # the interpreter you're using - Appveyor does not do anything special + # to put the Python version you want to use on PATH. + - "build.cmd %PYTHON%\\python.exe setup.py test" + +after_test: + # This step builds your wheels. + # Again, you only need build.cmd if you're building C extensions for + # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct + # interpreter + - "build.cmd %PYTHON%\\python.exe setup.py bdist_wheel" + +artifacts: + # bdist_wheel puts your built wheel in the dist directory + - path: dist\* + +#on_success: +# You can use this step to upload your artifacts to a public website. +# See Appveyor's documentation for more details. Or you can simply +# access your wheels from the Appveyor "artifacts" tab for your build. From 507bd193b20d43facc1281d0493c008cfb7effb8 Mon Sep 17 00:00:00 2001 From: shunyi Date: Sat, 24 Feb 2018 20:50:13 +0800 Subject: [PATCH 3/6] [#148] Customized appveyor.yml for zdict + Remove Python 2. + Added install part. --- appveyor.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bacf70f6..f576fabf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,14 +4,10 @@ environment: # For Python versions available on Appveyor, see # http://www.appveyor.com/docs/installed-software#python - # The list here is complete (excluding Python 2.6, which - # isn't covered by this document) at the time of writing. - - PYTHON: "C:\\Python27" - PYTHON: "C:\\Python33" - PYTHON: "C:\\Python34" - PYTHON: "C:\\Python35" - - PYTHON: "C:\\Python27-x64" - PYTHON: "C:\\Python33-x64" DISTUTILS_USE_SDK: "1" - PYTHON: "C:\\Python34-x64" @@ -23,6 +19,13 @@ install: # We need wheel installed to build wheels - "%PYTHON%\\python.exe -m pip install wheel" + - "%PYTHON%\\python.exe -m pip install -U setuptools pip pytest" + - "%PYTHON%\\python.exe -m pip install ." + + # Show all installed Python packages version + - "%PYTHON%\\python.exe -m pip freeze" + + build: off test_script: @@ -33,14 +36,14 @@ test_script: # Note that you must use the environment variable %PYTHON% to refer to # the interpreter you're using - Appveyor does not do anything special # to put the Python version you want to use on PATH. - - "build.cmd %PYTHON%\\python.exe setup.py test" + - "%PYTHON%\\python.exe setup.py test" after_test: # This step builds your wheels. # Again, you only need build.cmd if you're building C extensions for # 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct # interpreter - - "build.cmd %PYTHON%\\python.exe setup.py bdist_wheel" + - "%PYTHON%\\python.exe setup.py bdist_wheel" artifacts: # bdist_wheel puts your built wheel in the dist directory From 7626866e7bee97a76c4b134c61cbc72bb2a7f370 Mon Sep 17 00:00:00 2001 From: shunyi Date: Sat, 24 Feb 2018 21:18:29 +0800 Subject: [PATCH 4/6] [#148] Fix test_requires for Windows env Install gnureadline for OSX with Python version <= 3.5. Install pyreadline for Windows. --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 91a392ee..2652d3c8 100644 --- a/setup.py +++ b/setup.py @@ -27,8 +27,10 @@ def get_test_req(): ) test_requires = [str(tr.req) for tr in test_requirements] - if not sys.platform.startswith('freebsd'): + if sys.platform == 'darwin' and sys.version_info <= (3, 5): test_requires.append('gnureadline==6.3.3') + elif sys.platform == 'win32' or sys.platform == 'cygwin': + test_requires.append('pyreadline==2.1') return test_requires From bb592ed7d40230801f4ea88ef51de67dc60aa7ac Mon Sep 17 00:00:00 2001 From: shunyi Date: Sat, 24 Feb 2018 21:59:24 +0800 Subject: [PATCH 5/6] [#148] Fix import_readline() for Windows env No need to use patch for linux, darwin and windows because we will run test on all these platforms. --- zdict/tests/test_utils.py | 10 ++-------- zdict/utils.py | 2 ++ 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/zdict/tests/test_utils.py b/zdict/tests/test_utils.py index ed84445d..40705e02 100644 --- a/zdict/tests/test_utils.py +++ b/zdict/tests/test_utils.py @@ -66,14 +66,8 @@ def test_platform_readline(): ''' Check the imported readline module on different platforms ''' - with patch.object(sys, 'platform', new='linux'): - readline = import_readline() - assert readline.__name__ == 'readline' - - with patch.object(sys, 'platform', new='darwin'): - readline = import_readline() - expect = 'gnureadline' if sys.version_info <= (3, 5) else 'readline' - assert readline.__name__ == expect + readline = import_readline() + assert readline.__name__ == 'readline' with patch.object(sys, 'platform', new='foo'): readline = import_readline() diff --git a/zdict/utils.py b/zdict/utils.py index 88a22b77..df0ab9ba 100644 --- a/zdict/utils.py +++ b/zdict/utils.py @@ -91,6 +91,8 @@ def print(self, *args, end='\n', **kwargs): def import_readline(): if sys.platform == 'darwin' and sys.version_info <= (3, 5): import gnureadline as readline + elif sys.platform == 'win32' or sys.platform == 'cygwin': + import pyreadline as readline else: import readline return readline From 59322eceafae16b5a4b7fe0778b8ef4519d891d1 Mon Sep 17 00:00:00 2001 From: shunyi Date: Sat, 24 Feb 2018 22:01:31 +0800 Subject: [PATCH 6/6] [#148] Install pyreadline when in Windows --- setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 2652d3c8..71dddc77 100644 --- a/setup.py +++ b/setup.py @@ -64,6 +64,8 @@ def run_tests(self): if sys.platform == 'darwin' and sys.version_info <= (3, 5): install_requires.append('gnureadline==6.3.3') +elif sys.platform == 'win32' or sys.platform == 'cygwin': + install_requires.append('pyreadline==2.1') setup(