From ac5f08ea93b6e6984023082f4abfb8ec83c58093 Mon Sep 17 00:00:00 2001 From: swryan Date: Tue, 28 May 2024 16:49:23 -0400 Subject: [PATCH 1/4] remove setuptools as a dependency --- .github/workflows/test_workflow.yml | 20 +++++++++----------- build_pyoptsparse.py | 22 ++-------------------- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index cc54c11..7ff11e8 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -59,7 +59,7 @@ jobs: PY: '3.12' NUMPY: '1.26' SCIPY: '1.13' - MPI4PY: true + MPICC: 4 PYOPTSPARSE: 'default' PAROPT: true SNOPT: 7.7 @@ -76,10 +76,10 @@ jobs: # test baseline versions on MacOS - NAME: MacOS Baseline OS: macos-13 - PY: '3.12' + PY: '3.11' NUMPY: '1.26' SCIPY: '1.13' - MPI4PY: true + MPICC: 4 PYOPTSPARSE: 'default' PAROPT: true SNOPT: 7.7 @@ -90,7 +90,7 @@ jobs: PY: 3 NUMPY: 1 SCIPY: 1 - MPI4PY: true + MPICC: 4 PYOPTSPARSE: 'latest' PAROPT: true SNOPT: 7.7 @@ -118,10 +118,9 @@ jobs: # test baseline versions on MacOS without MPI with forced build - NAME: MacOS Baseline, no MPI, forced build OS: macos-12 - PY: '3.12' + PY: '3.11' NUMPY: '1.26' SCIPY: '1.13' - MPI4PY: true PYOPTSPARSE: 'default' SNOPT: 7.7 FORCE_BUILD: true @@ -132,7 +131,6 @@ jobs: PY: 3 NUMPY: 1 SCIPY: 1 - MPI4PY: true PYOPTSPARSE: 'latest' SNOPT: 7.7 FORCE_BUILD: true @@ -197,9 +195,9 @@ jobs: - name: Install run: | - conda install numpy=${{ matrix.NUMPY }} scipy=${{ matrix.SCIPY }} -q -y + conda install numpy=${{ matrix.NUMPY }} scipy=${{ matrix.SCIPY }} compilers cython swig -q -y - python -m pip install --upgrade pip + python -m ensurepip --upgrade echo "=============================================================" echo "Install build_pyoptsparse" @@ -207,13 +205,13 @@ jobs: python -m pip install . - name: Install MPI - if: matrix.MPI4PY + if: matrix.MPICC run: | echo "=============================================================" echo "Install MPI" echo "=============================================================" - conda install cython swig compilers openmpi-mpicc mpi4py -q -y + conda install openmpi-mpicc=${{ matrix.MPICC }} mpi4py -q -y echo "OMPI_MCA_rmaps_base_oversubscribe=1" >> $GITHUB_ENV diff --git a/build_pyoptsparse.py b/build_pyoptsparse.py index 43c45d6..0557564 100755 --- a/build_pyoptsparse.py +++ b/build_pyoptsparse.py @@ -12,7 +12,7 @@ from colors import * from shutil import which from packaging.version import Version, parse -import setuptools + # Default options that the user can change with command line switches opts = { @@ -935,25 +935,7 @@ def install_pyoptsparse_from_src(): if opts['build_pyoptsparse'] is True: patch_pyoptsparse_src() - - python_ver = Version(platform.python_version()) - stools_ver = Version(setuptools.__version__) - if python_ver < Version('3.12.0') and stools_ver >= Version('66.0'): - # `numpy.distutils` is deprecated since NumPy 1.23.0, as a result - # of the deprecation of `distutils` itself. It will be removed for - # Python >= 3.12. For older Python versions it will remain present. - # It is recommended to use `setuptools < 60.0` for those Python versions. - # For more details, see: - # https://numpy.org/devdocs/reference/distutils_status_migration.html - pip_install(pip_install_args=['setuptools<66.0'], pkg_desc='setuptools<66.0') - pip_install(pip_install_args=['--no-cache-dir', './'], pkg_desc='pyoptsparse') - try: - pip_install(pip_install_args=[f'setuptools=={stools_ver}'], - pkg_desc='previous version of setuptools') - except Exception: - print(f'Unable to restore previous version of setuptools ({stools_ver})') - else: - pip_install(pip_install_args=['--no-cache-dir', './'], pkg_desc='pyoptsparse') + pip_install(pip_install_args=['--no-cache-dir', './'], pkg_desc='pyoptsparse') else: announce('Not building pyOptSparse by request') if opts['include_ipopt'] is True: From b6777496455e0ea6e782cc3a3e987c80f915113c Mon Sep 17 00:00:00 2001 From: swryan Date: Tue, 28 May 2024 17:26:23 -0400 Subject: [PATCH 2/4] replace setuptools with hatchling --- pyproject.toml | 42 ++++++++++++++++++++++++++++++++++++++++++ setup.py | 44 -------------------------------------------- 2 files changed, 42 insertions(+), 44 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d9f735b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,42 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "build-pyoptsparse" +dynamic = ["version"] +description = "Automated installer for pyOptSparse" +readme = "README.md" +license = "Apache-2.0" +requires-python = ">=3.7" +authors = [ + { name = "OpenMDAO Team", email = "openmdao@openmdao.org" }, +] +dependencies = [ + "ansicolors", + "numpy", + "packaging", + "sqlitedict", + "swig", +] + +[project.optional-dependencies] +paropt = [ + "cython", + "mpi4py", +] + +[project.scripts] +build-pyoptsparse = "build_pyoptsparse:perform_install" +build_pyoptsparse = "build_pyoptsparse:perform_install" + +[project.urls] +Homepage = "http://openmdao.org" + +[tool.hatch.version] +path = "__init__.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index dd71c3a..0000000 --- a/setup.py +++ /dev/null @@ -1,44 +0,0 @@ -from distutils.core import setup -from setuptools import find_packages -import re - -__version__ = re.findall( - r"""__version__ = ["']+([0-9\.]*)["']+""", - open('__init__.py').read(), -)[0] - -optional_dependencies = { - 'paropt': [ - 'cython', - 'mpi4py' - ] -} - -setup(name='build_pyoptsparse', - version=__version__, - license='Apache License', - packages=find_packages(), - python_requires=">=3.7", - install_requires=[ - 'ansicolors', - 'numpy', - 'sqlitedict', - 'packaging' - ], - description="Automated installer for pyOptSparse", - long_description="""pyOptSparse has several dependencies which can be tricky - to build. This script attempts to automate the process as much as possible - with command line arguments to customize the functionality. - """, - author='OpenMDAO Team', - author_email='openmdao@openmdao.org', - url='http://openmdao.org', - py_modules=['build_pyoptsparse'], - entry_points={ - 'console_scripts': [ - 'build-pyoptsparse = build_pyoptsparse:perform_install', - 'build_pyoptsparse = build_pyoptsparse:perform_install', - ] - }, - extras_require=optional_dependencies -) From 9775fc9d3e257cc222ea950a3623beb1068b8f6a Mon Sep 17 00:00:00 2001 From: swryan Date: Tue, 28 May 2024 17:44:43 -0400 Subject: [PATCH 3/4] rm swig, display log --- .github/workflows/test_workflow.yml | 10 ++++++++++ pyproject.toml | 1 - 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml index 7ff11e8..6c8048a 100644 --- a/.github/workflows/test_workflow.yml +++ b/.github/workflows/test_workflow.yml @@ -295,6 +295,16 @@ jobs: echo "BRANCH=${BRANCH}" >> $GITHUB_ENV + - name: Display build log + if: failure() + run: | + for f in $(find /tmp/ -name 'meson-log.txt'); do + echo "=============================================================" + echo $f + echo "=============================================================" + cat $f + done + # Enable tmate debugging of manually-triggered workflows if the input option was provided # # To access the terminal through the web-interface: diff --git a/pyproject.toml b/pyproject.toml index d9f735b..9e8ee4f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,6 @@ dependencies = [ "numpy", "packaging", "sqlitedict", - "swig", ] [project.optional-dependencies] From d1cfdd483d98e778c9430b068440e2edba625544 Mon Sep 17 00:00:00 2001 From: swryan Date: Tue, 28 May 2024 18:17:27 -0400 Subject: [PATCH 4/4] increment version --- __init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__init__.py b/__init__.py index fca23f6..bc4c46a 100644 --- a/__init__.py +++ b/__init__.py @@ -1 +1 @@ -__version__ = '2.0.10' +__version__ = '2.0.11'