Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@

[submodule "cFMS"]
path = cFMS
url = https://github.com/NOAA-GFDL/cFMS.git
branch = main
1 change: 0 additions & 1 deletion cFMS
Submodule cFMS deleted from b9ebf8
78 changes: 0 additions & 78 deletions compile_c_libs.sh

This file was deleted.

10 changes: 3 additions & 7 deletions pyfms/cfms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import ctypes
import os

import pyfms

Expand All @@ -26,14 +25,11 @@ def init(libpath: str = None):
# todo reset all _function parameters to None

if libpath is None:
_libpath = os.path.dirname(__file__) + "/lib/cFMS/lib/libcFMS.so"
_libpath = "libcFMS.so"
try:
_lib = ctypes.cdll.LoadLibrary(_libpath)
except OSError:
print(
f"{_libpath} does not exist. Please provide a path to cFMS with\
pyfms.cfms.init(libpath=path_to_cfms)"
)
except Exception as e:
print(f"{type(e).__name__}: {e}")
return
else:
_libpath = libpath
Expand Down
29 changes: 23 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,31 @@
import subprocess

from setuptools import find_namespace_packages, setup
from setuptools.command.build import build
from setuptools.command.editable_wheel import editable_wheel as _editable_wheel
from setuptools.command.install import install as _install


class CustomBuild(build):
class editable_wheel(_editable_wheel):
def run(self):
with open("install.log", "w") as f:
subprocess.run(["./compile_c_libs.sh"], stdout=f, check=True)
build.run(self)
print("Installing cFMS")
try:
subprocess.run(["conda", "install", "-y", "-c", "file:///home/Frank.Malatino/cfms_conda_channel", "cfms"], check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
print(f"Error during conda install of cFMS: {e}")
print("STDOUT:", e.stdout)
print("STDERR:", e.stderr)
_editable_wheel.run(self)

class install(_install):
def run(self):
print("Installing cFMS")
try:
subprocess.run(["conda", "install", "-y", "-c", "file:///home/Frank.Malatino/cfms_conda_channel", "cfms"], check=True, capture_output=True, text=True)
except subprocess.CalledProcessError as e:
print(f"Error during conda install of cFMS: {e}")
print("STDOUT:", e.stdout)
print("STDERR:", e.stderr)
_install.run(self)


test_requirements = ["pytest", "pytest-subtests", "coverage"]
Expand Down Expand Up @@ -44,7 +61,7 @@ def run(self):
name="pyfms",
license="",
packages=find_namespace_packages(include=["pyfms", "pyfms.*"]),
cmdclass={"build": CustomBuild},
cmdclass={"editable_wheel": editable_wheel, "install": install},
include_package_data=True,
url="https://github.com/fmalatino/pyFMS.git",
version="2024.02.0",
Expand Down
Loading