Skip to content

Commit d0aa01a

Browse files
authored
Merge pull request #383 from hiddenSymmetries/scikit
New build system based on `scikit-build-core`
2 parents 2658512 + aa8a6c8 commit d0aa01a

File tree

12 files changed

+149
-277
lines changed

12 files changed

+149
-277
lines changed

.coveragerc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
[run]
22
parallel = true
33
source = simsopt
4+
relative_files = true
45

56
[paths]
67
sources =
7-
/opt/hostedtoolcache/Python/3.8.17/x64/lib/python3.8/site-packages
8-
/opt/hostedtoolcache/Python/3.9.17/x64/lib/python3.9/site-packages
9-
/opt/hostedtoolcache/Python/3.10.12/x64/lib/python3.10/site-packages
8+
src/
9+
/**/lib/python3.8/site-packages
10+
/**/lib/python3.9/site-packages
11+
/**/lib/python3.10/site-packages
12+
/**/lib/python3.11/site-packages

.github/workflows/conda.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
platform: [ubuntu-latest, macos-11]
19-
python-version: ["3.8"]
19+
python-version: ["3.9"]
2020

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

@@ -41,7 +41,7 @@ jobs:
4141
channel-priority: strict
4242

4343
- name: Prepare
44-
run: conda install -y conda-build conda-verify setuptools_scm anaconda-client
44+
run: conda install -y conda-build conda-verify setuptools_scm anaconda-client scikit-build-core
4545

4646
- name: Build and upload
4747
if: github.event_name == 'release' && github.event.action == 'published'

.github/workflows/extensive_ci.yml renamed to .github/workflows/extensive_test.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ jobs:
2929
matrix:
3030
test-type: [unit, integrated]
3131
packages: [all, vmec, spec, none]
32-
python-version: [3.8.17, 3.9.17, 3.10.12] # To sync with coveragerc use 3 levels with python version
32+
python-version: [3.8, 3.9, "3.10"]
3333
include:
34-
- python-version: 3.9.17
34+
- python-version: 3.9
3535
test-type: unit
3636
packages: none
37-
- python-version: 3.9.17
37+
- python-version: 3.9
3838
test-type: integrated
3939
packages: none
4040

@@ -165,15 +165,19 @@ jobs:
165165

166166
- name: Install simsopt package
167167
if: contains(matrix.packages, 'spec') || contains(matrix.packages, 'all')
168-
run: pip install -v .[MPI,SPEC]
168+
run: |
169+
pip install -v .
170+
pip install mpi4py py_spec pyoculus h5py
169171
170172
- name: Install simsopt package
171173
if: contains(matrix.packages, 'none')
172174
run: pip install -v .
173175

174176
- name: Install simsopt package
175177
if: contains(matrix.packages, 'vmec')
176-
run: pip install -v .[MPI]
178+
run: |
179+
pip install -v .
180+
pip install mpi4py
177181
178182
- name: Run serial examples as part of integrated tests
179183
if: contains(matrix.test-type, 'integrated') && (contains(matrix.packages, 'none') || contains(matrix.packages, 'all'))
@@ -247,7 +251,7 @@ jobs:
247251
- name: Set up Python
248252
uses: actions/setup-python@v4
249253
with:
250-
python-version: 3.8.17
254+
python-version: 3.9
251255

252256
- name: Install coverage
253257
run: pip install coverage

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: [3.8]
12+
python-version: [3.9]
1313

1414
steps:
1515
- uses: actions/checkout@v3

.github/workflows/non_simd_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
python-version: [3.8.15] # To sync with coveragerc use 3 level
30+
python-version: [3.9]
3131

3232
steps:
3333
# First print out lots of information. We do this in separate

.github/workflows/ci.yml renamed to .github/workflows/tests.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
strategy:
2727
fail-fast: false
2828
matrix:
29-
python-version: [3.8.17] # To sync with coveragerc use 3 level
29+
python-version: [3.9]
3030
test-type: [unit, integrated]
3131

3232
steps:
@@ -49,6 +49,11 @@ jobs:
4949
set -ex
5050
ls -l
5151
52+
- name: Print python location
53+
run: |
54+
set -ex
55+
which python
56+
5257
- name: apt-get stuff needed for libstell and vmec
5358
run: |
5459
sudo apt-get update
@@ -88,7 +93,7 @@ jobs:
8893
- name: Install python dependencies
8994
run: |
9095
sudo apt-get install graphviz graphviz-dev
91-
pip install wheel numpy scipy f90nml h5py scikit-build cmake qsc sympy pyevtk matplotlib ninja plotly networkx pygraphviz
96+
pip install numpy cmake scikit-build f90nml ninja wheel setuptools sympy qsc pyevtk matplotlib plotly networkx pygraphviz mpi4py py_spec pyoculus h5py
9297
9398
- name: Install booz_xform
9499
run: pip install -v git+https://github.com/hiddenSymmetries/booz_xform
@@ -130,8 +135,6 @@ jobs:
130135
run: |
131136
cd SPEC
132137
pip install .
133-
# python setup.py bdist_wheel
134-
# pip install dist/*.whl
135138
136139
- name: Try import spec
137140
run: python -c "import spec.spec_f90wrapped as spec; print(spec.constants.version)"
@@ -159,7 +162,8 @@ jobs:
159162
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__)"
160163

161164
- name: Install simsopt package
162-
run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI,SPEC]
165+
# run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI,SPEC]
166+
run: pip install -v ".[MPI,SPEC,VIS]"
163167

164168
- name: Verify that importing simsopt does not automatically initialize MPI
165169
run: ./tests/verify_MPI_not_initialized.py

.github/workflows/wheel.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
- uses: actions/setup-python@v4
4646
name: Install Python
4747
with:
48-
python-version: '3.8'
48+
python-version: '3.9'
4949

5050
- name: Download all submodules
5151
run: git submodule update --init

CMakeLists.txt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
cmake_minimum_required(VERSION 3.15)
2-
project(simsoptpp)
2+
project(simsoptpp LANGUAGES CXX)
33
#set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
44

55
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
66
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
77

88
set(Python_FIND_STRATEGY LOCATION)
9-
find_package(Python 3 COMPONENTS Interpreter Development.Module NumPy)
9+
find_package(Python REQUIRED COMPONENTS Interpreter Development.Module NumPy)
10+
find_package(pybind11 CONFIG REQUIRED)
1011

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

4142
include(CheckCXXCompilerFlag)
4243
IF(DEFINED ENV{CI})
43-
message(STATUS "CI environment detected. Set compilation flags targetting Westmere microarch.")
44-
set(CMAKE_CXX_FLAGS "-O3 -march=westmere")
44+
if (APPLE)
45+
set(CMAKE_CXX_FLAGS "-O3")
46+
else()
47+
message(STATUS "CI environment detected. Set compilation flags targetting Westmere microarch.")
48+
set(CMAKE_CXX_FLAGS "-O3 -march=westmere")
49+
endif()
4550
elseif(DEFINED ENV{CONDA_BUILD})
4651
message(STATUS "conda build environment detected. Let conda set compilation flags accordingly.")
4752
# set(CMAKE_CXX_FLAGS "-O3 -march=ivybridge -mfma -ffp-contract=fast")
@@ -106,7 +111,7 @@ else()
106111
message(STATUS "Boost include dirs are ${Boost_INCLUDE_DIRS}")
107112
endif()
108113

109-
add_subdirectory(thirdparty/pybind11)
114+
# add_subdirectory(thirdparty/pybind11)
110115
add_subdirectory(thirdparty/fmt EXCLUDE_FROM_ALL)
111116
set(XTENSOR_USE_OPENMP 0)
112117
set(XTENSOR_USE_TBB 0)
@@ -164,4 +169,4 @@ target_link_libraries(profiling PRIVATE fmt::fmt-header-only)
164169
#install(TARGETS ${PROJECT_NAME}
165170
# #LIBRARY
166171
# DESTINATION src/${PROJECT_NAME})
167-
#install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION ${PROJECT_NAME})
172+
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION .)

conda.recipe/meta.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
{% set data = load_setup_py_data(setup_file='../setup.py', from_recipe_dir=True) %}
2-
{% set version = data.get('version') %}
3-
41
package:
52
name: simsopt
6-
version: {{ version }}
3+
version: {{ GIT_DESCRIBE_TAG }}+{{ GIT_BUILD_STR }}
74

85
source:
96
path: ..
@@ -24,14 +21,17 @@ requirements:
2421
- libgomp # [linux]
2522
- "setuptools_scm[toml]"
2623
- boost
24+
- pybind11
25+
- scikit-build-core
2726

2827
host:
2928
- pip
3029
- wheel
31-
- setuptools
3230
- numpy {{ numpy }}
3331
- "setuptools_scm[toml]"
32+
- scikit-build-core
3433
- python {{ python }}
34+
- pybind11
3535

3636
run:
3737
- python
@@ -49,13 +49,13 @@ requirements:
4949
- pyevtk
5050

5151
about:
52-
home: {{ data.get('url') }}
52+
home: https://github.com/hiddenSymmetries/simsopt
5353
summary: simplified framework for stellarator optimization
5454
license: MIT
5555
license_file: "LICENSE"
5656
description:
5757
doc_url: https://simsopt.readthedocs.io/
58-
dev_url: {{ data.get('url') }}
58+
dev_url: https://github.com/hiddenSymmetries/simsopt
5959

6060
extra:
6161
recipe-maintainers:

pyproject.toml

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,95 @@
11
[build-system]
2-
requires = ["setuptools>=45", "wheel", "oldest-supported-numpy", "cmake", "ninja", "setuptools_scm[toml]>=6.0"]
3-
build-backend = "setuptools.build_meta"
2+
requires = [
3+
"scikit-build-core>=0.3.3",
4+
"pybind11",
5+
"oldest-supported-numpy",
6+
"setuptools_scm>=8.0",
7+
'tomli; python_version < "3.11"',]
8+
build-backend = "scikit_build_core.build"
9+
10+
[project]
11+
name = "simsopt"
12+
license = {text = "MIT License"}
13+
description="Framework for optimizing stellarators"
14+
readme = "README.md"
15+
# long_description = file: README.md
16+
# long_description_content_type = text/markdown
17+
requires-python = ">=3.8"
18+
authors = [
19+
{name = "Matt Landreman", email = "[email protected]"},
20+
{name = "Bharat Medasani", email = "[email protected]"},
21+
{name = "Florian Wechsung", email = "[email protected]"}
22+
]
23+
maintainers = [
24+
{name = "Bharat Medasani", email = "[email protected]"},
25+
{name = "Matt Landreman", email = "[email protected]"},
26+
]
27+
classifiers = [
28+
"Development Status :: 5 - Production/Stable",
29+
"Intended Audience :: Science/Research",
30+
"Topic :: Scientific/Engineering :: Physics",
31+
"License :: OSI Approved :: MIT License",
32+
"Operating System :: MacOS :: MacOS X",
33+
"Operating System :: POSIX :: Linux",
34+
"Environment :: Console",
35+
"Programming Language :: Python :: 3 :: Only",
36+
"Programming Language :: Python :: 3.8",
37+
"Programming Language :: Python :: 3.9",
38+
"Programming Language :: Python :: 3.10"
39+
]
40+
keywords = [
41+
"plasma physics",
42+
"plasma",
43+
"magnetohydrodynamics",
44+
"mhd",
45+
"nuclear fusion reactor",
46+
"fusion",
47+
"stellarator",
48+
"vmec",
49+
"spec",
50+
"optimization",
51+
"Biot-Savart",
52+
"magnetostatics"
53+
]
54+
dependencies = [
55+
"numpy>=1.21",
56+
"jax>=0.2.5",
57+
"jaxlib>=0.1.56",
58+
"scipy>=1.5.4",
59+
"Deprecated>=1.2.10",
60+
"nptyping>=1.3.0",
61+
"monty>=2021.6.10",
62+
"ruamel.yaml",
63+
"sympy",
64+
"f90nml",
65+
"randomgen",
66+
"pyevtk",
67+
"matplotlib"
68+
]
69+
dynamic = ["version"]
70+
71+
[project.optional-dependencies]
72+
SPEC = ["py_spec>=3.0.1", "pyoculus>=0.1.1", "h5py>=3.1.0"]
73+
MPI = ["mpi4py>=3.0.3"]
74+
VIS = ["vtk >= 8.1.2", "PyQt5", "mayavi", "plotly", "networkx"]
75+
DOCS = ["sphinx", "sphinx-rtd-theme"]
76+
77+
[project.urls]
78+
Homepage = "https://github.com/hiddenSymmetries/simsopt"
79+
Download = "https://pypi.org/project/simsopt"
80+
Issues = "https://github.com/hiddenSymmetries/simsopt/issues"
81+
Documentation = "https://simsopt.readthedocs.io"
82+
Repository = "https://github.com/hiddenSymmetries/simsopt"
83+
84+
[tool.setuptools_scm]
85+
write_to = "src/simsopt/_version.py"
86+
local_scheme = "dirty"
87+
88+
[tool.scikit-build]
89+
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
90+
sdist.include = ["src/simsopt/_version.py"]
91+
build-dir = "build/{wheel_tag}"
492

5-
[tools.setuptools_scm]
693

794
[tool.ruff]
895
src = ["src/simsopt"]
@@ -18,3 +105,14 @@ extend-exclude = ["thirdparty"]
18105
"tests/geo/test_curve.py" = ["F401"]
19106
"tests/geo/test_surface.py" = ["F401"]
20107
"tests/mhd/test_virtual_casing.py" = ["F841"]
108+
109+
[tool.coverage.run]
110+
parallel = true
111+
relative_files = true
112+
source = ["simsopt"]
113+
114+
[tool.coverage.paths]
115+
source = [
116+
"src",
117+
"/**/lib*/python*/site-packages"
118+
]

0 commit comments

Comments
 (0)