Skip to content
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
8 changes: 2 additions & 6 deletions .ci/release-uv
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ from subprocess import check_call

is_ci = os.environ.get('CI') is not None


def main() -> None:
p = argparse.ArgumentParser()
p.add_argument('--use-test-pypi', action='store_true')
Expand All @@ -34,19 +35,14 @@ def main() -> None:
publish_url = ['--publish-url', 'https://test.pypi.org/legacy/'] if args.use_test_pypi else []

root = Path(__file__).absolute().parent.parent
os.chdir(root) # just in case

if is_ci:
# see https://github.com/actions/checkout/issues/217
check_call('git fetch --prune --unshallow'.split())
os.chdir(root) # just in case

# TODO ok, for now uv won't remove dist dir if it already exists
# https://github.com/astral-sh/uv/issues/10293
dist = root / 'dist'
if dist.exists():
shutil.rmtree(dist)

# todo what is --force-pep517?
check_call(['uv', 'build'])

if not is_ci:
Expand Down
54 changes: 35 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ on:
branches: '*'
tags: 'v[0-9]+.*' # only trigger on 'release' tags for PyPi
# Ideally I would put this in the pypi job... but github syntax doesn't allow for regexes there :shrug:
pull_request: # needed to trigger on others' PRs

# Needed to trigger on others' PRs.
# Note that people who fork it need to go to "Actions" tab on their fork and click "I understand my workflows, go ahead and enable them".
workflow_dispatch: # needed to trigger workflows manually
# todo cron?
pull_request:

# Needed to trigger workflows manually.
workflow_dispatch:
inputs:
debug_enabled:
type: boolean
Expand All @@ -24,7 +27,7 @@ jobs:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
# vvv just an example of excluding stuff from matrix
# exclude: [{platform: macos-latest, python-version: '3.6'}]

Expand All @@ -37,16 +40,16 @@ jobs:
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0 # nicer to have all git history when debugging/for tests

- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}

- uses: astral-sh/setup-uv@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: false # we don't have lock files, so can't use them as cache key

Expand All @@ -55,44 +58,57 @@ jobs:

# explicit bash command is necessary for Windows CI runner, otherwise it thinks it's cmd...
- run: bash .ci/run
env:
# only compute lxml coverage on ubuntu; it crashes on windows
CI_MYPY_COVERAGE: ${{ matrix.platform == 'ubuntu-latest' && '--cobertura-xml-report .coverage.mypy' || '' }}

- if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms
uses: actions/upload-artifact@v4
uses: codecov/codecov-action@v5
with:
include-hidden-files: true
name: .coverage.mypy_${{ matrix.platform }}_${{ matrix.python-version }}
path: .coverage.mypy/
fail_ci_if_error: true # default false
token: ${{ secrets.CODECOV_TOKEN }}
flags: mypy-${{ matrix.python-version }}
files: .coverage.mypy/cobertura.xml


pypi:
runs-on: ubuntu-latest
# Do not run it for PRs/cron schedule etc.
# NOTE: release tags are guarded by on: push: tags on the top.
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags/') || (github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch)))
# Ugh, I tried using matrix or something to explicitly generate only test pypi or prod pypi pipelines.
# But github actions is so shit, it's impossible to do any logic at all, e.g. doesn't support conditional matrix, if/else statements for variables etc.

needs: [build] # add all other jobs here

runs-on: ubuntu-latest

permissions:
# necessary for Trusted Publishing
id-token: write

steps:
# ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation
- run: echo "$HOME/.local/bin" >> $GITHUB_PATH

- uses: actions/checkout@v4
- uses: actions/checkout@v5
with:
submodules: recursive
fetch-depth: 0 # pull all commits to correctly infer vcs version

- uses: actions/setup-python@v5
- uses: actions/setup-python@v6
with:
python-version: '3.10'

- uses: astral-sh/setup-uv@v5
- uses: astral-sh/setup-uv@v7
with:
enable-cache: false # we don't have lock files, so can't use them as cache key

- name: 'release to test pypi'
# always deploy merged master to test pypi
if: github.event_name != 'pull_request' && github.event.ref == 'refs/heads/master'
if: github.event.ref == format('refs/heads/{0}', github.event.repository.master_branch)
run: .ci/release-uv --use-test-pypi

- name: 'release to pypi'
- name: 'release to prod pypi'
# always deploy tags to release pypi
# NOTE: release tags are guarded by on: push: tags on the top
if: github.event_name != 'pull_request' && startsWith(github.event.ref, 'refs/tags')
if: startsWith(github.event.ref, 'refs/tags/')
run: .ci/release-uv
10 changes: 10 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,13 @@ True
'some text'
>>> node.body
' Body texts...'


Project status
--------------

Project is maintained by @karlicoss (myself).

For my personal use, orgparse mostly has all features I need, so there hasn't been much active development lately.

However, contributions are always welcome! Please provide tests along with your contribution if you're fixing bugs or adding new functionality.
15 changes: 13 additions & 2 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
# resolve_package_path is called from _pytest.pathlib.import_path
# takes a full abs path to the test file and needs to return the path to the 'root' package on the filesystem
resolve_pkg_path_orig = _pytest.pathlib.resolve_package_path


def resolve_package_path(path: pathlib.Path) -> Optional[pathlib.Path]:
result = path # search from the test file upwards
for parent in result.parents:
Expand All @@ -30,18 +32,27 @@ def resolve_package_path(path: pathlib.Path) -> Optional[pathlib.Path]:
if path.name == 'conftest.py':
return resolve_pkg_path_orig(path)
raise RuntimeError("Couldn't determine path for ", path)
_pytest.pathlib.resolve_package_path = resolve_package_path


# NOTE: seems like it's not necessary anymore?
# keeping it for now just in case
# after https://github.com/pytest-dev/pytest/pull/13426 we should be able to remove the whole conftest
# _pytest.pathlib.resolve_package_path = resolve_package_path


# without patching, the orig function returns just a package name for some reason
# (I think it's used as a sort of fallback)
# so we need to point it at the absolute path properly
# not sure what are the consequences.. maybe it wouldn't be able to run against installed packages? not sure..
search_pypath_orig = _pytest.main.search_pypath


def search_pypath(module_name: str) -> str:
mpath = root_dir / module_name.replace('.', os.sep)
if not mpath.is_dir():
mpath = mpath.with_suffix('.py')
assert mpath.exists(), mpath # just in case
return str(mpath)
_pytest.main.search_pypath = search_pypath


_pytest.main.search_pypath = search_pypath # ty: ignore[invalid-assignment]
51 changes: 26 additions & 25 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-

from os.path import dirname
import sys
sys.path.insert(0, dirname(dirname(dirname(__file__))))
from pathlib import Path

sys.path.insert(0, str(Path(__file__).parent.parent.parent))

# -- General configuration ------------------------------------------------
extensions = [
Expand All @@ -19,14 +18,14 @@
import orgparse

# General information about the project.
project = u'orgparse'
copyright = u'2012, Takafumi Arakaki'
project = 'orgparse'
copyright = '2012, Takafumi Arakaki' # noqa: A001

# The short X.Y version.
# TODO use setup.py for version
version = orgparse.__version__
version = orgparse.__version__ # ty: ignore[unresolved-attribute]
# The full version, including alpha/beta/rc tags.
release = orgparse.__version__
release = orgparse.__version__ # ty: ignore[unresolved-attribute]

exclude_patterns = []

Expand All @@ -43,45 +42,47 @@

# -- Options for LaTeX output ---------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#'preamble': '',
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto/manual]).
latex_documents = [
('index', 'orgparse.tex', u'orgparse Documentation',
u'Takafumi Arakaki', 'manual'),
('index', 'orgparse.tex', 'orgparse Documentation', 'Takafumi Arakaki', 'manual'),
]


# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'orgparse', u'orgparse Documentation',
[u'Takafumi Arakaki'], 1)
('index', 'orgparse', 'orgparse Documentation', ['Takafumi Arakaki'], 1),
]

# If true, show URL addresses after external links.
#man_show_urls = False
# man_show_urls = False


# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'orgparse', u'orgparse Documentation',
u'Takafumi Arakaki', 'orgparse', 'One line description of project.',
'Miscellaneous'),
(
'index',
'orgparse',
'orgparse Documentation',
'Takafumi Arakaki',
'orgparse',
'One line description of project.',
'Miscellaneous',
),
]


Expand All @@ -93,4 +94,4 @@
autodoc_member_order = 'bysource'
autodoc_default_flags = ['members']

inheritance_graph_attrs = dict(rankdir="TB")
inheritance_graph_attrs = {'rankdir': "TB"}
10 changes: 2 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,11 @@ testing = [
"pytest",
"ruff",
"mypy",
"lxml", # for mypy html coverage
"lxml", # for mypy html coverage
"ty>=0.0.1a25",
]



# workaround for error during uv publishing
# see https://github.com/astral-sh/uv/issues/9513#issuecomment-2519527822
[tool.setuptools]
license-files = []


[build-system]
requires = ["hatchling", "hatch-vcs"]
build-backend = "hatchling.build"
Expand Down
Loading