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
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PYTHONPATH=$PYTHONPATH:pype:example_pypes
PYTHONPATH=$PYTHONPATH:pype
PYPE_CONFIG_FOLDER=.venv/.pype-cli
20 changes: 17 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,26 @@ on:
jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
# https://www.python.org/downloads/
python-version: [
"3.9", # EOL: 2025-10
"3.10", # EOL: 2026-10
"3.11", # EOL: 2027-10
"3.12", # EOL: 2028-10
"3.13", # EOL: 2029-10
]
name: ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v1

- name: Setup python
uses: actions/setup-python@v3
with:
python-version: "${{ matrix.python-version }}"

- name: CI checks
run: |
python3 -m pip install pipenv
python -m pip install pipenv
make
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- name: Release
run: |
python3 -m pip install pipenv
python -m pip install pipenv
TWINE_USERNAME="${{ secrets.TWINE_USERNAME }}" \
TWINE_PASSWORD="${{ secrets.TWINE_PASSWORD }}" \
make publish
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"python.pythonPath": ".venv/bin/python",
"python.analysis.extraPaths": [
"pypes",
"example_pypes",
".venv/bin/python"
],
// PEP8 settings (https://www.python.org/dev/peps/pep-0008/)
Expand All @@ -29,5 +28,6 @@
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestArgs": []
"python.testing.pytestArgs": [],
"makefile.configureOnOpen": false
}
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.8.0

- Removed assumptions about `python` versus `python3` installation. This simplifies the code and gives full control into the user's hand to determine the correct `python` through the path or tools such as `pyenv`
- Upgraded to Python 3.9..3.12
- Using the minimal template for new pypes, e.g., `pype myplugin --create-pype my-pype --minimal` now creates a pype that can be executed independent from `pype-cli`, i.e., no built-in libraries are used
- `pype pype.config shell-install` produces more robust completion scripts
- Removal of all example pypes as they were outdated and misleading

## 0.7.0

- Rename PypeException to PypeError
Expand Down
40 changes: 24 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Required executables
ifeq (, $(shell which python3))
$(error "No python3 on PATH.")
ifeq (, $(shell which python))
$(error "No python on PATH.")
endif
ifeq (, $(shell which pipenv))
$(error "No pipenv on PATH.")
PIPENV_CMD := python -m pipenv
PIP_CMD := python -m pip
ifeq (, $(shell $(PIPENV_CMD) --version))
$(error "No $(PIPENV_CMD) on PATH.")
endif

# Suppress warning if pipenv is started inside .venv
Expand All @@ -20,23 +22,23 @@ export PYPE_CONFIG_FOLDER = $(shell pwd)/.venv/.pype-cli
# Process variables
LAST_VERSION := $(shell git tag | sort --version-sort -r | head -n1)
VERSION_HASH := $(shell git show-ref -s $(LAST_VERSION))
PY_FILES := setup.py pype tests example_pypes
PY_FILES := setup.py pype tests

all: prepare build

prepare: clean
@echo Preparing virtual environment
pipenv install --dev
$(PIPENV_CMD) install --dev
mkdir -p $(PYPE_CONFIG_FOLDER)
echo "export PYPE_CONFIG_FOLDER=$(PYPE_CONFIG_FOLDER)" >> .venv/bin/activate

build: test mypy isort lint
@echo Run setup.py-based build process to package application
pipenv run python setup.py bdist_wheel
$(PIPENV_CMD) run python setup.py bdist_wheel

shell:
@echo Initialize virtualenv and open a new shell using it
pipenv shell
$(PIPENV_CMD) shell

clean:
@echo Clean project base
Expand All @@ -59,36 +61,42 @@ clean:

test:
@echo Run all tests in default virtualenv
pipenv run py.test --verbose tests
$(PIPENV_CMD) run py.test --verbose tests

isort:
@echo Check for incorrectly sorted imports
pipenv run isort --check-only $(PY_FILES)
$(PIPENV_CMD) run isort --check-only $(PY_FILES)

isort-apply:
@echo Check for incorrectly sorted imports
pipenv run isort $(PY_FILES)
$(PIPENV_CMD) run isort $(PY_FILES)

lint:
@echo Run code formatting checks against source code base
pipenv run flake8 $(PY_FILES)
$(PIPENV_CMD) run flake8 $(PY_FILES)

mypy:
@echo Run static code checks against source code base
pipenv run mypy pype example_pypes tests
$(PIPENV_CMD) run mypy pype tests

sys-info:
@echo Print pype configuration within venv
pipenv run pype pype.config system-info
$(PIPENV_CMD) run pype pype.config system-info

install-wheel: all
@echo Install from wheel
pip3 install --force-reinstall dist/*.whl
$(PIP_CMD) install --force-reinstall dist/*.whl

install-wheel-no-test:
@echo Install from wheel including rebuild but skipping tests
rm -rf dist/*.whl
$(PIPENV_CMD) run python setup.py bdist_wheel
$(PIP_CMD) install --force-reinstall dist/*.whl

publish: all
@echo Publish pype to pypi.org
TWINE_USERNAME=$(TWINE_USERNAME) TWINE_PASSWORD=$(TWINE_PASSWORD) \
pipenv run twine upload dist/*
$(PIPENV_CMD) run twine upload dist/*

release:
@echo Commit release - requires NEXT_VERSION to be set
Expand Down
47 changes: 24 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
# pype-cli

> A command-line tool for command-line tools
<img align="right" src="res/icon.png" alt="pype-cli Logo" width="150" height="150">
> A command-line tool for command-line tools ![pype-cli Logo](res/icon.png)

![GitHub Workflow Status](https://img.shields.io/github/workflow/status/BastiTee/pype-cli/CI)
![PyPU - Version](https://img.shields.io/pypi/v/pype-cli.svg)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pype-cli.svg)
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/BastiTee/pype-cli/CI) ![PyPU - Version](https://img.shields.io/pypi/v/pype-cli.svg) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pype-cli.svg)

## In a nutshell

__pype-cli__ is a command-line tool to manage sets of other command-line tools. It simplifies the creation, orchestration and access of Python scripts that you require for your development work, process automation, etc.
**pype-cli** is a command-line tool to manage sets of other command-line tools. It simplifies the creation, orchestration and access of Python scripts that you require for your development work, process automation, etc.

<img src="res/pype-cli.gif" alt="pype-cli GIF" width="550">
![pype-cli GIF](res/pype-cli.gif)

## Quickstart

- Install **pype-cli** via `pip3 install --user pype-cli`. This will install the command `pype` for the current user
- To use an alternative name you need to install from source via `PYPE_CUSTOM_SHELL_COMMAND=my_cmd_name python3 setup.py install --user`
- Install **pype-cli** via `python -m pip install --user pype-cli`. This will install the command `pype` for the current user
- To use an alternative name you need to install from source via `PYPE_CUSTOM_SHELL_COMMAND=my_cmd_name python setup.py install --user`
- Run `pype pype.config shell-install` and open a new shell to activate shell completion
- Create a new **plugin** in your home folder: `pype pype.config plugin-register --create --name my-plugin --path ~/`
- Create a sample **pype** for your plugin: `pype my-plugin --create-pype my-pype`
Expand Down Expand Up @@ -86,7 +83,23 @@ If you have selected a **pype** from a **plugin** you can set **aliases** for it

### Global logging configuration

**pype-cli** contains a built-in logger setup. To configure it use the **pype** `pype pype.config logger`. In your **pypes** you can use it right away [like in the provided example](example_pypes/basics/logger.py).
**pype-cli** contains a built-in file logger setup. To configure it use the **pype** `pype pype.config logger`. In your **pypes** you can use it right away like this:

```python
import logging
import click

@click.command(name='my-pype', help=__doc__)
def main() -> None:
# Name your logger. Note that this can be omitted but you will end up
# with the default 'root' logger.
logger = logging.getLogger(__name__)

# Log something to the global log file. Note that the output to the file
# depends on the logging configuration mentioned above.
logger.debug('Debug message')
logger.info('Info message')
```

- Enable/disable global logging: `pype pype.config logger enable/disable`
- Print current configuration: `pype pype.config logger print-config`
Expand All @@ -98,21 +111,9 @@ If you have selected a **pype** from a **plugin** you can set **aliases** for it

If your **plugin** contains shared code over all **pypes** you can simply put it into a subpackage of your **plugin** or into a file prefixed with `__`, e.g., `__commons__.py`. **pype-cli** will only scan / consider top-level Python scripts without underscores as **pypes**.

### Example recipes

You can register a sample **plugin** called [**basics**](example_pypes/basics) that contains some useful recipes to get you started with your own pipes.

- Register the [**basics**](example_pypes/basics) **plugin**: `pype pype.config plugin-register --name basics --path <PYPE_REPOSITORY>/example_pypes`
- Navigate to `pype basics <TAB>` to see its content
- Open a recipe in your edior, for example: `pype basics --open-pype hello-world-opt`

For some basic information you can also refer to the built-in [template.py](pype/template.py) and [template_minimal.py](pype/template_minimal.py) that are used on creation of new **pypes**.

Note that as long as you don't import some of the [convenience utilities](pype/__init__.py) of **pype-cli** directly, your **pype** will remain [an independent Python script](example_pypes/basics/non_pype_script.py) that can be used regardless of **pype_cli**.

### Best practises

**pype-cli** has been built around the [Click-project ("Command Line Interface Creation Kit")](https://click.palletsprojects.com/) which is a Python package for creating beautiful command line interfaces. To fully utilize the capabilities of **pype-cli** it is highly recommended to get familiar with the project and use it in your **pypes** as well. Again you can refer to the [**basics**](example_pypes/basics) plugin for guidance.
**pype-cli** has been built around the [Click-project ("Command Line Interface Creation Kit")](https://click.palletsprojects.com/) which is a Python package for creating beautiful command line interfaces. To fully utilize the capabilities of **pype-cli** it is highly recommended to get familiar with the project and use it in your **pypes** as well.

## pype-cli development

Expand Down
2 changes: 0 additions & 2 deletions example_pypes/basics/__init__.py

This file was deleted.

16 changes: 0 additions & 16 deletions example_pypes/basics/hello_world.py

This file was deleted.

19 changes: 0 additions & 19 deletions example_pypes/basics/hello_world_opt.py

This file was deleted.

25 changes: 0 additions & 25 deletions example_pypes/basics/logger.py

This file was deleted.

79 changes: 0 additions & 79 deletions example_pypes/basics/multi_command.py

This file was deleted.

Loading
Loading