diff --git a/.github/environment.yml b/.github/environment.yml index 07ce63558..0411e61dd 100644 --- a/.github/environment.yml +++ b/.github/environment.yml @@ -4,12 +4,13 @@ dependencies: - numpy >=2.0 - swig - meson >=1.3.2 - - compilers - - pkg-config + - meson-python + - c-compiler + - cxx-compiler - pip - setuptools - build - - flang>=18 + - flang=20 - libpgmath # runtime - packaging diff --git a/.github/workflows/windows-build.yml b/.github/workflows/windows-build.yml index ed0b70db0..cdc90df91 100644 --- a/.github/workflows/windows-build.yml +++ b/.github/workflows/windows-build.yml @@ -36,6 +36,8 @@ jobs: :: debug - list environment vars set + set FC=flang.exe + python -m build -n -x . pip install --no-deps --no-index --find-links dist pyoptsparse diff --git a/doc/contribute.rst b/doc/contribute.rst index bcfce24c7..34ddfdaa0 100644 --- a/doc/contribute.rst +++ b/doc/contribute.rst @@ -8,6 +8,22 @@ If you have an issue with pyOptSparse, a bug to report, or a feature to request, This lets other users know about the issue. If you are comfortable fixing the issue, please do so and submit a pull request. +Editable Installs +----------------- +Due to the use of ``meson-python`` as the backend, the typical process of using ``pip install -e .`` to generate an editable install cannot be used. +Instead, based on the instructions `here `__, +you must first install the `build dependencies` yourself. +This can be done by looking at the ``requires`` field of the ``[build-system]`` section of the ``pyproject.toml`` file, or via +``pip install .[dev]`` + +Then, do the following: + +.. prompt:: bash + + pip install --no-build-isolation --editable . + +To run tests, ensure that the testing dependencies specified in the ``pyproject.toml`` file are also installed. + Coding style ------------ We use `ruff `_ and `pre-commit `_ for linting and formatting. @@ -49,6 +65,9 @@ When you add code or functionality, add tests that cover the new or modified cod These may be units tests for individual components or regression tests for entire models that use the new functionality. All the existing tests can be found under the ``test`` folder. +To run tests, ensure that the testing dependencies have been installed (see `pyproject.toml`). + + Pull requests ------------- Finally, after adding or modifying code, and making sure the steps above are followed, submit a pull request via the GitHub interface. diff --git a/doc/install.rst b/doc/install.rst index e3347adea..6c92ca110 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -98,11 +98,7 @@ If you encounter a ``no module named tkinter`` error when trying to run optview, Testing ------- pyOptSparse provides a set of unit and regression tests to verify the installation. -To run these tests, first install ``testflo`` which is a testing framework developed by the OpenMDAO team: - -.. prompt:: bash - - pip install testflo +To run these tests, first install testing dependencies via ``pip install .[testing]``. Then, in the project root directory, type: diff --git a/meson.build b/meson.build index a2219cd39..fa48ffa39 100644 --- a/meson.build +++ b/meson.build @@ -1,24 +1,33 @@ -# Much of this is from SciPy - project( 'pyoptsparse', 'c', 'cpp', -# unnecessary metadata commented out until Meson supports PEP517 and installation with pip -# version: 'x.x.x', -# license: 'GPL-3', - meson_version: '>= 0.60', + version: run_command( + 'python', '-c', + ''' +import re +from pathlib import Path +init_file = Path("pyoptsparse/__init__.py") +match = re.search(r'__version__ = ["\\\']([\d\\.]+)["\\\']', init_file.read_text()) +print(match.group(1)) + ''' + ).stdout().strip(), + meson_version: '>= 0.64', default_options: [ 'buildtype=debugoptimized', - 'c_std=c99', - 'cpp_std=c++14', + 'b_ndebug=if-release', + 'c_std=c17', + 'cpp_std=c++17', ], ) -fortranobject_c = '../fortranobject.c' +#