Skip to content

Commit c64b30a

Browse files
committed
First commit
0 parents  commit c64b30a

56 files changed

Lines changed: 1686 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/docs-deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: docs-deploy
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
permissions:
8+
contents: read
9+
pages: write
10+
id-token: write
11+
12+
concurrency:
13+
group: "pages"
14+
cancel-in-progress: false
15+
16+
jobs:
17+
build:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- uses: actions/setup-python@v5
24+
with:
25+
python-version: "3.x"
26+
27+
- name: Create Build Environment
28+
run: |
29+
python -m pip install --upgrade pip
30+
python -m pip install -r ${GITHUB_WORKSPACE}/doc/requirements.txt
31+
mkdir -p ${{runner.workspace}}/build
32+
33+
- name: Build documentation
34+
run: |
35+
sphinx-build -T -E -b html \
36+
"${GITHUB_WORKSPACE}/doc" \
37+
"${{runner.workspace}}/build"
38+
39+
- name: Upload artifact
40+
uses: actions/upload-pages-artifact@v1
41+
with:
42+
path: ${{runner.workspace}}/build
43+
44+
deploy:
45+
environment:
46+
name: github-pages
47+
url: ${{ steps.deployment.outputs.page_url }}
48+
49+
runs-on: ubuntu-latest
50+
needs: build
51+
52+
steps:
53+
- name: Deploy to GitHub Pages
54+
id: deployment
55+
uses: actions/deploy-pages@v2

.github/workflows/release.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: PyPi Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
pypi-publish:
13+
if: startsWith(github.ref, 'refs/tags/')
14+
runs-on: ubuntu-latest
15+
environment: release
16+
permissions:
17+
id-token: write
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.x"
25+
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
python -m pip install build twine
30+
31+
- name: Build package
32+
run: |
33+
python -m build --sdist
34+
35+
- name: Check metadata
36+
run: twine check dist/*
37+
38+
- name: Publish package distributions to PyPI
39+
uses: pypa/gh-action-pypi-publish@release/v1
40+
41+
github-release:
42+
runs-on: ubuntu-latest
43+
name: GitHub release
44+
environment: release
45+
permissions:
46+
contents: write
47+
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Get release version
52+
id: get_version
53+
uses: actions/github-script@v7
54+
with:
55+
script: core.setOutput('version', context.ref.replace("refs/tags/", ""))
56+
57+
- name: Create GitHub release
58+
uses: softprops/action-gh-release@v2
59+
if: startsWith(github.ref, 'refs/tags/')
60+
with:
61+
name: "v${{ steps.get_version.outputs.version }}"
62+
body: "Notes: https://python-cmake.github.io/pytest-cmake/release/release_notes.html"
63+

.github/workflows/test.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: tests
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
pull_request:
8+
branches: [ main ]
9+
10+
# Run tests once a week on Sunday.
11+
schedule:
12+
- cron: "0 6 * * 0"
13+
14+
jobs:
15+
run-tests:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
sphinx: [ "5", "6", "7" ]
20+
cmake: [ "3.20", "3.29" ]
21+
os: [ "ubuntu", "macos", "windows" ]
22+
python: [ "3.8", "3.11", "3.12" ]
23+
24+
name: |
25+
v${{ matrix.sphinx }}-${{ matrix.cmake }}
26+
[${{ matrix.os }}-py${{ matrix.python }}]
27+
28+
runs-on: "${{ matrix.os }}-latest"
29+
30+
env:
31+
BUNDLE_PYTHON_TESTS: ${{ matrix.bundled }}
32+
33+
steps:
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: "${{ matrix.python }}"
37+
38+
- uses: actions/checkout@v4
39+
40+
- name: Setup cmake
41+
uses: jwlawson/actions-setup-cmake@v2.0
42+
if: ${{matrix.os != 'windows' || matrix.cmake != '3.20'}}
43+
with:
44+
cmake-version: "${{ matrix.cmake }}.x"
45+
46+
- name: Setup cmake (Bump up CMake minimal version for Visual Studio 17 2022)
47+
uses: jwlawson/actions-setup-cmake@v2.0
48+
if: ${{matrix.os == 'windows' && matrix.cmake == '3.20'}}
49+
with:
50+
# Visual Studio 17 2022 requires at least CMake 3.21.
51+
# https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2017%202022.html
52+
cmake-version: "3.21.x"
53+
54+
- name: Install sphinx + sphinx-cmake
55+
run: pip install . sphinx==${{ matrix.sphinx }}.*
56+
57+
- name: Build Tests
58+
run: |
59+
cmake --version
60+
cmake -S ./test -B ./build
61+
cmake --build ./build --config Release
62+
63+
- name: Run Tests
64+
working-directory: build
65+
run: ctest -VV -C Release

.gitignore

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# cmake artifacts
2+
CMakeLists.txt.user
3+
CMakeCache.txt
4+
CMakeFiles
5+
CMakeScripts
6+
Testing
7+
Makefile
8+
cmake_install.cmake
9+
cmake-build-*/
10+
install_manifest.txt
11+
compile_commands.json
12+
CTestTestfile.cmake
13+
14+
# Byte-compiled / optimized / DLL files
15+
__pycache__/
16+
*.py[cod]
17+
*$py.class
18+
19+
# Distribution / packaging
20+
.Python
21+
env/
22+
build/
23+
develop-eggs/
24+
dist/
25+
downloads/
26+
eggs/
27+
.eggs/
28+
lib/
29+
lib64/
30+
parts/
31+
sdist/
32+
var/
33+
*.egg-info/
34+
.installed.cfg
35+
*.egg
36+
37+
# virtualenv
38+
venv/
39+
ENV/
40+
41+
# Caches
42+
Thumbs.db
43+
44+
# Development
45+
.project
46+
.pydevproject
47+
.settings
48+
.idea/
49+
.history/
50+
51+
# Unit test / coverage reports
52+
htmlcov/
53+
.coverage
54+
.coverage.*
55+
.cache
56+
*,cover
57+
.pytest_cache/

.versup.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"files": {
3+
"pyproject.toml": [
4+
[
5+
"version = \"([\\d\\.]+)\"",
6+
"version = \"[version]\""
7+
]
8+
],
9+
"setup.py": [
10+
[
11+
"version=\"([\\d\\.]+)\"",
12+
"version=\"[version]\""
13+
]
14+
],
15+
"doc/release/release_notes.rst": [
16+
[
17+
".. release:: Upcoming",
18+
".. release:: [version]\n :date: [version_date]"
19+
]
20+
]
21+
},
22+
"changelog": {
23+
"enabled": false
24+
},
25+
"commit": {
26+
"mainbranch": "main"
27+
}
28+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Jeremy Retailleau
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Sphinx CMake
2+
3+
[![PyPi version](https://img.shields.io/pypi/v/sphinx-cmake.svg?logo=pypi&label=PyPI&logoColor=gold)](https://pypi.python.org/pypi/sphinx-cmake)
4+
[![CMake](https://img.shields.io/badge/CMake-3.20...3.29-blue.svg?logo=CMake&logoColor=blue)](https://cmake.org)
5+
[![Test](https://github.com/python-cmake/sphinx-cmake/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/python-cmake/sphinx-cmake/actions/workflows/test.yml)
6+
[![License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7+
8+
This project provides convenient ways to use [Sphinx](https://www.sphinx-doc.org/)
9+
within a [CMake](https://cmake.org/) project. The package can be discovered from a specific range of
10+
versions on Linux, macOS or Windows using the
11+
[find_package](https://cmake.org/cmake/help/latest/command/find_package.html)
12+
function:
13+
14+
```cmake
15+
find_package(Sphinx 7.3.7 REQUIRED)
16+
```
17+
18+
A ``sphinx_add_docs`` function is provided as a convenience for adding a target
19+
for generating documentation with Sphinx.
20+
21+
```cmake
22+
sphinx_add_docs(docs ALL)
23+
```
24+
25+
## Documentation
26+
27+
Full documentation, including installation and setup guides, can be found at
28+
https://python-cmake.github.io/sphinx-cmake/

build_backend.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Custom backend to ensure compatibility with Python 2.7.
2+
"""
3+
4+
import sys
5+
6+
if sys.version_info[0] < 3:
7+
from setuptools.build_meta import *
8+
else:
9+
from hatchling.build import *

build_config.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
2+
3+
import pathlib
4+
import subprocess
5+
6+
7+
class BuildConfig(BuildHookInterface):
8+
"""Builder to create and share sphinx config."""
9+
10+
def initialize(self, version, build_data):
11+
"""Execute builder."""
12+
import sphinx
13+
14+
root = pathlib.Path(__file__).parent.resolve()
15+
build_path = (root / "build")
16+
build_path.mkdir(parents=True, exist_ok=True)
17+
18+
# CMake search procedure is limited to CMake package configuration files
19+
# and does not work with modules. Hence, we are generating a
20+
# configuration file based on the CMake modules created.
21+
# https://cmake.org/cmake/help/latest/command/find_package.html
22+
config_path = (build_path / "SphinxConfig.cmake")
23+
with config_path.open("w", encoding="utf-8") as stream:
24+
stream.write(
25+
"include(${CMAKE_CURRENT_LIST_DIR}/FindSphinx.cmake)\n"
26+
)
27+
28+
# Generate CMake config version file for client to target a specific
29+
# version of Sphinx within CMake projects.
30+
version_config_path = (build_path / "SphinxConfigVersion.cmake")
31+
script_path = (build_path / "SphinxConfigVersionScript.cmake")
32+
with script_path.open("w", encoding="utf-8") as stream:
33+
stream.write(
34+
"include(CMakePackageConfigHelpers)\n"
35+
"write_basic_package_version_file(\n"
36+
f" \"{str(version_config_path)}\"\n"
37+
f" VERSION {sphinx.__version__}\n"
38+
" COMPATIBILITY AnyNewerVersion\n"
39+
")"
40+
)
41+
42+
subprocess.call(["cmake", "-P", str(script_path), "-VV"])

0 commit comments

Comments
 (0)