Skip to content

Commit

Permalink
Switch build-backend to hatchling and modernize a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
zeevro authored and sharkdp committed Nov 22, 2024
1 parent ea630dc commit 647c051
Show file tree
Hide file tree
Showing 15 changed files with 108 additions and 171 deletions.
12 changes: 3 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,9 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: pip install .[tests]
- name: Run unit tests
run: pytest -vv
- uses: astral-sh/setup-uv@v3
- run: uv run --all-extras -p ${{ matrix.python-version }} pytest -vv
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,6 @@ ENV/

# mypy
.mypy_cache/

# uv
uv.lock
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ If you want to try it out on your own, run:
pip install shell-functools
```

If you only want to try it out temporarily, you can also use:
``` bash
git clone https://github.com/sharkdp/shell-functools /tmp/shell-functools
export PATH="$PATH:/tmp/shell-functools/ft"
```

## Documentation and examples

### Usage of `map`
Expand Down
6 changes: 0 additions & 6 deletions ft/filter

This file was deleted.

6 changes: 0 additions & 6 deletions ft/foldl

This file was deleted.

6 changes: 0 additions & 6 deletions ft/foldl1

This file was deleted.

53 changes: 0 additions & 53 deletions ft/ft-functions

This file was deleted.

5 changes: 3 additions & 2 deletions ft/ft/command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
import argparse
from signal import signal, SIGPIPE, SIG_DFL
import signal

from functools import partial

Expand All @@ -22,7 +22,8 @@ def __init__(self, name):
@staticmethod
def configure_broken_pipe():
# Use the default behavior (exit quietly) when catching SIGPIPE
signal(SIGPIPE, SIG_DFL)
if hasattr(signal, 'SIGPIPE'):
signal.signal(signal.SIGPIPE, signal.SIG_DFL)

def get_argument_parser(self):
parser = argparse.ArgumentParser(description=self.name)
Expand Down
56 changes: 56 additions & 0 deletions ft/ft/commands/ft_functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from ft.types import T_VOID
from ft.functions import function_list
from ft.termcolor import colored

type_color = {
"String": "yellow",
"Path": "cyan",
"Int": "blue",
"Bool": "magenta",
"Array": "red",
"*": "white",
"!": "red"
}


def with_color(typename):
if typename in type_color:
return colored(typename, type_color[typename])

return typename


def main():
for name, fn in sorted(function_list.items()):
type_in = fn.type_in
type_out = fn.type_out

if type_in is None:
type_in = with_color("*")
else:
type_in = with_color(str(type_in))

if type_out is None:
type_out = with_color("*")
elif type_out == "returned":
type_out = with_color("*")
elif type_out == T_VOID:
type_out = with_color("!")
else:
type_out = with_color(str(type_out))

arg_names = fn.inner_argspec.args[:-1]

name_and_args = colored(name, "green")

if len(arg_names) > 0:
name_and_args += " " + " ".join(arg_names)

print("{name_and_args:<28} :: {type_in:<15} → {type_out}".format(
name_and_args=name_and_args,
type_in=type_in,
type_out=type_out))


if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion ft/ft/version.py

This file was deleted.

6 changes: 0 additions & 6 deletions ft/map

This file was deleted.

5 changes: 0 additions & 5 deletions ft/sort_by

This file was deleted.

6 changes: 0 additions & 6 deletions ft/take_while

This file was deleted.

43 changes: 43 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "shell-functools"
version = "0.3.1"
description = "A collection of functional programming tools for the shell."
authors = [{ name = "David Peter", email = "mail@david-peter.de" }]
urls = { Home = "https://github.com/sharkdp/shell-functools" }
keywords = ["shell", "functional-programming", "filesystem", "string-manipulation", "command-line"]
classifiers=[
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
readme = { file = "README.md", content-type = "text/markdown" }
license = "MIT"
requires-python = ">=3.9"

[project.optional-dependencies]
tests = [
"pytest",
]

[project.scripts]
filter = "ft.commands.filter:Filter.main"
foldl = "ft.commands.foldl:Foldl.main"
foldl1 = "ft.commands.foldl1:Foldl1.main"
ft-functions = "ft.commands.ft_functions:main"
map = "ft.commands.map:Map.main"
sort_by = "ft.commands.sort_by:SortBy.main"
take_while = "ft.commands.take_while:TakeWhile.main"

[tool.hatch.build.targets.wheel]
packages = ["ft/ft"]
65 changes: 0 additions & 65 deletions setup.py

This file was deleted.

0 comments on commit 647c051

Please sign in to comment.