Skip to content

Commit

Permalink
fix formatting using black
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Nov 29, 2020
1 parent d35c722 commit 140eb99
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
42 changes: 26 additions & 16 deletions setup.py
Expand Up @@ -35,35 +35,45 @@ def parse_version_from(path):
raise ValueError("couldn't parse version")
return version_match.group(1)


class NumpyBuildExtCommand(build_ext):
"""
build_ext command for use when numpy headers are needed.
from https://stackoverflow.com/questions/2379898/
and https://stackoverflow.com/questions/48283503/
"""

def run(self):
self.distribution.fetch_build_eggs(['numpy'])
self.distribution.fetch_build_eggs(["numpy"])
import numpy

self.include_dirs.append(numpy.get_include())
build_ext.run(self)

cmdclass = {'build_ext': NumpyBuildExtCommand}

redtoregext =\
setuptools.Extension("eccodes.high_level.redtoreg",['eccodes/high_level/redtoreg.pyx'])
cmdclass = {"build_ext": NumpyBuildExtCommand}

redtoregext = setuptools.Extension(
"eccodes.high_level.redtoreg", ["eccodes/high_level/redtoreg.pyx"]
)
if os.environ.get("ECCODES_DIR"):
eccdir = os.environ["ECCODES_DIR"]
incdirs=[os.path.join(eccdir,"include")]
libdirs=[os.path.join(eccdir,"lib"),os.path.join(eccdir,"lib64")]
pygribext =\
setuptools.Extension("eccodes.high_level.pygrib",['eccodes/high_level/pygrib.pyx'],\
include_dirs=incdirs,\
library_dirs=libdirs,\
runtime_library_dirs=libdirs,libraries=["eccodes"])
incdirs = [os.path.join(eccdir, "include")]
libdirs = [os.path.join(eccdir, "lib"), os.path.join(eccdir, "lib64")]
pygribext = setuptools.Extension(
"eccodes.high_level.pygrib",
["eccodes/high_level/pygrib.pyx"],
include_dirs=incdirs,
library_dirs=libdirs,
runtime_library_dirs=libdirs,
libraries=["eccodes"],
)
else:
pygribext =\
setuptools.Extension("eccodes.high_level.pygrib",['eccodes/high_level/pygrib.pyx'],\
libraries=["eccodes"])
pygribext = setuptools.Extension(
"eccodes.high_level.pygrib",
["eccodes/high_level/pygrib.pyx"],
libraries=["eccodes"],
)


setuptools.setup(
Expand All @@ -76,9 +86,9 @@ def run(self):
license="Apache License Version 2.0",
url="https://github.com/ecmwf/eccodes-python",
packages=setuptools.find_packages(),
cmdclass = cmdclass,
cmdclass=cmdclass,
include_package_data=True,
ext_modules = [redtoregext,pygribext],
ext_modules=[redtoregext, pygribext],
build_requires=["cython"],
install_requires=[
"attrs",
Expand Down
7 changes: 5 additions & 2 deletions tests/test_pygrib.py
Expand Up @@ -47,13 +47,16 @@ def test():
>>> grbs.close()
"""


if __name__ == "__main__":
import doctest

failure_count, test_count = doctest.testmod(verbose=True)
from eccodes import pygrib
import sys
sys.stdout.write('using ECCODES library version %s\n' % pygrib.grib_api_version)
if failure_count==0:

sys.stdout.write("using ECCODES library version %s\n" % pygrib.grib_api_version)
if failure_count == 0:
sys.exit(0)
else:
sys.exit(1)

0 comments on commit 140eb99

Please sign in to comment.