Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New build system based on scikit-build-core #383

Merged
merged 28 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
239e405
Almost complete implementation of new build with scikit-build-core
mbkumar Nov 19, 2023
c61599c
Change localscheme to dirty
mbkumar Nov 20, 2023
24c80d3
Update CMakeLists for macos runner in CI builds
mbkumar Nov 20, 2023
c34bdf0
Bump python version to 3.9 in workflows
mbkumar Nov 20, 2023
f16b11c
Remove CMAKE option in simsopt installation in ci workflow
mbkumar Nov 20, 2023
b76f59a
Merge branch 'master' into scikit
mbkumar Nov 20, 2023
da5660a
Update conda recipe
mbkumar Nov 20, 2023
dec2483
Trying for mpi4py to be installed along with simsopt
mbkumar Nov 20, 2023
f907952
optional packages not getting installed on runners for some reason
mbkumar Nov 20, 2023
9f08b85
Add pybind11 to build and host requirements in conda recipe
mbkumar Nov 20, 2023
79fef3d
add git tag to meta.yml
mbkumar Nov 21, 2023
be7ac34
Bug fixes in conda recipe
mbkumar Nov 21, 2023
d0a62d5
Change python 3.10 patch version in workflows
mbkumar Nov 21, 2023
ec5f6a1
Update meta.yaml metadata with strings
mbkumar Nov 21, 2023
5f4c63c
Try not installing packages before
mbkumar Nov 22, 2023
0dfe6bb
Add back pip installation of packages for SPEC
mbkumar Nov 22, 2023
9de3a77
Add back scikit-build for SPEC
mbkumar Nov 22, 2023
b5febae
Get coverage working
mbkumar Nov 22, 2023
8531156
Get the location of python
mbkumar Nov 22, 2023
9b71e9a
Try with 3.10 in the coverage upload section
mbkumar Nov 22, 2023
1cfc787
Test without 3.10 in coverage
mbkumar Nov 26, 2023
ab72b08
New coveragerc to fix the issue in runner
mbkumar Nov 26, 2023
924ad7d
Add back python 3.10 to extensive ci
mbkumar Nov 26, 2023
97a12f7
Rename CI to tests to better reflect the workflow
mbkumar Nov 26, 2023
c214133
Shift coverage defs to pyproject.toml
mbkumar Nov 26, 2023
f50633d
Remove level 3 in python version specification
mbkumar Nov 26, 2023
a735697
Add strings surrounding 3.10
mbkumar Nov 26, 2023
aa8a6c8
Bring back coveragerc file
mbkumar Nov 27, 2023
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
9 changes: 6 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
[run]
parallel = true
source = simsopt
relative_files = true

[paths]
sources =
/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/site-packages
/opt/hostedtoolcache/Python/3.9.17/x64/lib/python3.9/site-packages
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages
src/
/**/lib/python3.8/site-packages
/**/lib/python3.9/site-packages
/**/lib/python3.10/site-packages
/**/lib/python3.11/site-packages
4 changes: 2 additions & 2 deletions .github/workflows/conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-11]
python-version: ["3.8"]
python-version: ["3.9"]

runs-on: ${{ matrix.platform }}

Expand All @@ -41,7 +41,7 @@ jobs:
channel-priority: strict

- name: Prepare
run: conda install -y conda-build conda-verify setuptools_scm anaconda-client
run: conda install -y conda-build conda-verify setuptools_scm anaconda-client scikit-build-core

- name: Build and upload
if: github.event_name == 'release' && github.event.action == 'published'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
matrix:
test-type: [unit, integrated]
packages: [all, vmec, spec, none]
python-version: [3.8.17, 3.9.17, 3.10.12] # To sync with coveragerc use 3 levels with python version
python-version: [3.8, 3.9, "3.10"]
include:
- python-version: 3.9.17
- python-version: 3.9
test-type: unit
packages: none
- python-version: 3.9.17
- python-version: 3.9
test-type: integrated
packages: none

Expand Down Expand Up @@ -165,15 +165,19 @@ jobs:

- name: Install simsopt package
if: contains(matrix.packages, 'spec') || contains(matrix.packages, 'all')
run: pip install -v .[MPI,SPEC]
run: |
pip install -v .
pip install mpi4py py_spec pyoculus h5py

- name: Install simsopt package
if: contains(matrix.packages, 'none')
run: pip install -v .

- name: Install simsopt package
if: contains(matrix.packages, 'vmec')
run: pip install -v .[MPI]
run: |
pip install -v .
pip install mpi4py

- name: Run serial examples as part of integrated tests
if: contains(matrix.test-type, 'integrated') && (contains(matrix.packages, 'none') || contains(matrix.packages, 'all'))
Expand Down Expand Up @@ -247,7 +251,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8.17
python-version: 3.9

- name: Install coverage
run: pip install coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8]
python-version: [3.9]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/non_simd_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8.15] # To sync with coveragerc use 3 level
python-version: [3.9]

steps:
# First print out lots of information. We do this in separate
Expand Down
14 changes: 9 additions & 5 deletions .github/workflows/ci.yml → .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [3.8.17] # To sync with coveragerc use 3 level
python-version: [3.9]
test-type: [unit, integrated]

steps:
Expand All @@ -49,6 +49,11 @@ jobs:
set -ex
ls -l

- name: Print python location
run: |
set -ex
which python

- name: apt-get stuff needed for libstell and vmec
run: |
sudo apt-get update
Expand Down Expand Up @@ -88,7 +93,7 @@ jobs:
- name: Install python dependencies
run: |
sudo apt-get install graphviz graphviz-dev
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz
pip install numpy cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec pyoculus h5py

- name: Install booz_xform
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
Expand Down Expand Up @@ -130,8 +135,6 @@ jobs:
run: |
cd SPEC
pip install .
# python setup.py bdist_wheel
# pip install dist/*.whl

- name: Try import spec
run: python -c "import spec.spec_f90wrapped as spec; print(spec.constants.version)"
Expand Down Expand Up @@ -159,7 +162,8 @@ jobs:
run: python -c "print(dir()); import vmec; print(dir()); print(dir(vmec)); print('package:', vmec.__package__); print('spec:', vmec.__spec__); print('doc:', vmec.__doc__); print('file:', vmec.__file__); print('path:', vmec.__path__)"

- name: Install simsopt package
run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI,SPEC]
# run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI,SPEC]
run: pip install -v ".[MPI,SPEC,VIS]"

- name: Verify that importing simsopt does not automatically initialize MPI
run: ./tests/verify_MPI_not_initialized.py
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
python-version: '3.9'

- name: Download all submodules
run: git submodule update --init
Expand Down
17 changes: 11 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
cmake_minimum_required(VERSION 3.15)
project(simsoptpp)
project(simsoptpp LANGUAGES CXX)
#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(Python_FIND_STRATEGY LOCATION)
find_package(Python 3 COMPONENTS Interpreter Development.Module NumPy)
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module NumPy)
find_package(pybind11 CONFIG REQUIRED)

message(status "Python executable is ${Python_EXECUTABLE}")
message(status "Python Development Module found value is ${Python_Development.Module_FOUND}")
Expand Down Expand Up @@ -40,8 +41,12 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})

include(CheckCXXCompilerFlag)
IF(DEFINED ENV{CI})
message(STATUS "CI environment detected. Set compilation flags targetting Westmere microarch.")
set(CMAKE_CXX_FLAGS "-O3 -march=westmere")
if (APPLE)
set(CMAKE_CXX_FLAGS "-O3")
else()
message(STATUS "CI environment detected. Set compilation flags targetting Westmere microarch.")
set(CMAKE_CXX_FLAGS "-O3 -march=westmere")
endif()
elseif(DEFINED ENV{CONDA_BUILD})
message(STATUS "conda build environment detected. Let conda set compilation flags accordingly.")
# set(CMAKE_CXX_FLAGS "-O3 -march=ivybridge -mfma -ffp-contract=fast")
Expand Down Expand Up @@ -106,7 +111,7 @@ else()
message(STATUS "Boost include dirs are ${Boost_INCLUDE_DIRS}")
endif()

add_subdirectory(thirdparty/pybind11)
# add_subdirectory(thirdparty/pybind11)
add_subdirectory(thirdparty/fmt EXCLUDE_FROM_ALL)
set(XTENSOR_USE_OPENMP 0)
set(XTENSOR_USE_TBB 0)
Expand Down Expand Up @@ -164,4 +169,4 @@ target_link_libraries(profiling PRIVATE fmt::fmt-header-only)
#install(TARGETS ${PROJECT_NAME}
# #LIBRARY
# DESTINATION src/${PROJECT_NAME})
#install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION .)
14 changes: 7 additions & 7 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}
{% set version = data.get('version') %}

package:
name: simsopt
version: {{ version }}
version: {{ GIT_DESCRIBE_TAG }}+{{ GIT_BUILD_STR }}

source:
path: ..
Expand All @@ -24,14 +21,17 @@ requirements:
- libgomp # [linux]
- "setuptools_scm[toml]"
- boost
- pybind11
- scikit-build-core

host:
- pip
- wheel
- setuptools
- numpy {{ numpy }}
- "setuptools_scm[toml]"
- scikit-build-core
- python {{ python }}
- pybind11

run:
- python
Expand All @@ -49,13 +49,13 @@ requirements:
- pyevtk

about:
home: {{ data.get('url') }}
home: https://github.com/hiddenSymmetries/simsopt
summary: simplified framework for stellarator optimization
license: MIT
license_file: "LICENSE"
description:
doc_url: https://simsopt.readthedocs.io/
dev_url: {{ data.get('url') }}
dev_url: https://github.com/hiddenSymmetries/simsopt

extra:
recipe-maintainers:
Expand Down
104 changes: 101 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,95 @@
[build-system]
requires = ["setuptools>=45", "wheel", "oldest-supported-numpy", "cmake", "ninja", "setuptools_scm[toml]>=6.0"]
build-backend = "setuptools.build_meta"
requires = [
"scikit-build-core>=0.3.3",
"pybind11",
"oldest-supported-numpy",
"setuptools_scm>=8.0",
'tomli; python_version < "3.11"',]
build-backend = "scikit_build_core.build"

[project]
name = "simsopt"
license = {text = "MIT License"}
description="Framework for optimizing stellarators"
readme = "README.md"
# long_description = file: README.md
# long_description_content_type = text/markdown
requires-python = ">=3.8"
authors = [
{name = "Matt Landreman", email = "[email protected]"},
{name = "Bharat Medasani", email = "[email protected]"},
{name = "Florian Wechsung", email = "[email protected]"}
]
maintainers = [
{name = "Bharat Medasani", email = "[email protected]"},
{name = "Matt Landreman", email = "[email protected]"},
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Physics",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX :: Linux",
"Environment :: Console",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10"
]
keywords = [
"plasma physics",
"plasma",
"magnetohydrodynamics",
"mhd",
"nuclear fusion reactor",
"fusion",
"stellarator",
"vmec",
"spec",
"optimization",
"Biot-Savart",
"magnetostatics"
]
dependencies = [
"numpy>=1.21",
"jax>=0.2.5",
"jaxlib>=0.1.56",
"scipy>=1.5.4",
"Deprecated>=1.2.10",
"nptyping>=1.3.0",
"monty>=2021.6.10",
"ruamel.yaml",
"sympy",
"f90nml",
"randomgen",
"pyevtk",
"matplotlib"
]
dynamic = ["version"]

[project.optional-dependencies]
SPEC = ["py_spec>=3.0.1", "pyoculus>=0.1.1", "h5py>=3.1.0"]
MPI = ["mpi4py>=3.0.3"]
VIS = ["vtk >= 8.1.2", "PyQt5", "mayavi", "plotly", "networkx"]
DOCS = ["sphinx", "sphinx-rtd-theme"]

[project.urls]
Homepage = "https://github.com/hiddenSymmetries/simsopt"
Download = "https://pypi.org/project/simsopt"
Issues = "https://github.com/hiddenSymmetries/simsopt/issues"
Documentation = "https://simsopt.readthedocs.io"
Repository = "https://github.com/hiddenSymmetries/simsopt"

[tool.setuptools_scm]
write_to = "src/simsopt/_version.py"
local_scheme = "dirty"

[tool.scikit-build]
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
sdist.include = ["src/simsopt/_version.py"]
build-dir = "build/{wheel_tag}"

[tools.setuptools_scm]

[tool.ruff]
src = ["src/simsopt"]
Expand All @@ -18,3 +105,14 @@ extend-exclude = ["thirdparty"]
"tests/geo/test_curve.py" = ["F401"]
"tests/geo/test_surface.py" = ["F401"]
"tests/mhd/test_virtual_casing.py" = ["F841"]

[tool.coverage.run]
parallel = true
relative_files = true
source = ["simsopt"]

[tool.coverage.paths]
source = [
"src",
"/**/lib*/python*/site-packages"
]
Loading
Loading