-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add recipe for xrst (extract rst files and run sphinx) #25198
Open
bradbell
wants to merge
10
commits into
conda-forge:main
Choose a base branch
from
bradbell:main
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
31c0418
main: Initial recipe directory for conda-forge xrst.
bradbell 999c2ba
main: meta.yaml: Add comments about warning messages, python >= 3.8
bradbell b904101
main: patch xrst.toml because there is a bug in conda pyenchant.
bradbell 60348ad
main: xrst.toml: change test version, not version in source.
bradbell 356515d
main: Some fixes for runing on win_64.
bradbell c920b2f
main: remove pyenchant from install (see comments in meta.yaml).
bradbell 80df5bc
main: split run_test.py into run_test.sh and run_test.bat.
bradbell 582a7f4
main: fix sed command so work on mac, fix comments in dos script.
bradbell 0adf204
main: run_test.bat: fix so truely run the test,
bradbell db29691
Do not need to patch setup.py or pyproject.toml;
bradbell File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
diff --git a/pyproject.toml b/pyproject.toml | ||
index a5d37a9..81c5145 100644 | ||
--- a/pyproject.toml | ||
+++ b/pyproject.toml | ||
@@ -30,7 +30,7 @@ classifiers = [ | ||
dependencies = [ | ||
'sphinx', 'toml', 'sphinx-copybutton', # required | ||
'pytest', # need for testing xrst | ||
- 'pyenchant', 'pyspellchecker', # need the one you use | ||
+ 'pyspellchecker', # need the one you use | ||
'furo', 'sphinx-rtd-theme', 'sphinx-book-theme', # need the ones you use | ||
] | ||
# END_DEPENDENCIES | ||
diff --git a/pytest/test_rst.py b/pytest/test_rst.py | ||
index b159f9e..39b0647 100644 | ||
--- a/pytest/test_rst.py | ||
+++ b/pytest/test_rst.py | ||
@@ -6,6 +6,9 @@ import os | ||
import re | ||
import subprocess | ||
# ---------------------------------------------------------------------------- | ||
+pattern_return_newline = re.compile( r'\r\n' ) | ||
+pattern_include_backslash = re.compile( r'\.\. literalinclude:: .*\\' ) | ||
+# ---------------------------------------------------------------------------- | ||
def get_index_page_name() : | ||
file_obj = open('.readthedocs.yaml', 'r') | ||
file_data = file_obj.read() | ||
@@ -86,6 +89,22 @@ def run_test() : | ||
rst_file_obj.close() | ||
check_file_obj.close() | ||
# | ||
+ # rst_data | ||
+ # dos2unix: relpace \r\n by \n | ||
+ replace = r'\n' | ||
+ rst_data = pattern_return_newline.sub(replace, rst_data) | ||
+ # | ||
+ # rst_data | ||
+ # relpace \ in file names by / | ||
+ m_obj = pattern_include_backslash.search(rst_data) | ||
+ while m_obj != None : | ||
+ start = m_obj.start() | ||
+ end = m_obj.end() | ||
+ text = m_obj.group(0) | ||
+ replace = text.replace( '\\' , '/' ) | ||
+ rst_data = check_data[:start] + replace + rst_data[end:] | ||
+ m_obj = pattern_include_backslash.search(rst_data) | ||
+ # | ||
if rst_data == check_data : | ||
print( f'{rst_name}: OK' ) | ||
else : | ||
diff --git a/setup.py b/setup.py | ||
index 446c6b0..2a56f82 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -27,7 +27,7 @@ setup( | ||
install_requires = [ | ||
'sphinx', 'toml', 'sphinx-copybutton', # required | ||
'pytest', # need for testing xrst | ||
- 'pyenchant', 'pyspellchecker', # need the one you use | ||
+ 'pyspellchecker', # need the one you use | ||
'furo', 'sphinx-rtd-theme', 'sphinx-book-theme', # need the ones you use | ||
], | ||
entry_points = { | ||
diff --git a/tox.ini b/tox.ini | ||
index 8a2e158..4b5ffc8 100644 | ||
--- a/tox.ini | ||
+++ b/tox.ini | ||
@@ -12,6 +12,5 @@ deps = | ||
pytest | ||
toml | ||
pyspellchecker | ||
- pyenchant | ||
# | ||
commands = pytest -s pytest | ||
diff --git a/xrst.toml b/xrst.toml | ||
index 0e52cbf..c26094d 100644 | ||
--- a/xrst.toml | ||
+++ b/xrst.toml | ||
@@ -34,7 +34,7 @@ overline = [ false, false, false, false, false, ] | ||
# ----------------------------------------------------------------------------- | ||
# BEGIN_SPELL_PACKAGE | ||
[spell_package] | ||
-data = 'pyenchant' | ||
+data = 'pyspellchecker' | ||
# END_SPELL_PACKAGE | ||
# ----------------------------------------------------------------------------- | ||
# BEGIN_INPUT_FILES |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# See meta.yaml in | ||
# https://github.com/conda-forge/staged-recipes/blob/main/recipes/example | ||
# | ||
# Note that the example above suggests that one use SPDX identifies for the | ||
# license field but this is not yet supported by conda build or conda-verfity; | ||
# see https://github.com/conda/conda/issues/5280 | ||
# This project uses the SPDX identifier GPL-3.0-or-later; see | ||
# https://spdx.org/licenses/GPL-3.0-or-later.html | ||
# | ||
# Remove pyenchant from requirements because the conda version does not work: | ||
# https://github.com/conda-forge/pyenchant-feedstock/issues/1 | ||
# | ||
# Warnings when in recipes we execute: conda build xrst | ||
# 1. DeprecationWarning: conda_build.cli.main_build.main is deprecated | ||
# and will be removed in 24.1.0. Use `conda build` instead. | ||
# (We get this warning even though we am using `conda build`.) | ||
# 2. No numpy version specified in conda_build_config.yaml. | ||
# Falling back to default numpy value of 1.22. | ||
# (We have not specified a conda_build_config.yaml file for this project.) | ||
# 3. C1115 Found invalid license "GPL-3.0-or-later" in info/index.json | ||
# (See the comments above about SPDX identifiers.) | ||
# | ||
# Warnings when in recipes we execute: conda-verify xrst | ||
# 1. WARNING: Setting build platform. ... | ||
# (We are not setting a specific build platform.) | ||
# 2. WARNING: Setting build arch. ... | ||
# (We are not setting noarch and not a specific build arch.) | ||
# 3. C2122 Found invalid license family "GPL-3.0-or-later" | ||
# (See the comments above about SPDX identifiers.) | ||
# | ||
# | ||
{% set name = "xrst" %} | ||
{% set version = "2024.0.0" %} | ||
{% set home = "https://github.com/bradbell/xrst" %} | ||
|
||
package: | ||
name: {{ name }} | ||
version: {{ version }} | ||
|
||
source: | ||
url: {{ home }}/archive/{{ version }}.tar.gz | ||
sha256: 60020376af6bf100194ced85ea19534084e858a80a03162e533ad84506900073 | ||
# | ||
# This patch should not be necessary once version advances to 2024.0.1 | ||
patches: | ||
- {{ version }}.patch | ||
|
||
build: | ||
entry_points: | ||
- xrst = xrst:run_xrst | ||
noarch: python | ||
script: {{ PYTHON }} -m pip install . -vv --no-deps --no-build-isolation | ||
number: 0 | ||
|
||
requirements: | ||
host: | ||
- python | ||
- setuptools | ||
- setuptools-scm | ||
- pip | ||
run: | ||
- python >=3.8 | ||
- sphinx | ||
- toml | ||
- sphinx-copybutton | ||
- pytest | ||
- pyspellchecker | ||
- furo | ||
- sphinx_rtd_theme | ||
- sphinx-book-theme | ||
|
||
test: | ||
source_files: | ||
- pytest/test_rst.py | ||
imports: | ||
- xrst | ||
commands: | ||
# pip check | ||
# Cannot use pip to check install becasue it has a pyenchant requirement. | ||
# This should be fixed once version advances to 2024.0.1. | ||
# | ||
- xrst --version | ||
requires: | ||
- pip | ||
|
||
about: | ||
home: {{ home }} | ||
summary: Extract RST files from source code and run Sphinx | ||
license: GPL-3.0-or-later | ||
license_file: gpl-3.0.txt | ||
doc_url: https://xrst.readthedocs.io | ||
|
||
extra: | ||
recipe-maintainers: | ||
- bradbell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
rem | ||
rem name, version | ||
set name=%PKG_NAME% | ||
set version=%PKG_VERSION% | ||
rem | ||
rem url | ||
set home="https://github.com/bradbell/%name%" | ||
set url="%home%/archive/%version%.tar.gz" | ||
rem | ||
rem xrst-%version%.tar.gz | ||
curl -LJO %url% | ||
rem | ||
rem xrst-%version% | ||
rem we get a copy of the original source because it has an automated test. | ||
tar -xzf xrst-%version%.tar.gz | ||
cd xrst-%version% | ||
rem | ||
rem xrst-%version%\pytest\test_rst.py | ||
rem It is hard to use PREFIX here becasue dos uses \ for directory separator. | ||
rem Using xrst.exe (instead of xrst) ensures we are running installed version | ||
rem and not the version in this source. | ||
sed -e "s|'python3' *,.*|'xrst.exe', '--suppress_spell_warnings', |" ^ | ||
..\pytest\test_rst.py > pytest\test_rst.py | ||
rem | ||
rem xrst-%version%\xrst.toml | ||
sed -i -e "s|pyenchant|pyspellchecker|" xrst.toml | ||
rem | ||
rem pytest | ||
pytest -s pytest | ||
IF %ERRORLEVEL% NEQ 0 ( | ||
CD .. | ||
ECHO run_test.bat Error | ||
exit /B 1 | ||
) | ||
CD .. | ||
ECHO run_test.bat: OK | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#! /usr/bin/env bash | ||
set -e -u | ||
# | ||
# prefix, name, version | ||
prefix=$PREFIX | ||
name=$PKG_NAME | ||
version=$PKG_VERSION | ||
# | ||
# url | ||
home="https://github.com/bradbell/$name" | ||
url="$home/archive/$version.tar.gz" | ||
# | ||
# xrst-$version.tar.gz | ||
curl -LJO $url | ||
# | ||
# xrst-$version | ||
# We get a copy of the original source becasue it has an automated test. | ||
tar -xzf xrst-$version.tar.gz | ||
cd xrst-$version | ||
# | ||
# xrst-$version/pytest/test_rst.py | ||
# Use prefix here ensures we are running the installed version and not | ||
# the version in this source. | ||
sed -i \ | ||
-e "s|'python3' *,.*|'$prefix/bin/xrst', '--suppress_spell_warnings', |" \ | ||
pytest/test_rst.py | ||
# | ||
# xrst-$version/xrst.toml | ||
sed -i -e 's|pyenchant|pyspellchecker|' xrst.toml | ||
# | ||
# pytest | ||
pytest -s pytest | ||
# | ||
echo 'run_test.sh: OK' | ||
exit 0 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since deps are specified in the
meta.yaml
it's not necessary to patch them in thesetup.py
... unless it's to enablepip check
to work.