Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 8 Jun 2017 14:11:43 +0000 (UTC)
From:      Ben Woods <woodsb02@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r442935 - in head/textproc: . py-sphinx py-sphinx/files py3-sphinx
Message-ID:  <201706081411.v58EBh7Y015906@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: woodsb02
Date: Thu Jun  8 14:11:43 2017
New Revision: 442935
URL: https://svnweb.freebsd.org/changeset/ports/442935

Log:
  [NEW] textproc/py3-sphinx: Create Python 3.x version of this port
  
  Also make the following changes for the master textproc/py-sphinx port:
   - Remove post-build introduced when port was updated to version 1.2 in
     r336515, but is no longer required after version 1.2.1 [1].
   - Include upstream patch which fixes the bundling of grammar files [2]
  
  [1] https://github.com/sphinx-doc/sphinx/blob/1.2.1/CHANGES#L51-L53
  [2] https://github.com/sphinx-doc/sphinx/commit/b03b7e543f5e135d046d2fe407def219336c12b2
  
  PR:		217475
  PR:		217447
  PR:		219833
  Submitted by:	dbaio
  Approved by:	kmoore (maintainer timeout)

Added:
  head/textproc/py-sphinx/files/
  head/textproc/py-sphinx/files/patch-b03b7e543f5e135d046d2fe407def219336c12b2   (contents, props changed)
  head/textproc/py3-sphinx/
  head/textproc/py3-sphinx/Makefile   (contents, props changed)
Modified:
  head/textproc/Makefile
  head/textproc/py-sphinx/Makefile

Modified: head/textproc/Makefile
==============================================================================
--- head/textproc/Makefile	Thu Jun  8 14:08:03 2017	(r442934)
+++ head/textproc/Makefile	Thu Jun  8 14:11:43 2017	(r442935)
@@ -1381,6 +1381,7 @@
     SUBDIR += py3-pygments
     SUBDIR += py3-pystemmer
     SUBDIR += py3-snowballstemmer
+    SUBDIR += py3-sphinx
     SUBDIR += py3-sphinx_rtd_theme
     SUBDIR += py3-texttable
     SUBDIR += pychm

Modified: head/textproc/py-sphinx/Makefile
==============================================================================
--- head/textproc/py-sphinx/Makefile	Thu Jun  8 14:08:03 2017	(r442934)
+++ head/textproc/py-sphinx/Makefile	Thu Jun  8 14:11:43 2017	(r442935)
@@ -3,6 +3,7 @@
 
 PORTNAME=	sphinx
 PORTVERSION=	1.4.8
+PORTREVISION=	1
 PORTEPOCH=	1
 CATEGORIES=	textproc python
 MASTER_SITES=	CHEESESHOP
@@ -16,10 +17,10 @@ COMMENT=	Python documentation generator
 LICENSE=	BSD2CLAUSE
 LICENSE_FILE=	${WRKSRC}/LICENSE
 
-BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Jinja2>=2.3:devel/py-Jinja2 \
+BUILD_DEPENDS?=	${PYTHON_PKGNAMEPREFIX}Jinja2>=2.3:devel/py-Jinja2 \
 		${PYTHON_PKGNAMEPREFIX}docutils>=0.11:textproc/py-docutils \
 		${PYTHON_PKGNAMEPREFIX}six>=1.4:devel/py-six
-RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Babel>=1.3:devel/py-babel\
+RUN_DEPENDS?=	${PYTHON_PKGNAMEPREFIX}Babel>=1.3:devel/py-babel\
 		${PYTHON_PKGNAMEPREFIX}Jinja2>=2.3:devel/py-Jinja2 \
 		${PYTHON_PKGNAMEPREFIX}docutils>=0.11:textproc/py-docutils \
 		${PYTHON_PKGNAMEPREFIX}pygments>=2.0:textproc/py-pygments \
@@ -31,13 +32,8 @@ RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Babel>=1.3:devel/p
 		${PYTHON_PKGNAMEPREFIX}imagesize>=0.7.1:graphics/py-imagesize \
 		${LOCALBASE}/share/certs/ca-root-nss.crt:security/ca_root_nss
 
-USES=		python
+USES?=		python
 USE_PYTHON=	autoplist distutils
 NO_ARCH=	yes
-
-post-build:
-	cd ${WRKSRC}/build/lib && \
-	${SETENV} PYTHONPATH=${WRKSRC}/build/lib:${PYTHONPREFIX_SITELIBDIR} \
-	${PYTHON_CMD} -m sphinx.pycode.pgen2.driver -c 'import load_grammar'
 
 .include <bsd.port.mk>

Added: head/textproc/py-sphinx/files/patch-b03b7e543f5e135d046d2fe407def219336c12b2
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py-sphinx/files/patch-b03b7e543f5e135d046d2fe407def219336c12b2	Thu Jun  8 14:11:43 2017	(r442935)
@@ -0,0 +1,171 @@
+From e1e82e43c9280e7486aad49c7f84a75f4ee1654b Mon Sep 17 00:00:00 2001
+From: Takeshi KOMIYA <i.tkomiya@gmail.com>
+Date: Tue, 12 Jul 2016 02:33:19 +0900
+Subject: [PATCH 1/3] Load some library lazily on sphinx.util to lessen
+ dependency
+
+---
+ sphinx/util/__init__.py | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py
+--- sphinx/util/__init__.py.orig
++++ sphinx/util/__init__.py
+@@ -24,12 +24,8 @@
+ from six import iteritems, text_type, binary_type
+ from six.moves import range
+ from six.moves.urllib.parse import urlsplit, urlunsplit, quote_plus, parse_qsl, urlencode
+-import docutils
+ from docutils.utils import relative_path
+ 
+-import jinja2
+-
+-import sphinx
+ from sphinx.errors import PycodeError, SphinxParallelError, ExtensionError
+ from sphinx.util.console import strip_colors
+ from sphinx.util.fileutil import copy_asset_file
+@@ -186,6 +182,9 @@ def copy_static_entry(source, targetdir, builder, context={},
+ 
+ def save_traceback(app):
+     """Save the current exception's traceback in a temporary file."""
++    import sphinx
++    import jinja2
++    import docutils
+     import platform
+     exc = sys.exc_info()[1]
+     if isinstance(exc, SphinxParallelError):
+
+From 2ccb75c98fbe7e69e4689725affa268e7c538315 Mon Sep 17 00:00:00 2001
+From: Takeshi KOMIYA <i.tkomiya@gmail.com>
+Date: Mon, 11 Jul 2016 00:27:06 +0900
+Subject: [PATCH 2/3] Bundle sphinx/pycode/Grammar-*.pickle (ref: #2765)
+
+So far, sphinx generates the grammar files on demand.
+It causes uninstallation does not remove whole of files.
+With this fix, Sphinx bundles the files in the package.
+---
+ MANIFEST.in                   |  3 +--
+ setup.py                      |  5 +++++
+ sphinx/pycode/pgen2/driver.py | 42 ++++++++++++++++++++++++++----------------
+ tox.ini                       |  2 ++
+ 4 files changed, 34 insertions(+), 18 deletions(-)
+
+diff --git a/MANIFEST.in b/MANIFEST.in
+--- MANIFEST.in.orig
++++ MANIFEST.in
+@@ -20,8 +20,7 @@ recursive-include sphinx/search/non-minified-js *.js
+ recursive-include sphinx/ext/autosummary/templates *
+ recursive-include tests *
+ recursive-include utils *
+-include sphinx/pycode/Grammar-py2.txt
+-include sphinx/pycode/Grammar-py3.txt
++include sphinx/pycode/Grammar-py*
+ 
+ recursive-include doc *
+ prune doc/_build
+diff --git a/setup.py b/setup.py
+--- setup.py.orig
++++ setup.py
+@@ -6,6 +6,7 @@
+ from distutils import log
+ 
+ import sphinx
++from sphinx.pycode.pgen2.driver import compile_grammar
+ 
+ long_desc = '''
+ Sphinx is a tool that makes it easy to create intelligent and beautiful
+@@ -72,6 +73,10 @@
+ if sys.platform == 'win32':
+     requires.append('colorama>=0.3.5')
+ 
++# Compile grammars before packaging
++compile_grammar('sphinx/pycode/Grammar-py2.txt')
++compile_grammar('sphinx/pycode/Grammar-py3.txt')
++
+ # Provide a "compile_catalog" command that also creates the translated
+ # JavaScript files if Babel is available.
+ 
+diff --git a/sphinx/pycode/pgen2/driver.py b/sphinx/pycode/pgen2/driver.py
+--- sphinx/pycode/pgen2/driver.py.orig
++++ sphinx/pycode/pgen2/driver.py
+@@ -109,27 +109,37 @@ def generate_lines(text):
+         yield ""
+ 
+ 
+-def load_grammar(gt="Grammar.txt", gp=None,
+-                 save=True, force=False, logger=None):
++def get_compiled_path(filename):
++    head, tail = os.path.splitext(filename)
++    if tail == ".txt":
++        tail = ""
++    # embed Sphinx major version for the case we ever change the grammar...
++    return "%s%s-sphinx%s.pickle" % (head, tail, ".".join(map(str, sphinx.version_info[:2])))
++
++
++def compile_grammar(gt='Grammar.txt', logger=None):
++    """Compile the grammer."""
++    if logger is None:
++        logger = logging.getLogger()
++
++    logger.info("Generating grammar tables from %s", gt)
++    g = pgen.generate_grammar(gt)
++    gp = get_compiled_path(gt)
++    logger.info("Writing grammar tables to %s", gp)
++    try:
++        g.dump(gp)
++    except IOError as e:
++        logger.info("Writing failed:"+str(e))
++
++
++def load_grammar(gt="Grammar.txt", logger=None):
+     """Load the grammar (maybe from a pickle)."""
+     if logger is None:
+         logger = logging.getLogger()
+-    if gp is None:
+-        head, tail = os.path.splitext(gt)
+-        if tail == ".txt":
+-            tail = ""
+-        # embed Sphinx major version for the case we ever change the grammar...
+-        gp = head + tail + "-sphinx" + \
+-             ".".join(map(str, sphinx.version_info[:2])) + ".pickle"
+-    if force or not _newer(gp, gt):
++    gp = get_compiled_path(gt)
++    if not os.path.exists(gp):
+         logger.info("Generating grammar tables from %s", gt)
+         g = pgen.generate_grammar(gt)
+-        if save:
+-            logger.info("Writing grammar tables to %s", gp)
+-            try:
+-                g.dump(gp)
+-            except IOError as e:
+-                logger.info("Writing failed:"+str(e))
+     else:
+         g = grammar.Grammar()
+         g.load(gp)
+
+From 1cabc17edb0c61a7c702c72f98ada38ae0ecaa22 Mon Sep 17 00:00:00 2001
+From: Takeshi KOMIYA <i.tkomiya@gmail.com>
+Date: Tue, 12 Jul 2016 12:10:36 +0900
+Subject: [PATCH 3/3] Remove sphinx version from the filename of compiled
+ grammar files
+
+Now sphinx bundles the compiled grammar files.  Then it will be replaced
+on upgrading sphinx.  So the sphinx version is not needed on its
+filename.
+---
+ sphinx/pycode/pgen2/driver.py | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/sphinx/pycode/pgen2/driver.py b/sphinx/pycode/pgen2/driver.py
+--- sphinx/pycode/pgen2/driver.py.orig
++++ sphinx/pycode/pgen2/driver.py
+@@ -113,8 +113,7 @@ def get_compiled_path(filename):
+     head, tail = os.path.splitext(filename)
+     if tail == ".txt":
+         tail = ""
+-    # embed Sphinx major version for the case we ever change the grammar...
+-    return "%s%s-sphinx%s.pickle" % (head, tail, ".".join(map(str, sphinx.version_info[:2])))
++    return "%s%s.pickle" % (head, tail)
+ 
+ 
+ def compile_grammar(gt='Grammar.txt', logger=None):

Added: head/textproc/py3-sphinx/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/textproc/py3-sphinx/Makefile	Thu Jun  8 14:11:43 2017	(r442935)
@@ -0,0 +1,23 @@
+# Created by: Ben Woods <woodsb02@FreeBSD.org>
+# $FreeBSD$
+
+MASTERDIR=	${.CURDIR}/../py-sphinx
+
+BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Jinja2>=2.3:devel/py3-Jinja2 \
+		${PYTHON_PKGNAMEPREFIX}docutils>=0.11:textproc/py3-docutils \
+		${PYTHON_PKGNAMEPREFIX}six>=1.4:devel/py3-six
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Babel>=1.3:devel/py3-babel\
+		${PYTHON_PKGNAMEPREFIX}Jinja2>=2.3:devel/py3-Jinja2 \
+		${PYTHON_PKGNAMEPREFIX}docutils>=0.11:textproc/py3-docutils \
+		${PYTHON_PKGNAMEPREFIX}pygments>=2.0:textproc/py3-pygments \
+		${PYTHON_PKGNAMEPREFIX}Babel>=1.3:devel/py3-babel \
+		${PYTHON_PKGNAMEPREFIX}sphinx_rtd_theme>=0.1:textproc/py3-sphinx_rtd_theme \
+		${PYTHON_PKGNAMEPREFIX}alabaster>=0.7:textproc/py3-alabaster \
+		${PYTHON_PKGNAMEPREFIX}snowballstemmer>=1.1:textproc/py3-snowballstemmer \
+		${PYTHON_PKGNAMEPREFIX}six>=1.4:devel/py3-six \
+		${PYTHON_PKGNAMEPREFIX}imagesize>=0.7.1:graphics/py3-imagesize \
+		${LOCALBASE}/share/certs/ca-root-nss.crt:security/ca_root_nss
+
+USES=	python:3.3+
+
+.include "${MASTERDIR}/Makefile"



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706081411.v58EBh7Y015906>