Skip to content
Closed
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
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
push:
branches:
- master
tags:
- '*'

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/tabulate-slip39
permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
- name: Build
run: |
python -m pip install --upgrade pip
python -m pip install setuptools build
python -m build -s
- name: Publish package distributions to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 3 additions & 3 deletions HOWTOPUBLISH
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# update contributors and CHANGELOG in README
python -m pip install pre-commit
python -m pre_commit run -a # and then commit changes
tox -e py39-extra,py310-extra,py311-extra,py312-extra,py313-extra
# tag version release
python -m build -s # this will update tabulate/version.py
python -m pip install . # install tabulate in the current venv
python -m pip install -r benchmark/requirements.txt
python benchmark/benchmark.py # then update README
# move tag to the last commit
# move tag to the last commit: eg.
git tag v0.10.4
python -m build -s # update tabulate/version.py
python -m build -nswx .
git push # wait for all CI builds to succeed
git push --tags # if CI builds succeed
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
twine upload dist/*
114 changes: 114 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# Minimal Makefile for Nix and venv

SHELL := /bin/bash


export PYTHON ?= $(shell python3 --version >/dev/null 2>&1 && echo python3 || echo python )

# Ensure $(PYTHON), $(VENV) are re-evaluated at time of expansion, when target $(PYTHON) are known to be available
PYTHON_V = $(shell $(PYTHON) -c "import sys; print('-'.join((('venv' if sys.prefix != sys.base_prefix else next(iter(filter(None,sys.base_prefix.split('/'))))),sys.platform,sys.implementation.cache_tag)))" 2>/dev/null )

export TOX ?= tox
export TOX_OPTS ?= -e py39-extra,py310-extra,py311-extra,py312-extra,py313-extra
#export TOX_OPTS ?= -e py311-extra,py312-extra,py313-extra
export PYTEST ?= $(PYTHON) -m pytest
export PYTEST_OPTS ?= # -vv --capture=no

VERSION = $(shell $(PYTHON) -c "exec(open('tabulate/version.py').read()); print('.'.join(map(str, __version_tuple__[:3])))" )
VERSION_FULL = $(shell $(PYTHON) -c "exec(open('tabulate/version.py').read()); print(__version__)" )
WHEEL = dist/tabulate_slip39-$(VERSION_FULL)-py3-none-any.whl
VENV = $(CURDIR)-$(VERSION)-$(PYTHON_V)

# Force export of variables that might be set from command line
export VENV_OPTS ?=
export NIX_OPTS ?=

# Put it first so that "make" without argument is like "make help".
help:
@echo "Build and test tabulate under Nix and Python venv"
@echo
@echo " nix-... Make a target in the Nix Flake develop environment"
@echo " venv Create and start a Python venv using the available Python interpreter"
@echo " venv-... Make a target using the venv environment"
@echo
@echo "For example, to build, create venv run tox tests in a Nix-supplied Python:"
@echo
@echo " make nix-build nix-venv-test"
@echo

.PHONY: help wheel build install test bench analyze types venv Makefile FORCE

wheel: $(WHEEL)

$(WHEEL): build FORCE

build:
$(PYTHON) -m build .
@ls -last dist

# Install from wheel, including all optional extra dependencies (doesn't include dev)
install: $(WHEEL) FORCE
$(PYTHON) -m pip install --force-reinstall $<

# Install from requirements/*; eg. install-dev, always getting the latest version
install-%: FORCE
$(PYTHON) -m pip install --upgrade -r requirements/$*.txt


unit-%:
$(PYTEST) $(PYTEST_OPTS) -k $*

test:
$(TOX) $(TOX_OPTS)

lint:
python -m pre_commit run -a

bench:
$(PYTHON) benchmark/benchmark.py

analyze:
$(PYTHON) -m flake8 --color never -j 1 --max-line-length=250 \
--ignore=W503,W504,E201,E202,E223,E226 \
tabulate

types:
mypy .

#
# Nix and VirtualEnv build, install and activate
#
# Create, start and run commands in "interactive" shell with a python venv's activate init-file.
# Doesn't allow recursive creation of a venv with a venv-supplied python. Alters the bin/activate
# to include the user's .bashrc (eg. Git prompts, aliases, ...). Use to run Makefile targets in a
# proper context, for example to obtain a Nix environment containing the proper Python version,
# create a python venv with the current Python environment.
#
# make nix-venv-build
#
nix-%:
@if [ -r flake.nix ]; then \
nix develop $(NIX_OPTS) --command make $*; \
else \
nix-shell $(NIX_OPTS) --run "make $*"; \
fi

venv-%: $(VENV)
@echo; echo "*** Running in $< VirtualEnv: make $*"
@bash --init-file $</bin/activate -ic "make $*"

venv: $(VENV)
@echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)"
@bash --init-file $</bin/activate -i

$(VENV):
@[[ "$(PYTHON_V)" =~ "^venv" ]] && ( echo -e "\n\n!!! $@ Cannot start a venv within a venv"; false ) || true
@echo; echo "*** Building $@ VirtualEnv..."
@rm -rf $@ && $(PYTHON) -m venv $(VENV_OPTS) $@ && sed -i -e '1s:^:. $$HOME/.bashrc\n:' $@/bin/activate \
&& source $@/bin/activate \
&& make install-dev install

print-%:
@echo $* = $($*)
@echo $*\'s origin is $(origin $*)

18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
python-tabulate
===============

> This is a temporary upgrade shim for https://github.com/astanin/python-tabulate

> Install `tabulate` via `python -m pip install tabulate-slip39`,
> until the upstream https://pypi.org/project/tabulate is upgraded


Pretty-print tabular data in Python, a library and a command-line
utility.

Expand Down Expand Up @@ -503,10 +509,10 @@ format:
>>> print(tabulate(table, headers, tablefmt="asciidoc"))
[cols="8<,7>",options="header"]
|====
| item | qty
| spam | 42
| eggs | 451
| bacon | 0
| item | qty
| spam | 42
| eggs | 451
| bacon | 0
|====

```
Expand Down Expand Up @@ -1065,11 +1071,11 @@ the lines being wrapped would probably be significantly longer than this.

Text is preferably wrapped on whitespaces and right after the hyphens in hyphenated words.

break_long_words (default: True) If true, then words longer than width will be broken in order to ensure that no lines are longer than width.
break_long_words (default: True) If true, then words longer than width will be broken in order to ensure that no lines are longer than width.
If it is false, long words will not be broken, and some lines may be longer than width.
(Long words will be put on a line by themselves, in order to minimize the amount by which width is exceeded.)

break_on_hyphens (default: True) If true, wrapping will occur preferably on whitespaces and right after hyphens in compound words, as it is customary in English.
break_on_hyphens (default: True) If true, wrapping will occur preferably on whitespaces and right after hyphens in compound words, as it is customary in English.
If false, only whitespaces will be considered as potentially good places for line breaks.

```pycon
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

65 changes: 65 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
description = "Python HD Wallet development environment with multiple Python versions";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/25.05";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};

# Create Python environments with required packages
mkPythonEnv = pythonPkg: pythonPkg.withPackages (ps: with ps; [
pip
build
pytest
tox
numpy
pandas
wcwidth
]);

python310Env = mkPythonEnv pkgs.python310;
python311Env = mkPythonEnv pkgs.python311;
python312Env = mkPythonEnv pkgs.python312;
python313Env = mkPythonEnv pkgs.python313;
python314Env = mkPythonEnv pkgs.python314;

in {
# Single development shell with all Python versions
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Common tools
cacert
git
gnumake
openssh
bash
bash-completion

# All Python versions with packages
#python310Env
python311Env
python312Env
python313Env
#python314Env
];

shellHook = ''
echo "Welcome to the multi-Python development environment!"
echo "Available Python interpreters:"
echo " python (default): $(python --version 2>&1 || echo 'not available')"
#echo " python3.10: $(python3.10 --version 2>&1 || echo 'not available')"
echo " python3.11: $(python3.11 --version 2>&1 || echo 'not available')"
echo " python3.12: $(python3.12 --version 2>&1 || echo 'not available')"
echo " python3.13: $(python3.13 --version 2>&1 || echo 'not available')"
#echo " python3.14: $(python3.14 --version 2>&1 || echo 'not available')"
echo ""
echo "All versions have pytest and tox installed."
'';
};
});
}
4 changes: 4 additions & 0 deletions nixpkgs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import (fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/refs/tags/25.05.tar.gz";
sha256 = "1915r28xc4znrh2vf4rrjnxldw2imysz819gzhk9qlrkqanmfsxd";
})
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=77.0.3", "setuptools_scm[toml]>=3.4.3"]
build-backend = "setuptools.build_meta"

[project]
name = "tabulate"
name = "tabulate-slip39"
authors = [{name = "Sergey Astanin", email = "s.astanin@gmail.com"}]
license = "MIT"
license-files = ["LICENSE"]
Expand Down
11 changes: 11 additions & 0 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
build
pre-commit
setuptools >=77.0.3
setuptools_scm[toml] >=3.4.3
wheel
flake8
pytest
tox
# for benchmark/benchmark.py
prettytable
texttable
Loading