Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- cxx-compiler
- pip
- setuptools
- setuptools_scm >=8.2
- build
- flang=20
- libpgmath
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
versions: [{python: "3.11", numpy: "1.25"}, {python: "3.12", numpy: "2.3"}]
steps:
- uses: actions/checkout@v4
with:
# full history so setuptools_scm can find version tags
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.versions.python }}
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
numpy_version: ["1.25.2", "2.3.5"]
steps:
- uses: actions/checkout@v4
with:
# full history so setuptools_scm can find version tags
fetch-depth: 0
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: "3.11"
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ env
pyoptsparse/pySNOPT/source
pyoptsparse/pyNLPQLP/source
*.egg-info
pyoptsparse/_version.py

.idea/
/meson_build/
Expand Down
6 changes: 6 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ build:
os: ubuntu-22.04
tools:
python: "3.11"
jobs:
post_checkout:
# RTD clones shallowly; setuptools_scm needs the full history to find version tags.
# --unshallow errors on an already-complete repo, so only run it when actually
# shallow; a real fetch failure then still fails the build instead of being masked.
- test $(git rev-parse --is-shallow-repository) = false || git fetch --unshallow

sphinx:
configuration: doc/conf.py
Expand Down
9 changes: 4 additions & 5 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Standard Python modules
import os
import re
import sys

# External modules
from setuptools_scm import get_version
from sphinx_mdolab_theme.config import *

# -- Path setup --------------------------------------------------------------
Expand All @@ -19,10 +19,9 @@
# -- Project information -----------------------------------------------------

project = "pyOptSparse"
version = re.findall(
r"""__version__ = ["']+([0-9\.]*)["']+""",
open("../pyoptsparse/__init__.py").read(),
)[0]
# version_file (resolved relative to this file's directory) is written into the checkout so
# that optionstable can import pyoptsparse from the source tree (RTD does not install the package)
version = get_version(root="..", relative_to=__file__, version_file="../pyoptsparse/_version.py")

# -- General configuration ---------------------------------------------------

Expand Down
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
sphinx_mdolab_theme>=1.2
setuptools_scm>=8
sphinx-codeautolink
numpy
scipy
12 changes: 4 additions & 8 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
project(
'pyoptsparse',
'c', 'cpp',
# setuptools_scm (configured in pyproject.toml) derives the version and writes
# pyoptsparse/_version.py, which is installed as part of the package below
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))
'''
'python', '-m', 'setuptools_scm', '--force-write-version-files',
check: true
).stdout().strip(),
meson_version: '>= 0.64',
default_options: [
Expand Down
2 changes: 1 addition & 1 deletion pyoptsparse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "2.16.0"
from ._version import __version__

from .pyOpt_history import History
from .pyOpt_variable import Variable
Expand Down
9 changes: 7 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["meson-python", "ninja", "numpy>=2.0", "swig"]
requires = ["meson-python", "ninja", "numpy>=2.0", "swig", "setuptools_scm[simple]>=8.2"]
build-backend = "mesonpy"

[project]
Expand All @@ -15,7 +15,7 @@ dependencies = [
"scipy>=1.11",
"mdolab-baseclasses>=1.3.1"
]
dynamic = ["version"] # version is dynamically populated from meson project
dynamic = ["version"] # version is dynamically populated from meson project, which gets it from setuptools_scm

[project.optional-dependencies]
optview = [
Expand All @@ -40,6 +40,11 @@ dev = [
"parameterized",
]

# Version is derived from git tags (or PKG-INFO in an sdist, or SETUPTOOLS_SCM_PRETEND_VERSION).
# meson runs `python -m setuptools_scm` at configure time, which writes pyoptsparse/_version.py.
[tool.setuptools_scm]
version_file = "pyoptsparse/_version.py"

[project.urls]
Homepage = "https://github.com/mdolab/pyoptsparse"

Expand Down
Loading