Skip to content

Commit

Permalink
remove c++ source code
Browse files Browse the repository at this point in the history
  • Loading branch information
changliao1025 committed Apr 16, 2024
1 parent 1415ca9 commit 78f78ff
Show file tree
Hide file tree
Showing 7 changed files with 216 additions and 138 deletions.
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ authors:
given-names: Chang
orcid: https://orcid.org/0000-0002-7348-8858
title: "HexWatershed: a mesh-independent flow direction model for hydrologic models"
version: 0.2.25
version: 0.2.26
doi: 10.5281/zenodo.6425881
date-released: 2022-03-31
2 changes: 1 addition & 1 deletion conda-recipe/conda_build_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
# Package name
name: hexwatershed
# Package version
version: "0.2.25"
version: "0.2.26"
# Package summary
summary: A mesh-independent flow direction model for hydrologic models
# Package homepage
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% set name = "hexwatershed" %}
{% set git_rev = "main" %}
{% set version = "0.2.25" %}
{% set version = "0.2.26" %}

package:
name: {{ name|lower }}
Expand Down
4 changes: 2 additions & 2 deletions pyhexwatershed/classes/pycase.py
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,8 @@ def pyhexwatershed_export(self):
else:
#if the pyflowline does not turn on flowline,
#then we need to include at least one watershed
#self.pyhexwatershed_export_flow_direction()
#self.pyhexwatershed_export_stream_segment()
self.pyhexwatershed_export_flow_direction()
self.pyhexwatershed_export_stream_segment()

#polygon
#self.pyhexwatershed_export_elevation()
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.25
current_version = 0.2.26
commit = True
tag = True

Expand Down
134 changes: 2 additions & 132 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
AUTHOR = "Chang Liao"
AUTHOR_EMAIL = "chang.liao@pnnl.gov"
URL = "https://github.com/changliao1025/pyhexwatershed"
VERSION = "0.2.25"
VERSION = "0.2.26"
REQUIRES_PYTHON = ">=3.8.0"
KEYWORDS = ["hexwatershed",
"hydrology",
Expand All @@ -38,28 +38,7 @@
"Topic :: Scientific/Engineering :: Hydrology",
"Topic :: Scientific/Engineering :: GIS",
"Topic :: Scientific/Engineering :: Physics"
]

def get_data_files(sFolder_in):
data_files_tmp = []
for root, dirs, files in os.walk(sFolder_in):
for file in files:
data_files_tmp.append(os.path.join(root, file))

#print(data_files_tmp)
return data_files_tmp


data_files=[ ( 'external/hexwatershed/', ["external/hexwatershed/CMakeLists.txt"] ) ,
( "external/rapidjson/" , get_data_files('external/rapidjson') ),
( "external/rapidjson/error/" , get_data_files('external/rapidjson/error/') ),
( "external/rapidjson/internal/" , get_data_files('external/rapidjson/internal') ),
( "external/rapidjson/msinttypes/" , get_data_files('external/rapidjson/msinttypes') ),
( "external/hexwatershed/src" , get_data_files('external/hexwatershed/src') ),
( "external/hexwatershed/src/compset/", get_data_files('external/hexwatershed/src/compset') ),
( "external/hexwatershed/src/domain/" , get_data_files('external/hexwatershed/src/domain') ),
( "external/hexwatershed/src/json/" , get_data_files('external/hexwatershed/src/json') )
]
]

HERE = os.path.abspath(os.path.dirname(__file__))
HERE = os.path.expandvars(HERE)
Expand All @@ -77,111 +56,6 @@ def get_data_files(sFolder_in):
except FileNotFoundError:
LONG_DESCRIPTION = DESCRIPTION

def get_cmake_version():
try:
out = subprocess.check_output(
["cmake", "--version"]).decode("utf-8")
sln = out.splitlines()[0]
ver = sln.split()[2]
return ver

except:
print("cmake not found!")

class build_external(Command):

description = "build external hexwatershed dependencies"

user_options = []

def initialize_options(self): pass

def finalize_options(self): pass

def run(self):
"""
The actual cmake-based build steps for hexwatershed
"""
if (self.dry_run): return

cwd_pointer = os.getcwd()

try:
self.announce("cmake config.", level=3)

source_path = os.path.join(
HERE, "external", "hexwatershed")

source_path = os.path.expandvars(source_path)

# Check if the expanded path exists
if os.path.exists(source_path):
print('Path exists:', source_path)
else:
print('Path does not exist:', source_path)

builds_path = os.path.join(source_path, "build")

if os.path.exists(builds_path):
sFilename_cache = os.path.join(builds_path, "CMakeCache.txt")
if os.path.exists(sFilename_cache):
os.remove(sFilename_cache)
else:
#print('File or directory does not exist')
pass
pass
else:
os.mkdir(builds_path)

exesrc_path = \
os.path.join(source_path, "bin")

libsrc_path = \
os.path.join(source_path, "lib")

exedst_path = os.path.join(
HERE, "pyhexwatershed", "_bin")

libdst_path = os.path.join(
HERE, "pyhexwatershed", "_lib")

shutil.rmtree(
exedst_path, ignore_errors=True)
shutil.rmtree(
libdst_path, ignore_errors=True)

os.chdir(builds_path)
#copy cmakelistx.txt to the build folder
dst = os.getcwd()
shutil.copy("../CMakeLists.txt", dst)
config_call = ["cmake", "CMakeLists.txt"]
#' -G "Unix Makefiles"',
subprocess.run(config_call, check=True)

self.announce("cmake complie", level=3)

ver = get_cmake_version()

compilecall = [
"cmake", "--build", ".",
"--config", "Release",
"--target", "install"
]


subprocess.run(compilecall, check=True)

self.announce("cmake cleanup", level=3)

shutil.copytree(exesrc_path, exedst_path)
#shutil.copytree(libsrc_path, libdst_path)

finally:
os.chdir(cwd_pointer)
shutil.rmtree(builds_path)


setup(
name=NAME,
version=VERSION,
Expand All @@ -196,11 +70,7 @@ def run(self):
url=URL,
setup_requires=['setuptools'],
packages=find_packages(),
package_data={
"pyhexwatershed": ["_bin/*", "_lib/*"]
},
install_requires=REQUIRED,
cmdclass={"build_external": build_external},
classifiers=CLASSIFY,
extras_require={
'visualization': ['cython', 'matplotlib', 'cartopy>=0.21.0']
Expand Down
Loading

0 comments on commit 78f78ff

Please sign in to comment.