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

Build docs separate #122

Merged
merged 17 commits into from
Jul 20, 2024
Merged
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
28 changes: 0 additions & 28 deletions .cirrus.yml

This file was deleted.

12 changes: 12 additions & 0 deletions .github/workflows/sage_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ jobs:

- name: Do the tests
run: sage -python -m snappy.test

- name: Build docs
# Doesn't just do "make html" as neither "make" nor "zip" is
# installed in this image.
run: |
cd /__w/SnapPy/SnapPy/doc_src
sage -python -m sphinx -b html -E -d _build/doctrees . _build/doc

- uses: actions/upload-artifact@v3
with:
name: doc
path: /__w/SnapPy/SnapPy/doc_src/_build/doc/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be a mess to download all that stuff. Would it be hard to install zip in the container temporarily?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The upload-artifact action automatically puts the files in a single zipfile for easy download.

12 changes: 5 additions & 7 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
os: [ubuntu-22.04, macos-11, windows-2019]

steps:
- uses: actions/checkout@v3
Expand All @@ -18,23 +18,21 @@ jobs:
uses: pypa/cibuildwheel@v2.19.2
env:
# Skip Python 32 bit Linux, and PyPy
CIBW_BUILD: "cp312-*"
CIBW_SKIP: "*-manylinux_i686 *musllinux* pp*"
CIBW_BEFORE_ALL_LINUX: yum install -y tk mesa-libGLU-devel
CIBW_BEFORE_BUILD: >
pip install cython FXrays low_index sphinx sphinx_rtd_theme &&
pip install --pre --extra-index-url https://test.pypi.org/simple cypari &&
pip install git+https://github.com/3-manifolds/PLink &&
pip install git+https://github.com/3-manifolds/snappy_manifolds &&
pip install git+https://github.com/3-manifolds/Spherogram
pip install cython
CIBW_BEFORE_TEST: >
pip install cython low_index &&
pip install low_index &&
pip install --pre --extra-index-url https://test.pypi.org/simple cypari &&
pip install git+https://github.com/3-manifolds/PLink &&
pip install git+https://github.com/3-manifolds/snappy_manifolds &&
pip install git+https://github.com/3-manifolds/Spherogram
CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair --strip -w {dest_dir} {wheel}
CIBW_TEST_COMMAND: python -m snappy.test --skip-modern-opengl


- uses: actions/upload-artifact@v3
with:
name: snappy_all_wheels
Expand Down
92 changes: 9 additions & 83 deletions doc_src/Makefile
Original file line number Diff line number Diff line change
@@ -1,96 +1,22 @@
# Makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
INSTALLDIR = ../snappy/doc
SPHINXBUILD = python -m sphinx

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d _build/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest install
.PHONY: clean html

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo " install to install the documentation in the snappy module directory"
@echo " clean to delete all generated files in _build"

clean:
-rm -rf _build/*

# sphinx options:
# -E forces it to rebuild the docs from scratch every time.
# -d keeps the intermediate doctree files out the html directory.
html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) _build/html
@echo
@echo "Build finished. The HTML pages are in _build/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) _build/dirhtml
@echo
@echo "Build finished. The HTML pages are in _build/dirhtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in _build/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) _build/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in _build/qthelp, like this:"
@echo "# qcollectiongenerator _build/qthelp/PLink.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile _build/qthelp/PLink.qhc"

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex
@echo
@echo "Build finished; the LaTeX files are in _build/latex."
@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
"run these through (pdf)latex."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) _build/changes
$(SPHINXBUILD) -b html -E -d _build/doctrees . _build/doc
cd _build && zip -rq snappy_doc.zip doc
@echo
@echo "The overview file is in _build/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) _build/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in _build/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) _build/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in _build/doctest/output.txt."


install: clean html
rm -rf $(INSTALLDIR)
mv _build/html $(INSTALLDIR)
@echo "Installed docs in snappy directory"
@echo "HTML build done. Result was _build/doc and _build/snappy_doc.zip."
41 changes: 41 additions & 0 deletions doc_src/add_doc_to_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /usr/bin/env python3

"""
Adds doc directory to exisiting wheel
"""

import subprocess
import sys
import os
import tempfile
import glob
import shutil

doc_zipfile = os.path.abspath(sys.argv[1])
wheel_path = os.path.abspath(sys.argv[2])

if not (doc_zipfile.endswith('.zip') and wheel_path.endswith('.whl')):
raise ValueError('Usage: add_doc_to_wheel docs.zip snappy.whl')

python = sys.executable
tmp_dir = tempfile.mkdtemp()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with tempfile.TemporaryDirectory() as tmp_dir:

might be more pythonic. Not sure whether cleaning up the tmp directory at the end is a feature (making debugging easier) or bug.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was intended to make debugging easier.

subprocess.check_call([python, '-m', 'wheel', 'unpack', '--dest', tmp_dir, wheel_path])
pkg, version = os.path.basename(wheel_path).split('-')[:2]
wheel_dir = os.path.join(tmp_dir, pkg + '-' + version)
target = os.path.join(wheel_dir, pkg)
target_doc_dir = os.path.join(target, 'doc')
if os.path.exists(target_doc_dir):
print('Deleting existing docs...')
shutil.rmtree(target_doc_dir)
print('Unpacking docs..')
subprocess.check_call(['unzip', '-q', doc_zipfile, '-d', target])
subprocess.check_call([python, '-m', 'wheel', 'pack', '--dest', tmp_dir, wheel_dir])
new_whl = glob.glob(os.path.join(tmp_dir, pkg + '-' + version + '*.whl'))[0]
if os.path.basename(new_whl) != os.path.basename(wheel_path):
raise ValueError(f'Wheel tag changed, see {tmp_dir}')
subprocess.check_call(['cp', new_whl, wheel_path])
print(f'Added docs to {os.path.basename(wheel_path)} in-place')




77 changes: 3 additions & 74 deletions doc_src/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,8 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys, os, datetime, sysconfig, platform

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

def build_lib_dir():
if sys.platform == 'darwin':
target = sysconfig.get_platform().split('-')[-1]
machine = platform.machine()
# Check if we're cross-compiling. If so, module must already
# have been built for the host architecture.
if target == 'universal2':
python_platform = 'macosx-10.9-universal2'
elif target != machine:
python_platform = {'x86_64':'macosx-10.9-x86_64',
'arm64': 'macosx-11-arm64'}[machine]
else:
python_platform = sysconfig.get_platform()

else:
python_platform = sysconfig.get_platform()

v0, v1 = sys.version_info[:2]
old_path = os.path.join(
'..',
'build',
f'lib.{python_platform}-{v0}.{v1}')
new_path = os.path.join(
'..',
'build',
f'lib.{python_platform}-cpython-{v0}{v1}')
return os.path.abspath(old_path), os.path.abspath(new_path)

for path in build_lib_dir():
print('sys.path addition:', path)
sys.path.insert(0, path)

import os
import datetime
import snappy
print('Using: ' + snappy.__file__)

Expand Down Expand Up @@ -80,7 +44,6 @@ def build_lib_dir():

# General information about the project.


project = u'SnapPy'
copyright = u'2009-%d, by Marc Culler, Nathan Dunfield, Matthias Goerner, Jeffrey Weeks and others' % datetime.datetime.now().year

Expand Down Expand Up @@ -177,9 +140,9 @@ def setup(app):
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.

html_theme_options = {
'collapse_navigation': True,

'navigation_depth': 5,
}

Expand Down Expand Up @@ -247,37 +210,3 @@ def setup(app):

# Output file base name for HTML help builder.
htmlhelp_basename = 'SnapPydoc'


# -- Options for LaTeX output --------------------------------------------------

# The paper size ('letter' or 'a4').
#latex_paper_size = 'letter'

# The font size ('10pt', '11pt' or '12pt').
#latex_font_size = '10pt'

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'SnapPy.tex', u'SnapPy Documentation',
u'Marc Culler (culler@math.uic.edu) and Nathan Dunfield (nmd@illinois.edu)',
'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
# the title page.
#latex_logo = None

# For "manual" documents, if this is true, then toplevel headings are parts,
# not chapters.
#latex_use_parts = False

# Additional stuff for the LaTeX preamble.
#latex_preamble = ''

# Documents to append as an appendix to all manuals.
#latex_appendices = []

# If false, no module index is generated.
#latex_use_modindex = True
23 changes: 4 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
[build-system]
requires = [
requires = ["setuptools", "wheel", "cython"]

# True build dependenciees
"setuptools>=42",
"wheel",
"cython>=0.28",

# Install dependencies needed to build documentation
"decorator",
"FXrays",
"low_index",
"cypari", # Missing "--pre --extra-index-url https://test.pypi.org/simple" arguments from pip install
"PLink @ git+https://github.com/3-manifolds/PLink",
"snappy_manifolds @ git+https://github.com/3-manifolds/snappy_manifolds",
"Spherogram @ git+https://github.com/3-manifolds/Spherogram",

# Build dependencies to build documentation
"sphinx",
"sphinx_rtd_theme",
]
[tool.cibuildwheel]
build = "cp312-macosx_*"
test-command = "python -m snappy.test"

1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ class SnapPyBuildWheel(bdist_wheel):
def run(self):
python = sys.executable
check_call([python, 'setup.py', 'build'])
check_call([python, 'setup.py', 'build_docs'])
bdist_wheel.run(self)
@staticmethod
def check_command_available():
Expand Down
Loading