From b66b684d5cea3d5e9c4bf1c035f6db9dcfc87401 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Thu, 20 Aug 2020 14:28:00 -0400 Subject: [PATCH 1/9] Fix unable to build Pandas with xlc on z/OS --- doc/source/whatsnew/v1.2.0.rst | 2 +- pandas/_libs/src/headers/cmath | 12 ++++++++++++ setup.py | 24 ++++++++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v1.2.0.rst b/doc/source/whatsnew/v1.2.0.rst index f27c83fafef55..b742c09c4c3a1 100644 --- a/doc/source/whatsnew/v1.2.0.rst +++ b/doc/source/whatsnew/v1.2.0.rst @@ -276,7 +276,7 @@ ExtensionArray Other ^^^^^ -- +- Fixed Pandas not being able to compile on z/OS when using xlc (:issue:`35826`) - .. --------------------------------------------------------------------------- diff --git a/pandas/_libs/src/headers/cmath b/pandas/_libs/src/headers/cmath index 632e1fc2390d0..9e7540cfefc13 100644 --- a/pandas/_libs/src/headers/cmath +++ b/pandas/_libs/src/headers/cmath @@ -25,6 +25,18 @@ namespace std { __inline int isnan(double x) { return _isnan(x); } __inline int notnan(double x) { return x == x; } } +#elif defined(__MVS__) +#include + +#define _signbit signbit +#undef signbit +#undef isnan + +namespace std { + __inline int notnan(double x) { return x == x; } + __inline int signbit(double num) { return _signbit(num); } + __inline int isnan(double x) { return isnan(x); } +} #else #include diff --git a/setup.py b/setup.py index f6f0cd9aabc0e..0efcf0c98e7e9 100755 --- a/setup.py +++ b/setup.py @@ -33,6 +33,10 @@ def is_platform_mac(): return sys.platform == "darwin" +def is_platform_zos(): + return sys.platform == "zos" + + min_numpy_ver = "1.16.5" min_cython_ver = "0.29.16" # note: sync with pyproject.toml @@ -681,15 +685,31 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): include = data.get("include") + extra_comp_args = extra_compile_args.copy() + comp_macros = data.get("macros", macros) + undef_macros = [] + + if is_platform_zos(): + language = data.get("language", None) + if language == "c++": + compiler = os.environ.get("CXX", "/bin/xlc++") + compiler_name = os.path.basename(compiler) + + if (compiler_name == "xlc") or (compiler_name == "xlc++"): + comp_macros.append(("__s390__", "1")) + extra_comp_args.append("-qlanglvl=extended0x:nolibext") + undef_macros.append("_POSIX_THREADS") + obj = Extension( f"pandas.{name}", sources=sources, depends=data.get("depends", []), include_dirs=include, language=data.get("language", "c"), - define_macros=data.get("macros", macros), - extra_compile_args=extra_compile_args, + define_macros=comp_macros, + extra_compile_args=extra_comp_args, extra_link_args=extra_link_args, + undef_macros=undef_macros ) extensions.append(obj) From 0a9db9559d672518e998810e8772b0052ce5fb0f Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Tue, 13 Oct 2020 12:37:14 -0400 Subject: [PATCH 2/9] Fix styling pre-commit failure --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d0ff0f08913ec..5c8b1eda4d6a7 100755 --- a/setup.py +++ b/setup.py @@ -709,7 +709,7 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): define_macros=comp_macros, extra_compile_args=extra_comp_args, extra_link_args=extra_link_args, - undef_macros=undef_macros + undef_macros=undef_macros, ) extensions.append(obj) From 4ba6b142274cd9c20d2db2969eb5df845f32bf60 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Mon, 4 Jan 2021 16:48:57 +0000 Subject: [PATCH 3/9] Add z/OS support to 1.3.0 docs --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index b4b98ec0403a8..eeffd11b3690b 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -322,7 +322,7 @@ ExtensionArray Other ^^^^^ - Bug in :class:`Index` constructor sometimes silently ignorning a a specified ``dtype`` (:issue:`38879`) -- +- Fixed Pandas not being able to compile on z/OS when using xlc (:issue:`35826`) - .. --------------------------------------------------------------------------- From 02591d982d5938c1aa79e019f46b457a755041e6 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Fri, 30 Apr 2021 12:45:12 -0500 Subject: [PATCH 4/9] Revert accidental merge conflict addition --- doc/source/whatsnew/v1.3.0.rst | 3 --- 1 file changed, 3 deletions(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 4a2e0e8084d01..640ff1e6e13d5 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -903,9 +903,6 @@ Styler Other ^^^^^ -- Bug in :class:`Index` constructor sometimes silently ignorning a a specified ``dtype`` (:issue:`38879`) -- -======= - Bug in :class:`Index` constructor sometimes silently ignoring a specified ``dtype`` (:issue:`38879`) - Bug in :func:`pandas.api.types.infer_dtype` not recognizing Series, Index or array with a period dtype (:issue:`23553`) - Bug in :func:`pandas.api.types.infer_dtype` raising an error for general :class:`.ExtensionArray` objects. It will now return ``"unknown-array"`` instead of raising (:issue:`37367`) From 18688a1b72916f18b2328dd6e9792806e04766d7 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Fri, 30 Apr 2021 12:55:42 -0500 Subject: [PATCH 5/9] Add link to xlc homepage --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index 640ff1e6e13d5..d575a344e5df6 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -913,7 +913,7 @@ Other - Bug in :func:`pandas.testing.assert_series_equal`, :func:`pandas.testing.assert_frame_equal`, :func:`pandas.testing.assert_index_equal` and :func:`pandas.testing.assert_extension_array_equal` incorrectly raising when an attribute has an unrecognized NA type (:issue:`39461`) - Bug in :meth:`DataFrame.equals`, :meth:`Series.equals`, :meth:`Index.equals` with object-dtype containing ``np.datetime64("NaT")`` or ``np.timedelta64("NaT")`` (:issue:`39650`) - Bug in :func:`pandas.util.show_versions` where console JSON output was not proper JSON (:issue:`39701`) -- Fixed Pandas not being able to compile on z/OS when using xlc (:issue:`35826`) +- Fixed Pandas not being able to compile on z/OS when using `xlc `_ (:issue:`35826`) - Bug in :meth:`DataFrame.convert_dtypes` incorrectly raised ValueError when called on an empty DataFrame (:issue:`40393`) - Bug in :meth:`DataFrame.clip` not interpreting missing values as no threshold (:issue:`40420`) From 06f304c02e981b99957330304d4d4831fe638e50 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Wed, 12 May 2021 12:55:44 +0000 Subject: [PATCH 6/9] Swap doc wording for getting pandas to compile with xlc --- doc/source/whatsnew/v1.3.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.3.0.rst b/doc/source/whatsnew/v1.3.0.rst index d575a344e5df6..441116376d52b 100644 --- a/doc/source/whatsnew/v1.3.0.rst +++ b/doc/source/whatsnew/v1.3.0.rst @@ -913,7 +913,7 @@ Other - Bug in :func:`pandas.testing.assert_series_equal`, :func:`pandas.testing.assert_frame_equal`, :func:`pandas.testing.assert_index_equal` and :func:`pandas.testing.assert_extension_array_equal` incorrectly raising when an attribute has an unrecognized NA type (:issue:`39461`) - Bug in :meth:`DataFrame.equals`, :meth:`Series.equals`, :meth:`Index.equals` with object-dtype containing ``np.datetime64("NaT")`` or ``np.timedelta64("NaT")`` (:issue:`39650`) - Bug in :func:`pandas.util.show_versions` where console JSON output was not proper JSON (:issue:`39701`) -- Fixed Pandas not being able to compile on z/OS when using `xlc `_ (:issue:`35826`) +- Let Pandas compile on z/OS when using `xlc `_ (:issue:`35826`) - Bug in :meth:`DataFrame.convert_dtypes` incorrectly raised ValueError when called on an empty DataFrame (:issue:`40393`) - Bug in :meth:`DataFrame.clip` not interpreting missing values as no threshold (:issue:`40420`) From a072833e0bd95a25f8163a5d07d1b953fde1c103 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Thu, 13 May 2021 13:21:41 +0000 Subject: [PATCH 7/9] Address review comments - shrink setup changes --- setup.py | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/setup.py b/setup.py index e847beeb14a67..a62736f591e27 100755 --- a/setup.py +++ b/setup.py @@ -38,10 +38,6 @@ def is_platform_mac(): return sys.platform == "darwin" -def is_platform_zos(): - return sys.platform == "zos" - - min_cython_ver = "0.29.21" # note: sync with pyproject.toml try: @@ -573,20 +569,12 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): include = data.get("include", []) include.append(numpy.get_include()) - extra_comp_args = extra_compile_args.copy() - comp_macros = data.get("macros", macros) undef_macros = [] - if is_platform_zos(): - language = data.get("language", None) - if language == "c++": - compiler = os.environ.get("CXX", "/bin/xlc++") - compiler_name = os.path.basename(compiler) - - if (compiler_name == "xlc") or (compiler_name == "xlc++"): - comp_macros.append(("__s390__", "1")) - extra_comp_args.append("-qlanglvl=extended0x:nolibext") - undef_macros.append("_POSIX_THREADS") + if sys.platform == "zos" and data.get("language") == "c++" and os.path.basename(os.environ.get("CXX", "/bin/xlc++")) in ('xlc', 'xlc++'): + data.get("macros", macros).append(("__s390__", "1")) + extra_compile_args.append("-qlanglvl=extended0x:nolibext") + undef_macros.append("_POSIX_THREADS") obj = Extension( f"pandas.{name}", @@ -594,8 +582,8 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): depends=data.get("depends", []), include_dirs=include, language=data.get("language", "c"), - define_macros=comp_macros, - extra_compile_args=extra_comp_args, + define_macros=data.get("macros", macros), + extra_compile_args=extra_compile_args, extra_link_args=extra_link_args, undef_macros=undef_macros, ) From 28ff70790940d79ef5b2e8f2b71614831210c575 Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Thu, 13 May 2021 13:49:10 +0000 Subject: [PATCH 8/9] Fix line too long --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index a62736f591e27..44c91171e6e7c 100755 --- a/setup.py +++ b/setup.py @@ -571,7 +571,8 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): undef_macros = [] - if sys.platform == "zos" and data.get("language") == "c++" and os.path.basename(os.environ.get("CXX", "/bin/xlc++")) in ('xlc', 'xlc++'): + if sys.platform == "zos" and data.get("language") == "c++" and \ + os.path.basename(os.environ.get("CXX", "/bin/xlc++")) in ('xlc', 'xlc++'): data.get("macros", macros).append(("__s390__", "1")) extra_compile_args.append("-qlanglvl=extended0x:nolibext") undef_macros.append("_POSIX_THREADS") From 2c7d3f7f55bbfb66c0f9b55b418eb1380fd20c1e Mon Sep 17 00:00:00 2001 From: Steven Pitman Date: Thu, 13 May 2021 18:56:32 +0000 Subject: [PATCH 9/9] Apply styling changes from black --- setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 44c91171e6e7c..17ee110bc4136 100755 --- a/setup.py +++ b/setup.py @@ -571,8 +571,11 @@ def srcpath(name=None, suffix=".pyx", subdir="src"): undef_macros = [] - if sys.platform == "zos" and data.get("language") == "c++" and \ - os.path.basename(os.environ.get("CXX", "/bin/xlc++")) in ('xlc', 'xlc++'): + if ( + sys.platform == "zos" + and data.get("language") == "c++" + and os.path.basename(os.environ.get("CXX", "/bin/xlc++")) in ("xlc", "xlc++") + ): data.get("macros", macros).append(("__s390__", "1")) extra_compile_args.append("-qlanglvl=extended0x:nolibext") undef_macros.append("_POSIX_THREADS")