Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
290 lines (266 loc) · 11.5 KB
/
Copy pathsetup.py
File metadata and controls
290 lines (266 loc) · 11.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
from setuptools import setup, find_packages
from setuptools.command.build_py import build_py
import subprocess
from pathlib import Path
# The native (Rust) HDF engine is ras-commander's default HDF engine. It is
# published as binary wheels only for CPython on Windows x64, Linux x64
# (manylinux_2_28) and macOS arm64, so the marker limits the dependency to those
# platforms and pip never tries to compile the Rust source distribution
# elsewhere. Where the extension is not installed, every read uses h5py.
FAST_HDF_REQUIREMENT = 'ras-commander-fast-hdf>=0.5.0,<0.6'
FAST_MAP_REQUIREMENT = 'ras-commander-fast-map>=0.21.0,<0.22'
FAST_MAP_WHEEL_MARKER = (
'(platform_system == "Windows" and platform_machine == "AMD64")'
' or (platform_system == "Linux" and platform_machine == "x86_64")'
)
FAST_HDF_WHEEL_MARKER = (
'platform_python_implementation == "CPython" and ('
'(platform_system == "Windows" and platform_machine == "AMD64")'
' or (platform_system == "Linux" and platform_machine == "x86_64")'
' or (platform_system == "Darwin" and platform_machine == "arm64"))'
)
# The native DSS engine (FAST-DSS) is optional: the default DSS backend is
# "java". Release 0.1.2 is published as abi3 wheels for CPython 3.10+ on
# Windows x64 and Linux x86_64/aarch64 (manylinux and musllinux) only, so the
# marker keeps pip from compiling the Rust source distribution elsewhere.
# There are no macOS wheels; macOS users can build it from the sdist with
# `pip install ras-commander-fast-dss` and a Rust toolchain.
FAST_DSS_REQUIREMENT = 'ras-commander-fast-dss>=0.1.2,<0.2'
FAST_DSS_WHEEL_MARKER = (
'platform_python_implementation == "CPython" and ('
'(platform_system == "Windows" and platform_machine == "AMD64")'
' or (platform_system == "Linux" and platform_machine == "x86_64")'
' or (platform_system == "Linux" and platform_machine == "aarch64"))'
)
FAST_DSS_DEPENDENCY = f'{FAST_DSS_REQUIREMENT}; {FAST_DSS_WHEEL_MARKER}'
# Keep the default installation import-safe and suitable for inventory/HDF work.
# Feature groups are additive so batch runners can install only what they use.
CORE_DEPENDENCIES = [
'h5py',
'numpy',
'pandas',
f'{FAST_HDF_REQUIREMENT}; {FAST_HDF_WHEEL_MARKER}',
]
COMPUTE_DEPENDENCIES = [
'psutil>=5.6.6', # Process supervision and the default dialog watchdog
'pywin32>=227; sys_platform == "win32"', # Windows dialog watchdog primitives
]
FULL_FEATURE_DEPENDENCIES = [
f'{FAST_MAP_REQUIREMENT}; {FAST_MAP_WHEEL_MARKER}',
'requests',
'tqdm',
'scipy',
'xarray',
'geopandas',
'matplotlib',
'shapely>=2.0',
'rasterio',
'affine>=3', # ras_commander.fim composes transforms with Affine @ Affine
'rioxarray',
'cfgrib>=0.9.10',
'eccodes>=2.28',
'pyarrow>=14.0',
'pyproj',
'rasterstats',
'rtree',
'fsspec>=2023.0.0',
'hms-commander>=0.3.1',
]
class CustomBuildPy(build_py):
def run(self):
# Clean up __pycache__ folders
root_dir = Path(__file__).parent
for pycache_dir in root_dir.rglob('__pycache__'):
if pycache_dir.is_dir():
for cache_file in pycache_dir.iterdir():
cache_file.unlink() # Delete each file
pycache_dir.rmdir() # Delete the empty directory
print(f"Cleaned up: {pycache_dir}")
# Skip knowledge base generation on ReadTheDocs (causes build timeout)
# and in CI environments where it's not needed
import os
if os.environ.get('READTHEDOCS') or os.environ.get('CI'):
print("Skipping knowledge base generation (docs/CI build detected)")
else:
# Run the summary_knowledge_bases.py script
script_path = Path(__file__).parent / 'ai_tools' / 'generate_llm_knowledge_bases.py'
try:
subprocess.run(['python', str(script_path)], check=True)
except subprocess.CalledProcessError:
print("Warning: Knowledge base generation script failed, continuing with build")
except FileNotFoundError:
print("Warning: Knowledge base generation script not found, continuing with build")
# Continue with the regular build process
super().run()
setup(
name="ras-commander",
version="0.122.0",
packages=find_packages(include=['ras_commander', 'ras_commander.*']),
include_package_data=True,
package_data={
"ras_commander": [
"LLM_GUIDE.md",
"fim/THIRD_PARTY_NOTICES.md",
"resources/*.json",
"resources/templates/*/*",
],
"ras_commander.native": [
"InvokeRas5GeometryLandCover.ps1",
"InvokeRas5LandCover.ps1",
"RasStoreMapHelper.exe",
"RasStoreMapHelper.exe.config",
"RasStoreMapHelper.cs",
"RasMetImportHelper.cs",
"RasMapperTerrainExportHelper.exe",
"RasMapperTerrainExportHelper.cs",
"BuildRasMapperTerrainExportHelper.ps1",
],
},
python_requires='>=3.10',
author="William M. Katzenmeyer, P.E., C.F.M.",
author_email="info@clbengineering.com",
description="A Python library for automating HEC-RAS 6.x operations",
long_description=open('README.md').read(),
long_description_content_type="text/markdown",
url="https://github.com/gpt-cmdr/ras-commander",
project_urls={
"Documentation": "https://rascommander.info/ras/",
"AI Agent Guide": "https://rascommander.info/ras/llms.txt",
"Citation": "https://rascommander.info/ras/cite/",
"Changelog": "https://rascommander.info/ras/development/release-notes/",
"Source": "https://github.com/gpt-cmdr/ras-commander",
},
cmdclass={
'build_py': CustomBuildPy,
},
install_requires=CORE_DEPENDENCIES,
extras_require={
# No longer needed: the native HDF engine is a core dependency on the
# platforms that have wheels. Kept so existing install commands work.
# Without the platform marker, these extras also request the engine on
# other platforms, where pip builds it from source (needs Rust).
# "fast-hdf" is an alias.
'fast': [FAST_HDF_REQUIREMENT],
'fast-hdf': [FAST_HDF_REQUIREMENT],
# Lean Windows/Wine batch execution through RasCmdr.compute_plan().
# This intentionally excludes the RasControl COM interface and the
# geospatial/plotting stack. "execution" is a descriptive alias.
'compute': COMPUTE_DEPENDENCIES,
'execution': COMPUTE_DEPENDENCIES,
# Preserve the historical default feature dependency surface for
# users who need every ras-commander module.
'full': FULL_FEATURE_DEPENDENCIES + COMPUTE_DEPENDENCIES,
# Remote execution backends (PsExec worker has no extra deps)
'remote': [], # Base remote - PsExec only, no additional deps
'remote-docker': ['docker>=6.0'],
# paramiko backs DockerWorker SSH/SFTP staging for ssh:// Docker hosts.
'remote-all': [
'paramiko>=3.0',
'docker>=6.0',
],
# GUI automation and screenshot capture (Windows only)
'gui': [
'Pillow>=9.0',
'psutil>=5.6.6',
'comtypes>=1.4.0; sys_platform == "win32"',
],
# Optional mapping engine and Python preparation/delivery stack.
# Runtime calls never download or compile the engine.
'fast-map': [f'{FAST_MAP_REQUIREMENT}; {FAST_MAP_WHEEL_MARKER}'],
'fim': ['scipy', 'geopandas', 'shapely>=2.0', 'rasterio', 'affine>=3', 'pyproj',
f'{FAST_MAP_REQUIREMENT}; {FAST_MAP_WHEEL_MARKER}'],
# USGS gauge data integration
'usgs': ['dataretrieval>=1.4'],
# FEMA eBFE archives that use Deflate64 compression (ZIP method 9).
# Upstream publishes wheels only through CPython 3.10; keep this out of
# the broad ``all`` extra so current Python installs do not require an
# unqualified native source build.
'ebfe': ['zipfile-deflate64; python_version < "3.11"'],
# Precipitation enhancements
'precip': [
'xarray',
'h5netcdf',
'scipy',
'rasterio',
'rioxarray',
'cfgrib>=0.9.10',
'eccodes>=2.28',
'pyproj',
'zarr>=2.14.0',
's3fs>=2023.0.0',
'netCDF4>=1.6.0',
],
'precip-huc12': ['pygeohydro>=0.19.0'], # HUC12 watershed boundaries for Atlas14Variance
# GeoParquet support without the rest of the full feature stack.
'geoparquet': ['pyarrow>=14.0'],
# Notebook dependencies (raster visualization, coordinate systems, precipitation examples)
'notebooks': [
'rasterio',
'rioxarray',
'cfgrib>=0.9.10',
'eccodes>=2.28',
'pyproj',
'aiohttp',
'dataretrieval>=1.4',
'zarr>=2.14.0',
's3fs>=2023.0.0',
'netCDF4>=1.6.0',
'pygeohydro>=0.19.0',
],
# RasMapperLib pythonnet interop: headless mesh generation and
# polyline profile queries for velocity, WSE, flow, time-series,
# pipe-network, and plan-difference renderers (Windows HEC-RAS install required)
'mesh': ['pythonnet>=3.0.5'],
# DSS file operations. The default "java" backend needs pyjnius and a
# Java JRE/JDK 8+; the optional native engine (FAST-DSS) serves the
# "native" and "shadow" backends without Java.
'dss': ['pyjnius', FAST_DSS_DEPENDENCY],
# pydsstools writes NumPy grids directly to DSS7 for
# write_precip_grid_arrays on the "java" backend; FAST-DSS serves the
# "native" backend.
'dss-native': ['pydsstools>=3.1.0,<4', 'pyproj', 'affine',
FAST_DSS_DEPENDENCY],
# Everything (all optional dependencies)
'all': FULL_FEATURE_DEPENDENCIES + COMPUTE_DEPENDENCIES + [
'paramiko>=3.0',
'docker>=6.0',
'Pillow>=9.0',
'comtypes>=1.4.0; sys_platform == "win32"',
'dataretrieval>=1.4',
'zarr>=2.14.0',
's3fs>=2023.0.0',
'netCDF4>=1.6.0',
'pygeohydro>=0.19.0',
'rasterio',
'rioxarray',
'cfgrib>=0.9.10',
'eccodes>=2.28',
'pyproj',
'aiohttp',
'pythonnet>=3.0.5',
'pyjnius',
FAST_DSS_DEPENDENCY,
],
})
"""
ras-commander setup.py
This file is used to build and publish the ras-commander package to PyPI.
To build and publish this package, follow these steps:
1. Ensure you have the latest versions of setuptools, wheel, and twine installed:
pip install --upgrade setuptools wheel twine
2. Update the version number in ras_commander/__init__.py (if not using automatic versioning)
3. Create source distribution and wheel:
python setup.py sdist bdist_wheel
4. Check the distribution:
twine check dist/*
5. Upload to Test PyPI (optional):
twine upload --repository testpypi dist/*
6. Install from Test PyPI to verify (optional):
pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple ras-commander
7. Upload to PyPI:
twine upload dist/* --username __token__ --password <your_api_key>
8. Install from PyPI to verify:
pip install ras-commander
Note: Ensure you have the necessary credentials and access rights to upload to PyPI.
For more information, visit: https://packaging.python.org/tutorials/packaging-projects/
"""