From b8e9aa80a3b7b0ea279ea2f0cc0e3a347740af9e Mon Sep 17 00:00:00 2001 From: Jos de Kloe Date: Nov 20 2016 13:10:00 +0000 Subject: update specfile and build patch to use the new release --- diff --git a/pygrib-2.0.1-build.patch b/pygrib-2.0.1-build.patch deleted file mode 100644 index 6ea6209..0000000 --- a/pygrib-2.0.1-build.patch +++ /dev/null @@ -1,94 +0,0 @@ ---- setup.py.orig 2016-01-21 21:46:30.437814697 +0100 -+++ setup.py 2016-01-21 22:02:55.376863983 +0100 -@@ -122,23 +122,33 @@ - if zlib_incdir is None and zlib_dir is not None: - incdirs.append(os.path.join(zlib_dir,'include')) - --g2clib_deps = glob.glob('g2clib_src/*.c') --g2clib_deps.append(g2clib_pyx) --incdirs.append("g2clib_src") -+#g2clib_deps = glob.glob('g2clib_src/*.c') -+#g2clib_deps.append(g2clib_pyx) -+g2clib_deps = [g2clib_pyx,] -+g2clib_dir = '/usr/lib64' -+g2clib_incdir = '/usr/include' -+libdirs.append(g2clib_dir) -+incdirs.append(g2clib_incdir) -+libraries.append('grib2c') -+#incdirs.append("g2clib_src") - macros=[] - --# if jasper or openjpeg lib not available... --if 'jasper' not in libraries and 'openjpeg' not in libraries: -- g2clib_deps.remove(os.path.join('g2clib_src', 'jpcpack.c')) -- g2clib_deps.remove(os.path.join('g2clib_src', 'jpcunpack.c')) --else: -- macros.append(('USE_JPEG2000',1)) --# if png lib not available... --if 'png' not in libraries: -- g2clib_deps.remove(os.path.join('g2clib_src', 'pngpack.c')) -- g2clib_deps.remove(os.path.join('g2clib_src', 'pngunpack.c')) --else: -- macros.append(('USE_PNG',1)) -+# the USE_JPEG2000 and USE_PNG defines are only used inside -+# g2clib_src, which is removed before doing the fedora rpm build -+# anyway, so these lines can be safely discarded: -+ -+## if jasper or openjpeg lib not available... -+#if 'jasper' not in libraries and 'openjpeg' not in libraries: -+# g2clib_deps.remove('g2clib_src/jpcpack.c') -+# g2clib_deps.remove('g2clib_src/jpcunpack.c') -+#else: -+# macros.append(('USE_JPEG2000',1)) -+## if png lib not available... -+#if 'png' not in libraries: -+# g2clib_deps.remove('g2clib_src/pngpack.c') -+# g2clib_deps.remove('g2clib_src/pngunpack.c') -+#else: -+# macros.append(('USE_PNG',1)) - - if hasattr(sys,'maxsize'): - if sys.maxsize > 2**31-1: macros.append(('__64BIT__',1)) -@@ -146,12 +156,12 @@ - if sys.maxint > 2**31-1: macros.append(('__64BIT__',1)) - - g2clibext = Extension("g2clib",g2clib_deps,include_dirs=incdirs,\ -- library_dirs=libdirs,libraries=libraries,runtime_library_dirs=libdirs,define_macros=macros) -+ library_dirs=libdirs,libraries=libraries,define_macros=macros) - redtoregext =\ - Extension("redtoreg",[redtoreg_pyx],include_dirs=[numpy.get_include()]) - pygribext =\ - Extension("pygrib",[pygrib_pyx],include_dirs=incdirs,library_dirs=libdirs,\ -- runtime_library_dirs=libdirs,libraries=libraries) -+ libraries=libraries) - - # man pages installed in man_dir/man1 - if man_dir is not None: -@@ -161,7 +171,16 @@ - else: - data_files = None - -- -+# don't provide the scripts and man pages for the python3 version, -+# to prevent rpm ownership collisions in case a user installs both -+# a python2 and a python3 version of the module -+scripts_list = [] -+if sys.version_info[0] < 3: -+ scripts_list = ['utils/grib_list','utils/grib_repack', -+ 'utils/cnvgrib1to2','utils/cnvgrib2to1'] -+if sys.version_info[0] >= 3: -+ data_files = None -+ - - setup(name = "pygrib", - version = "2.0.1", -@@ -171,8 +190,7 @@ - url = "https://github.com/jswhit/pygrib", - download_url = "http://python.org/pypi/pygrib", - cmdclass = cmdclass, -- scripts = -- ['utils/grib_list','utils/grib_repack','utils/cnvgrib1to2','utils/cnvgrib2to1'], -+ scripts = scripts_list, - ext_modules = [pygribext,g2clibext,redtoregext], - py_modules = ["ncepgrib2"], - data_files = data_files) diff --git a/pygrib-2.0.2-build.patch b/pygrib-2.0.2-build.patch new file mode 100644 index 0000000..1703084 --- /dev/null +++ b/pygrib-2.0.2-build.patch @@ -0,0 +1,94 @@ +--- setup.py.orig 2016-11-18 20:23:03.000000000 +0100 ++++ setup.py 2016-11-20 11:31:48.042087899 +0100 +@@ -122,23 +122,33 @@ + if zlib_incdir is None and zlib_dir is not None: + incdirs.append(os.path.join(zlib_dir,'include')) + +-g2clib_deps = glob.glob('g2clib_src/*.c') +-g2clib_deps.append(g2clib_pyx) +-incdirs.append("g2clib_src") ++#g2clib_deps = glob.glob('g2clib_src/*.c') ++#g2clib_deps.append(g2clib_pyx) ++g2clib_deps = [g2clib_pyx,] ++g2clib_dir = '/usr/lib64' ++g2clib_incdir = '/usr/include' ++libdirs.append(g2clib_dir) ++incdirs.append(g2clib_incdir) ++libraries.append('grib2c') ++#incdirs.append("g2clib_src") + macros=[] + +-# if jasper or openjpeg lib not available... +-if 'jasper' not in libraries and 'openjpeg' not in libraries: +- g2clib_deps.remove(os.path.join('g2clib_src', 'jpcpack.c')) +- g2clib_deps.remove(os.path.join('g2clib_src', 'jpcunpack.c')) +-else: +- macros.append(('USE_JPEG2000',1)) +-# if png lib not available... +-if 'png' not in libraries: +- g2clib_deps.remove(os.path.join('g2clib_src', 'pngpack.c')) +- g2clib_deps.remove(os.path.join('g2clib_src', 'pngunpack.c')) +-else: +- macros.append(('USE_PNG',1)) ++# the USE_JPEG2000 and USE_PNG defines are only used inside ++# g2clib_src, which is removed before doing the fedora rpm build ++# anyway, so these lines can be safely discarded: ++ ++## if jasper or openjpeg lib not available... ++#if 'jasper' not in libraries and 'openjpeg' not in libraries: ++# g2clib_deps.remove('g2clib_src/jpcpack.c') ++# g2clib_deps.remove('g2clib_src/jpcunpack.c') ++#else: ++# macros.append(('USE_JPEG2000',1)) ++## if png lib not available... ++#if 'png' not in libraries: ++# g2clib_deps.remove('g2clib_src/pngpack.c') ++# g2clib_deps.remove('g2clib_src/pngunpack.c') ++#else: ++# macros.append(('USE_PNG',1)) + + if hasattr(sys,'maxsize'): + if sys.maxsize > 2**31-1: macros.append(('__64BIT__',1)) +@@ -146,12 +156,12 @@ + if sys.maxint > 2**31-1: macros.append(('__64BIT__',1)) + + g2clibext = Extension("g2clib",g2clib_deps,include_dirs=incdirs,\ +- library_dirs=libdirs,libraries=libraries,runtime_library_dirs=libdirs,define_macros=macros) ++ library_dirs=libdirs,libraries=libraries,define_macros=macros) + redtoregext =\ + Extension("redtoreg",[redtoreg_pyx],include_dirs=[numpy.get_include()]) + pygribext =\ + Extension("pygrib",[pygrib_pyx],include_dirs=incdirs,library_dirs=libdirs,\ +- runtime_library_dirs=libdirs,libraries=libraries) ++ libraries=libraries) + + # man pages installed in man_dir/man1 + if man_dir is not None: +@@ -161,7 +171,16 @@ + else: + data_files = None + +- ++# don't provide the scripts and man pages for the python3 version, ++# to prevent rpm ownership collisions in case a user installs both ++# a python2 and a python3 version of the module ++scripts_list = [] ++if sys.version_info[0] < 3: ++ scripts_list = ['utils/grib_list','utils/grib_repack', ++ 'utils/cnvgrib1to2','utils/cnvgrib2to1'] ++if sys.version_info[0] >= 3: ++ data_files = None ++ + + setup(name = "pygrib", + version = "2.0.2", +@@ -184,8 +203,7 @@ + "License :: OSI Approved", + "Topic :: Software Development :: Libraries :: Python Modules"], + cmdclass = cmdclass, +- scripts = +- ['utils/grib_list','utils/grib_repack','utils/cnvgrib1to2','utils/cnvgrib2to1'], ++ scripts = scripts_list, + ext_modules = [pygribext,g2clibext,redtoregext], + py_modules = ["ncepgrib2"], + data_files = data_files) diff --git a/pygrib.spec b/pygrib.spec index 9b7a4be..d26f2cd 100644 --- a/pygrib.spec +++ b/pygrib.spec @@ -1,17 +1,17 @@ -# This module also works with Python 3 +# This module works with Python 2 and 3 %if 0%{?fedora} || 0%{?rhel} > 6 %global with_python3 1 %endif Name: pygrib -Version: 2.0.1 -Release: 3%{?dist} +Version: 2.0.2 +Release: 1%{?dist} Summary: Python module for reading and writing GRIB (editions 1 and 2) files License: MIT Group: Applications/Engineering URL: https://github.com/jswhit/pygrib -Source0: https://pypi.python.org/packages/source/p/%{name}/%{name}-%{version}.tar.gz +Source0: https://files.pythonhosted.org/packages/source/p/pygrib/%{name}-%{version}.tar.gz # Adapt setup.py to not use packaged g2clib source code Patch0: %%{name}-%%{version}-build.patch @@ -32,7 +32,7 @@ BuildRequires: python3-pyproj # a note on the build requirements: # pygrib installation instructions mention these requirements: # $GRIBAPI_DIR, $JASPER_DIR, $OPENJPEG_DIR, $PNG_DIR and $ZLIB_DIR -# (see http://pygrib.googlecode.com/svn/trunk/docs/index.html) +# (see https://jswhit.github.io/pygrib/docs/index.html) # # grib_api-devel is mentioned above. # g2clib-devel is included in the pygrib sources, but has been removed @@ -79,10 +79,19 @@ and writing GRIB data using the ECMWF GRIB API C library, and the NCEP GRIB2 C library, as well as command-line utilities for listing and re-packing GRIB files. +# provide python2.pygrib as well +%python_provide python2-%{name} + +# this should evaluate to Provides: python2-pygrib +%{?python_provide:%python_provide python-%{name}} + %if 0%{?with_python3} %package -n python3-%{name} Summary: Python3 module for reading and writing GRIB (editions 1 and 2) files +# ensure python provides are provided when python3 becomes the default runtime +%{?python_provide:%python_provide python3-%{name}} + # it seems this requires must be specified before the description section # or it will be ignored ... Requires: python3-pyproj @@ -170,35 +179,42 @@ export PYTHONPATH=%{buildroot}/%{python3_sitearch} %endif # if with_python3 %files -%doc COPYING PKG-INFO +%doc COPYING PKG-INFO README.md %doc docs ncepgrib2_docs # For arch-specific packages: sitearch %{python2_sitearch}/*.so %{python2_sitearch}/ncep*.py* %{python2_sitearch}/%{name}-*-py*.egg-info -%{_bindir}/cnv* -%{_bindir}/grib_* -%{_mandir}/man1/cnv* -%{_mandir}/man1/grib_* +# these are only provided for python3 +# as required by the python3=default choice for Fedora +#%%{_bindir}/cnv* +#%%{_bindir}/grib_* +#%%{_mandir}/man1/cnv* +#%%{_mandir}/man1/grib_* %if 0%{?with_python3} %files -n python3-%{name} -%doc COPYING PKG-INFO +%doc COPYING PKG-INFO README.md %doc docs ncepgrib2_docs %{python3_sitearch}/*.so %{python3_sitearch}/ncep*.py* %{python3_sitearch}/__pycache__/ncep*.py* %{python3_sitearch}/%{name}-*-py*.egg-info -# these are only provided for python2 for now -#%%{_bindir}/cnv* -#%%{_bindir}/grib_* -#%%{_mandir}/man1/cnv* -#%%{_mandir}/man1/grib_* +%{_bindir}/cnv* +%{_bindir}/grib_* +%{_mandir}/man1/cnv* +%{_mandir}/man1/grib_* %endif # with_python3 %changelog + +* Sun Nov 20 2016 Jos de Kloe 2.0.2-1 +- provide tools below /usr/bin for python3 in stead of python2 +- move to new predictable pypi source location +- add python_provide macros + * Tue Jul 19 2016 Fedora Release Engineering - 2.0.1-3 - https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages