Skip to content

Commit

Permalink
Merge branch 'release/0.3.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
AndydeCleyre committed Dec 12, 2024
2 parents c5b5a28 + f2db1e6 commit 0c86e52
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 26 deletions.
14 changes: 14 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
News
====

0.3.12
======

Changed
-------

- Use reverse-list layout for fzf/skim instead of reverse
- pypc: don't add '.' to any dependency list
- Add optional syntax highlighter backend: gat
- Ensure to use ``python3`` instead of ``python`` for out-of-venv internal uses
- Add mise auto-venv-activation instructions to docs
- Update demo container base for Alpine
- Install uv completion (which becomes part of zpy completion) in demo containers

0.3.11
======

Expand Down
4 changes: 2 additions & 2 deletions doc/mkdocs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ markupsafe==3.0.2 # via jinja2, mkdocs
mergedeep==1.3.4 # via mkdocs, mkdocs-get-deps
mkdocs==1.6.1 # via -r requirements.in, mkdocs-material
mkdocs-get-deps==0.2.0 # via mkdocs
mkdocs-material==9.5.44 # via -r requirements.in
mkdocs-material==9.5.48 # via -r requirements.in
mkdocs-material-extensions==1.3.1 # via mkdocs-material
packaging==24.2 # via mkdocs
paginate==0.5.7 # via mkdocs-material
Expand All @@ -24,6 +24,6 @@ pyyaml==6.0.2 # via mkdocs, mkdocs-get-deps, pymdown-extensions, pyy
pyyaml-env-tag==0.1 # via mkdocs
regex==2024.11.6 # via mkdocs-material
requests==2.32.3 # via mkdocs-material
six==1.16.0 # via python-dateutil
six==1.17.0 # via python-dateutil
urllib3==2.2.3 # via requests
watchdog==6.0.0 # via mkdocs
18 changes: 9 additions & 9 deletions doc/src/completions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ somewhere before loading zpy:
autoload -Uz compinit && compinit
```

I'll also recommend:

```shell
zstyle ':completion:*' menu select
```

Some functions allow you to pass arguments through to other tools,
like `pip`, `pip-compile`, and `uv`.
Completion will work for those if you install their own completion definitions.

If using `uv`, neither `pip` nor `pip-compile` will be relevant.

`uv` completion can be installed with something like the following,
depending on your `$fpath`:
`uv` completion is installed by creating a `_uv` file
in one of your `$fpath` folders (usually `~/.local/share/zsh/site-functions`):

```console
% uv generate-shell-completion zsh >~/.local/share/zsh/site-functions/_uv
```

You can check for appropriate folders with:

```console
% print -rl -- $fpath
```

Filter to .../username/... paths for the most likely candidates:
You can check for appropriate `$fpath` folders with:

```console
% print -rl -- ${(M)fpath:#*/$USER/*}
Expand Down
5 changes: 3 additions & 2 deletions doc/src/deps.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dependencies

The primary requirements are Zsh, Python, and
[`fzf`](https://github.com/junegunn/fzf) *or* [`sk` (skim)](https://github.com/lotabout/skim),
[`fzf`](https://github.com/junegunn/fzf) *or* [`sk` (skim)](https://github.com/skim-rs/skim),
with optional additions for more colorful output, alternative json parsers, and faster performance.

## Suggested Dependencies by Platform
Expand Down Expand Up @@ -48,13 +48,14 @@ with optional additions for more colorful output, alternative json parsers, and

- [Zsh](https://repology.org/project/zsh/versions)
- [Python](https://repology.org/project/python/versions)
- [`fzf`](https://github.com/junegunn/fzf) *or* [`sk` (skim)](https://github.com/lotabout/skim)
- [`fzf`](https://github.com/junegunn/fzf) *or* [`sk` (skim)](https://github.com/skim-rs/skim)

=== "The optional ones"

- [uv](https://github.com/astral-sh/uv/)
-- for faster performance, leaner venvs, and more operational feedback
- [highlight](https://repology.org/project/highlight/versions)
*or* [gat](https://github.com/koki-develop/gat/)
*or* [bat](https://repology.org/project/bat/versions)
*or* [rich-cli](https://github.com/Textualize/rich-cli)
-- for pretty syntax highlighting; rich-cli adds fancy tables
Expand Down
29 changes: 29 additions & 0 deletions doc/src/direnv.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,35 @@ please open an issue or discussion on GitHub.
This ensures the proper project folder is used,
even if you're activating the script by entering a deeper subdirectory.

=== "mise"

[mise](https://mise.jdx.dev/) supports
[automatic venv activation](https://mise.jdx.dev/lang/python.html#automatic-virtualenv-activation),
so we can configure the venv location to match zpy's.

Let's create a self-contained script for `venvs_path`,
so that we can easily call it from Bash.

Assuming `~/.local/bin` is in your `PATH`, run

```console
$ zpy mkbin venvs_path ~/.local/bin/
```

Now you can add the following to your project's `mise.local.toml`:

```toml
[env._.python]
venv = "{{exec(command='venvs_path')}}/venv"
```

This can also be done with commands:

```console
$ touch mise.local.toml
$ mise config set -f mise.local.toml env._.python.venv "{{exec(command='venvs_path')}}/venv"
```

=== "direnv"

[direnv](https://github.com/direnv/direnv/)
Expand Down
2 changes: 1 addition & 1 deletion doc/src/start.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
## Install locally

Aside from Zsh and Python, the only dependency you're likely to *need* is
[`fzf`](https://github.com/junegunn/fzf) *or* [`sk` (skim)](https://github.com/lotabout/skim).
[`fzf`](https://github.com/junegunn/fzf) *or* [`sk` (skim)](https://github.com/skim-rs/skim).
For more details and recommended package manager commands, see [Dependencies](deps.md).

To install `zpy` itself, you only need to source the file `zpy.plugin.zsh`
Expand Down
3 changes: 2 additions & 1 deletion mk/ctnr/zcomet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ case $distro in
alias ctnr_mkuser="ctnr_run useradd -m -s /bin/zsh"
;;
alpine)
basetag=${2:-3.20}
basetag=${2:-3.21}
pkgs="$pkgs git sudo"
fat="$fat /var/cache/apk/*"
alias ctnr_pkg="ctnr_run apk -q --no-progress"
Expand Down Expand Up @@ -87,6 +87,7 @@ ctnr_run -u git clone -q --depth 1 https://github.com/agkozak/zcomet /home/$user
# Add settings and plugins to .zshrc:
ctnr_run -u rm -f /home/$user/.zshrc
<<EOF ctnr_append -u /home/$user/.zshrc
typeset -U fpath=(~/.local/share/zsh/site-functions \$fpath)
typeset -U path=(~/.local/bin \$path)
precmd () { rehash }
zstyle ':completion:*:*:*:*:*' menu select
Expand Down
5 changes: 4 additions & 1 deletion mk/ctnr/zpy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ fi
printf 'zpy_branch: %s\n' "$zpy_branch"
printf 'zpy_version: %s\n' "$zpy_version"

# Install uv, rich-cli
ctnr_run -u zsh -ic 'pipz install --cmd uv uv; pipz install --cmd rich rich-cli'
ctnr_run -u mkdir -p /home/${user}/.local/share/zsh/site-functions
# shellcheck disable=SC2088
ctnr_run -u sh -c '~/.local/bin/uv generate-shell-completion zsh >~/.local/share/zsh/site-functions/_uv'

# Install standalone vpy script, for simpler shebangs
ctnr_run -u mkdir -p /home/${user}/.local/bin
ctnr_run -u zsh -ic 'zpy mkbin vpy ~/.local/bin/vpy'

# Set aliases
Expand Down
25 changes: 15 additions & 10 deletions zpy.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ ZPY_PROCS=${${$(nproc 2>/dev/null):-$(sysctl -n hw.logicalcpu 2>/dev/null)}:-4}
# the first of the next. This is true of at least highlight 3.58.

# The method below bypasses both issues consistently
# across all known versions of highlight, and still outperforms bat:
# across all known versions of highlight, and still outperforms the rest:
local content=$(<&0)
if [[ $content ]] {
local themes=(aiseered blacknblue bluegreen ekvoli navy)
HIGHLIGHT_OPTIONS=${HIGHLIGHT_OPTIONS:-"-s $themes[RANDOM % $#themes + 1]"} \
highlight -O truecolor --stdout --force -S $1 <<<$content
}
} elif (( $+commands[gat] )) { # recommended themes: base16-snazzy, doom-one, gruvbox, onedark, vulcan
GAT_THEME=${GAT_THEME:-doom-one} \
gat --force-color -l $1
} elif (( $+commands[bat] )) { # recommended themes: ansi, zenburn
BAT_THEME=${BAT_THEME:-ansi} \
bat --color always --paging never -p -l $1
Expand Down Expand Up @@ -299,7 +302,7 @@ ZPY_PROCS=${${$(nproc 2>/dev/null):-$(sysctl -n hw.logicalcpu 2>/dev/null)}:-4}
.zpy_fzf_cmd || return
local fzf_cmd=$REPLY

local multi fzf_args=(--reverse -0 --preview='<{}/*.in')
local multi fzf_args=(--layout=reverse-list -0 --preview='<{}/*.in')
if [[ $1 == --multi ]] {
unset reply
fzf_args+=(-m)
Expand Down Expand Up @@ -1232,17 +1235,19 @@ ZPY_PROCS=${${$(nproc 2>/dev/null):-$(sysctl -n hw.logicalcpu 2>/dev/null)}:-4}

rehash

local blocklist=(setuptools six pip pip-tools wheel)

local cells=()
if (( $+commands[jq] )) {
cells=($(
.zpy_ui_vrun $vrun_args $list_outdated 2>/dev/null \
| jq -r '.[] | select(.name|test("^(setuptools|six|pip|pip-tools|wheel)$")|not) | .name,.version,.latest_version'
| jq -r '.[] | select(.name|test("^('${(j:|:)blocklist}')$")|not) | .name,.version,.latest_version'
))
} elif (( $+commands[wheezy.template] )) {
local template=(
'@require(__args__)'
'@for pkg in __args__[0]:'
'@if pkg["name"] not in ("setuptools", "six", "pip", "pip-tools", "wheel"):'
'@if pkg["name"] not in ("'${(j:", ":)blocklist}'"):'
'@pkg["name"]'
'@pkg["version"]'
'@pkg["latest_version"]'
Expand All @@ -1261,7 +1266,7 @@ import sys
from json import load
pkgs = load(sys.stdin)
for pkg in pkgs:
if pkg["name"] not in ("setuptools", "six", "pip", "pip-tools", "wheel"):
if pkg["name"] not in ("'${(j:", ":)blocklist}'"):
print(pkg["name"], pkg["version"], pkg["latest_version"], sep="\n")
'
))
Expand Down Expand Up @@ -1435,7 +1440,7 @@ def reqs_from_reqsin(reqsin):
reqs.append(
re.search(r'^(-\S+\s+)*([^#]+)', line).group(2).rstrip()
)
return sorted(set(r for r in reqs if r.strip()))
return sorted(set(r for r in reqs if r.strip() and r not in ('.',)))


suffix = 'requirements.in'
Expand Down Expand Up @@ -1520,7 +1525,7 @@ Path('''${newtoml}''').write_text(tomlkit.dumps(toml_data))
jq --argjson val "$value" "${keypath}=\$val" "$jsonfile"
)" >$jsonfile
} else {
python -c "
python3 -c "
from collections import defaultdict
from json import loads, dumps
from pathlib import Path
Expand Down Expand Up @@ -1830,7 +1835,7 @@ for pkg in pkgs:
local fzf_cmd=$REPLY

local fzf_args=() fzf_header fzf_prompt multi
fzf_args=(--reverse -0)
fzf_args=(--layout=reverse-list -0)
fzf_header='Packages:'
fzf_prompt='Which package? '
while [[ $1 == --(header|multi) ]] {
Expand Down Expand Up @@ -1908,7 +1913,7 @@ for pkg in pkgs:
projects_home=$1; shift
bins_home=$1; shift

local bins_showlist=() bins_hidelist=() linkonly=1 fzf_args=(--reverse -m -0) fzf_header=Installing
local bins_showlist=() bins_hidelist=() linkonly=1 fzf_args=(--layout=reverse-list -m -0) fzf_header=Installing
while [[ $1 == --(cmd|activate|no-cmd|auto1|header) ]] {
if [[ $1 == --cmd ]] { bins_showlist=(${(s:,:)2}); shift 2 }
if [[ $1 == --no-cmd ]] { bins_hidelist=(${(s:,:)2}); shift 2 }
Expand Down Expand Up @@ -2949,7 +2954,7 @@ _.zpy_ui_pipz () {
)
wheezy.template =(<<<${(F)template}) $json >$txt
} else {
python -c "
python3 -c "
from pathlib import Path
from json import loads

Expand Down

0 comments on commit 0c86e52

Please sign in to comment.