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

2.0.5 release #694

Merged
merged 27 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
28ba83f
Fix Changelog entry to link to #665, not #655.
tartley May 22, 2023
cdde901
Merge pull request #678 from tartley/fix-changelog
ecederstrand May 22, 2023
39dd2ec
[doc] Add example for Piping to STDIN migration
honnix Jun 5, 2023
6145cbb
Merge pull request #679 from honnix/patch-1
amoffat Jun 23, 2023
8fb5a92
Use f-strings
eumiro Jun 29, 2023
baebe57
fix f-strings
eumiro Jul 10, 2023
4941fe0
Merge pull request #686 from eumiro/fstrings
ecederstrand Jul 12, 2023
c24b7f0
Fix nested contexts duplicating commands
johntrimble Jul 29, 2023
8512ec8
Merge pull request #691 from johntrimble/690-fix-nested-contexts
amoffat Aug 7, 2023
043ed5d
fix dockerfile tests
amoffat Aug 7, 2023
631a949
changelog update
amoffat Aug 7, 2023
c815027
first pass read the docs
amoffat Aug 7, 2023
27209dd
update docs
amoffat Aug 7, 2023
1f09994
use a portable echo
amoffat Aug 7, 2023
c2db2f6
bugfix when running dockerfile tests, fixes #670
amoffat Aug 7, 2023
0365c28
make timing of test less fiddly closes #684
amoffat Aug 7, 2023
89333ae
cleanup includes
amoffat Aug 7, 2023
5f9f2ac
make tests friendlier to pytest
amoffat Aug 7, 2023
60445c7
call correct asyncio loop function, closes #683
amoffat Aug 7, 2023
31a6ff4
async docs
amoffat Aug 7, 2023
0e82a7d
cleanup unsupported version
amoffat Aug 7, 2023
5b23807
Merge branch 'rtd' into develop
amoffat Aug 7, 2023
823ecd5
Merge branch 'master' into develop
amoffat Aug 7, 2023
09caaf8
rtd config
amoffat Aug 7, 2023
1062b9f
update docs links
amoffat Aug 7, 2023
09c4ed9
version 2.0.5
amoffat Aug 7, 2023
e117fd8
fix coverage
amoffat Aug 7, 2023
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
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:

- name: Run tests
run: |
SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run -a -m unittest
SH_TESTS_RUNNING=1 SH_TESTS_USE_SELECT=${{ matrix.use-select }} LANG=${{ matrix.lang }} poetry run coverage run -a -m pytest

- name: Store coverage
uses: actions/upload-artifact@v2
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ __pycache__/
/.venv/
/build
/dist
/docs/build
/TODO.md
/htmlcov/
29 changes: 29 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.10"
jobs:
post_create_environment:
- pip install poetry
- poetry config virtualenvs.create false
post_install:
- poetry install
- pip install -e .

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/source/conf.py
# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
29 changes: 29 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Doc builder",
"type": "shell",
"command": "source ${workspaceFolder}/.venv/bin/activate && find source/ | entr -s 'make clean && make html'",
"options": {
"cwd": "${workspaceFolder}/docs"
},
"problemMatcher": [],
"group": {
"kind": "build"
},
"isBackground": true,
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "dedicated",
"showReuseMessage": false,
"clear": true,
"close": true
}
}
]
}
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
# Changelog

## 2.0.5 - 8/7/23

- Allow nested `with` contexts [#690](https://github.com/amoffat/sh/issues/690)
- Call correct asyncio function for getting event loop [#683](https://github.com/amoffat/sh/issues/683)

## 2.0.4 - 5/13/22

- Allow `ok_code` to be used with `fg` [#655](https://github.com/amoffat/sh/pull/655)
- Allow `ok_code` to be used with `fg` [#665](https://github.com/amoffat/sh/pull/665)
- Make sure `new_group` never creates a new session [#675](https://github.com/amoffat/sh/pull/675)

## 2.0.2 / 2.0.3 (misversioned) - 2/13/22
Expand Down
22 changes: 22 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,28 @@ Previously, if the first argument of a sh command was an instance of `RunningCom
it was automatically fed into the process's STDIN. This is no longer the case and you
must explicitly use `_in=`.

```python
from sh import wc,ls

print(wc(ls("/home/<user>", "-l"), "-l"))
```

Becomes:

```python
from sh import wc,ls

print(wc("-l", _in=ls("/home/<user>", "-l")))
```

Or:

```python
from sh import wc,ls

print(wc("-l", _in=ls("/home/<user>", "-l", _return_cmd=True)))
```

### Workaround

None
Expand Down
14 changes: 3 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@
.. image:: https://img.shields.io/pypi/pyversions/sh.svg?style=flat-square
:target: https://pypi.python.org/pypi/sh
:alt: Python Versions
.. image:: https://img.shields.io/travis/amoffat/sh/master.svg?style=flat-square
:target: https://travis-ci.org/amoffat/sh
:alt: Build Status
.. image:: https://img.shields.io/coveralls/amoffat/sh.svg?style=flat-square
:target: https://coveralls.io/r/amoffat/sh?branch=master
:alt: Coverage Status

|

sh is a full-fledged subprocess replacement for Python 3.8 - 3.10, PyPy and PyPy3
sh is a full-fledged subprocess replacement for Python 3.8 - 3.11, and PyPy
that allows you to call *any* program as if it were a function:

.. code:: python
Expand All @@ -37,7 +34,7 @@ sh is *not* a collection of system commands implemented in Python.
sh relies on various Unix system calls and only works on Unix-like operating
systems - Linux, macOS, BSDs etc. Specifically, Windows is not supported.

`Complete documentation here <https://amoffat.github.io/sh>`_
`Complete documentation here <https://sh.readthedocs.io/>`_

Installation
============
Expand All @@ -55,11 +52,6 @@ Support
Developers
==========

Updating the docs
-----------------

Check out the `gh-pages <https://github.com/amoffat/sh/tree/gh-pages>`_ branch and follow the ``README.rst`` there.

Testing
-------

Expand All @@ -76,7 +68,7 @@ Coverage

First run all of the tests::

$> SH_TESTS_RUNNING=1 coverage run --source=sh -m unittest
$> SH_TESTS_RUNNING=1 coverage run --source=sh -m pytest

This will aggregate a ``.coverage``. You may then visualize the report with::

Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?= -a -W
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
toml==0.10.2
62 changes: 62 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Configuration file for the Sphinx documentation builder.

from pathlib import Path

import toml

_THIS_DIR = Path(__file__).parent
_REPO = _THIS_DIR.parent.parent
_PYPROJECT = _REPO / "pyproject.toml"

pyproject = toml.load(_PYPROJECT)
nitpicky = True

nitpick_ignore = [
("py:class", "Token"),
("py:class", "'Token'"),
]

nitpick_ignore_regex = [
("py:class", r".*lark.*"),
]

version = pyproject["tool"]["poetry"]["version"]
release = version

# -- Project information

project = "sh"
copyright = "2023, Andrew Moffat"
author = "Andrew Moffat"

# -- General configuration

extensions = [
"sphinx.ext.duration",
"sphinx.ext.doctest",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
]

intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"sphinx": ("https://www.sphinx-doc.org/en/master/", None),
"lark": ("https://lark-parser.readthedocs.io/en/latest/", None),
"jinja2": ("https://jinja.palletsprojects.com/en/latest/", None),
}
intersphinx_disabled_domains = ["std"]

templates_path = ["_templates"]

# -- Options for HTML output

html_theme = "sphinx_rtd_theme"

# -- Options for EPUB output
epub_show_urls = "footnote"

autodoc_typehints = "both"

add_module_names = False
24 changes: 24 additions & 0 deletions docs/source/examples/done.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Here's an example of using :ref:`done` to create a multiprocess pool, where
``sh.your_parallel_command`` is executed concurrently at no more than 10 at a
time:

.. code-block:: python

import sh
from threading import Semaphore

pool = Semaphore(10)

def done(cmd, success, exit_code):
pool.release()

def do_thing(arg):
pool.acquire()
return sh.your_parallel_command(arg, _bg=True, _done=done)

procs = []
for arg in range(100):
procs.append(do_thing(arg))

# essentially a join
[p.wait() for p in procs]
Binary file added docs/source/images/logo-230.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading