-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
catching up documentation and improving installation robustness
- Loading branch information
Showing
4 changed files
with
176 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,131 @@ | ||
[build-system] | ||
requires = ["setuptools", "meson>=0.60.0", "numpy","ninja"] | ||
requires = ["setuptools", "meson>=1.1", "numpy","ninja","wheel"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "CCBlade" | ||
version = "1.3.1" | ||
description = "Blade element momentum aerodynamics for wind turbines" | ||
readme = "README.md" | ||
requires-python = ">=3.9" | ||
license = {text = "Apache-2.0"} | ||
keywords = ["wind", "turbine", "mdao", "design", "optimization"] | ||
authors = [ | ||
{name = "NREL WISDEM Team", email = "[email protected]" } | ||
] | ||
maintainers = [ | ||
{name = "NREL WISDEM Team", email = "[email protected]" } | ||
] | ||
classifiers = [ # Optional | ||
# How mature is this project? Common values are | ||
# 3 - Alpha | ||
# 4 - Beta | ||
# 5 - Production/Stable | ||
"Development Status :: 4 - Beta", | ||
|
||
# Indicate who your project is intended for | ||
"Intended Audience :: Science/Research", | ||
"Topic :: Scientific/Engineering", | ||
|
||
"License :: OSI Approved :: Apache Software License", | ||
|
||
# Specify the Python versions you support here. In particular, ensure | ||
# that you indicate you support Python 3. These classifiers are *not* | ||
# checked by "pip install". See instead "python_requires" below. | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Fortran", | ||
] | ||
|
||
dependencies = [ | ||
"numpy", | ||
"scipy", | ||
"openmdao", | ||
] | ||
|
||
# List additional groups of dependencies here (e.g. development | ||
# dependencies). Users will be able to install these using the "extras" | ||
# syntax, for example: | ||
# | ||
# $ pip install sampleproject[dev] | ||
# | ||
# Similar to `dependencies` above, these must be valid existing | ||
# projects. | ||
[project.optional-dependencies] # Optional | ||
dev = ["meson", "ninja"] | ||
test = ["pytest"] | ||
|
||
# List URLs that are relevant to your project | ||
# | ||
# This field corresponds to the "Project-URL" and "Home-Page" metadata fields: | ||
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use | ||
# https://packaging.python.org/specifications/core-metadata/#home-page-optional | ||
# | ||
# Examples listed include a pattern for specifying where the package tracks | ||
# issues, where the source is hosted, where to say thanks to the package | ||
# maintainers, and where to support the project financially. The key is | ||
# what's used to render the link text on PyPI. | ||
[project.urls] # Optional | ||
"Homepage" = "https://github.com/WISDEM/CCBlade" | ||
|
||
# This is configuration specific to the `setuptools` build backend. | ||
# If you are using a different build backend, you will need to change this. | ||
[tool.setuptools] | ||
zip-safe = false | ||
include-package-data = true | ||
|
||
#[tool.setuptools.packages] | ||
#find = {} | ||
|
||
[tool.setuptools.packages.find] | ||
#where = ["wisdem"] | ||
exclude = ["docs", "test"] | ||
namespaces = true | ||
|
||
[tool.setuptools.package-data] | ||
# If there are data files included in your packages that need to be | ||
# installed, specify them here. | ||
"*" = ["*.yaml", "*.xlsx", "*.txt", "*.so", "*.lib", "*.pyd", "*.pdb", "*.dylib", "*.dll", "*.exe"] | ||
|
||
[tool.black] | ||
line-length = 120 | ||
target-version = ['py39'] | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
/( | ||
\.git | ||
| \.hg | ||
| \.mypy_cache | ||
| \.tox | ||
| \.venv | ||
| _build | ||
| buck-out | ||
| build | ||
| dist | ||
)/ | ||
''' | ||
|
||
[tool.isort] | ||
# https://github.com/PyCQA/isort | ||
multi_line_output = "3" | ||
include_trailing_comma = true | ||
force_grid_wrap = false | ||
use_parentheses = true | ||
line_length = "120" | ||
sections = ["FUTURE", "STDLIB", "THIRDPARTY", "FIRSTPARTY", "LOCALFOLDER"] | ||
known_first_party = ["wisdem"] | ||
length_sort = "1" | ||
profile = "black" | ||
skip_glob = ['__init__.py'] | ||
atomic = true | ||
#lines_after_imports = 2 | ||
#lines_between_types = 1 | ||
#src_paths=isort,test | ||
|
||
[tool.cibuildwheel] | ||
skip = ["cp36-*", "cp37-*", "cp38-*", "*-win32", "*arm64", "pp*"] | ||
build-frontend = "build" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,22 @@ | |
import setuptools | ||
import subprocess | ||
|
||
####### | ||
# This forces wheels to be platform specific | ||
from setuptools.dist import Distribution | ||
from wheel.bdist_wheel import bdist_wheel as _bdist_wheel | ||
|
||
class bdist_wheel(_bdist_wheel): | ||
def finalize_options(self): | ||
_bdist_wheel.finalize_options(self) | ||
self.root_is_pure = False | ||
|
||
class BinaryDistribution(Distribution): | ||
"""Distribution which always forces a binary package with platform name""" | ||
def has_ext_modules(foo): | ||
return True | ||
####### | ||
|
||
|
||
def run_meson_build(staging_dir): | ||
prefix = os.path.join(os.getcwd(), staging_dir) | ||
|
@@ -19,6 +35,8 @@ def run_meson_build(staging_dir): | |
meson_args = "" | ||
if "MESON_ARGS" in os.environ: | ||
meson_args = os.environ["MESON_ARGS"] | ||
# A weird add-on on mac github action runners needs to be removed | ||
if meson_args.find("buildtype") >= 0: meson_args = "" | ||
|
||
if platform.system() == "Windows": | ||
if not "FC" in os.environ: | ||
|
@@ -28,54 +46,52 @@ def run_meson_build(staging_dir): | |
|
||
# configure | ||
meson_path = shutil.which("meson") | ||
meson_call = ( | ||
f"{meson_path} setup {staging_dir} --prefix={prefix} " | ||
+ f"-Dpython.purelibdir={purelibdir} -Dpython.platlibdir={purelibdir} {meson_args}" | ||
) | ||
sysargs = meson_call.split(" ") | ||
sysargs = [arg for arg in sysargs if arg != ""] | ||
print(sysargs) | ||
p1 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
if meson_path is None: | ||
raise OSError("The meson command cannot be found on the system") | ||
|
||
meson_call = [meson_path, "setup", staging_dir, "--wipe", | ||
f"--prefix={prefix}", f"-Dpython.purelibdir={purelibdir}", | ||
f"-Dpython.platlibdir={purelibdir}", meson_args] | ||
meson_call = [m for m in meson_call if m != ""] | ||
print(meson_call) | ||
p1 = subprocess.run(meson_call, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
os.makedirs(staging_dir, exist_ok=True) | ||
setup_log = os.path.join(staging_dir, "setup.log") | ||
with open(setup_log, "wb") as f: | ||
f.write(p1.stdout) | ||
if p1.returncode != 0: | ||
with open(setup_log, "r") as f: | ||
print(f.read()) | ||
raise OSError(sysargs, f"The meson setup command failed! Check the log at {setup_log} for more information.") | ||
raise OSError(meson_call, f"The meson setup command failed! Check the log at {setup_log} for more information.") | ||
|
||
# build | ||
meson_call = f"{meson_path} compile -vC {staging_dir}" | ||
sysargs = meson_call.split(" ") | ||
sysargs = [arg for arg in sysargs if arg != ""] | ||
print(sysargs) | ||
p2 = subprocess.run(sysargs, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
meson_call = [meson_path, "compile", "-vC", staging_dir] | ||
meson_call = [m for m in meson_call if m != ""] | ||
print(meson_call) | ||
p2 = subprocess.run(meson_call, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) | ||
compile_log = os.path.join(staging_dir, "compile.log") | ||
with open(compile_log, "wb") as f: | ||
f.write(p2.stdout) | ||
if p2.returncode != 0: | ||
with open(compile_log, "r") as f: | ||
print(f.read()) | ||
raise OSError( | ||
sysargs, f"The meson compile command failed! Check the log at {compile_log} for more information." | ||
) | ||
raise OSError(meson_call, f"The meson compile command failed! Check the log at {compile_log} for more information.") | ||
|
||
|
||
def copy_shared_libraries(): | ||
build_path = os.path.join(staging_dir, "ccblade") | ||
for root, _dirs, files in os.walk(build_path): | ||
for file in files: | ||
# move ccblade to just under staging_dir | ||
if file.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll")): | ||
if file.endswith((".so", ".lib", ".pyd", ".pdb", ".dylib", ".dll", ".mod")): | ||
if ".so.p" in root or ".pyd.p" in root: # excludes intermediate object files | ||
continue | ||
file_path = os.path.join(root, file) | ||
new_path = str(file_path) | ||
match = re.search(staging_dir, new_path) | ||
new_path = new_path[match.span()[1] + 1 :] | ||
print(f"Copying build file {file_path} -> {new_path}") | ||
shutil.copy(file_path, new_path) | ||
shutil.move(file_path, new_path) | ||
|
||
|
||
if __name__ == "__main__": | ||
|
@@ -90,43 +106,11 @@ def copy_shared_libraries(): | |
os.chdir(cwd) | ||
copy_shared_libraries() | ||
|
||
#docs_require = "" | ||
#req_txt = os.path.join("doc", "requirements.txt") | ||
#if os.path.isfile(req_txt): | ||
# with open(req_txt) as f: | ||
# docs_require = f.read().splitlines() | ||
|
||
init_file = os.path.join("ccblade", "__init__.py") | ||
#__version__ = re.findall( | ||
# r"""__version__ = ["']+([0-9\.]*)["']+""", | ||
# open(init_file).read(), | ||
#)[0] | ||
|
||
setuptools.setup( | ||
name='CCBlade', | ||
version='1.3.0', | ||
description='Blade element momentum aerodynamics for wind turbines', | ||
long_description="CCBlade is a Python package that provides a blade element momentum theory solution for wind turbine blade design", | ||
author='NREL WISDEM Team', | ||
author_email='[email protected]', | ||
install_requires=[ | ||
"numpy", | ||
"scipy", | ||
"openmdao", | ||
], | ||
extras_require={ | ||
"testing": ["pytest"], | ||
}, | ||
python_requires=">=3.8", | ||
packages=["ccblade"], | ||
package_data={"": ["*.yaml", "*.so", "*.lib", "*.pyd", "*.pdb", "*.dylib", "*.dll"]}, | ||
license='Apache License, Version 2.0', | ||
zip_safe=False, | ||
) | ||
|
||
#os.environ['NPY_DISTUTILS_APPEND_FLAGS'] = '1' | ||
|
||
# package_data={'ccblade': []}, | ||
# ext_modules=[Extension('ccblade._bem', | ||
# sources=[os.path.join('ccblade','src','bem.f90')], | ||
# extra_compile_args=['-O2','-fPIC','-std=c11'])], | ||
setuptools.setup(cmdclass={'bdist_wheel': bdist_wheel}, distclass=BinaryDistribution) | ||
|