Skip to content
Open
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
89 changes: 89 additions & 0 deletions pkgs/by-name/ty/typ2docx/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
lib,
python3Packages,
fetchFromGitHub,
fetchurl,
rustPlatform,

pkg-config,
openssl,

pandoc,
}:
python3Packages.buildPythonApplication rec {
pname = "typ2docx";
version = "0.8.0";
pyproject = true;

src = fetchFromGitHub {
owner = "sghng";
repo = "typ2docx";
tag = "v${version}";
hash = "sha256-8Jb13qiS+dpyfJS4m2T6STzORs1VzRKwC8GGgEwiVtU=";
};

# use `v${version}` for update script
lockFile = fetchurl {
url = "https://github.com/sghng/typ2docx/releases/download/v${version}/Cargo.lock";
hash = "sha256-irWv7+uqNyyq42JVLSy9WQz78ynYVsYuQ8fk5nardWw=";
};

cargoDeps = rustPlatform.fetchCargoVendor {
inherit
pname
version
src
postPatch
;
hash = "sha256-Gvdj9izGCem0A3Cy7RBzNzJ57lxk5GRP8I2C2T6RsbY=";
};

postPatch = ''
ln -s ${lockFile} Cargo.lock
'';

nativeBuildInputs = [
rustPlatform.cargoSetupHook
rustPlatform.maturinBuildHook
pkg-config
];

build-system = with python3Packages; [
uv-build
];

dependencies = with python3Packages; [
pdf2docx
pdfservices-sdk
pypdf
rich
saxonche
typer
];

buildInputs = [
openssl
];

makeWrapperArgs = [
"--prefix"
"PATH"
":"
"${lib.makeBinPath [ pandoc ]}"
"--prefix"
"PYTHONPATH"
":"
"$PYTHONPATH"
];

passthru.updateScript = ./update.sh;

meta = {
description = "Convert Math-Rich Typst Project to Microsoft Word Format";
homepage = "https://github.com/sghng/typ2docx";
changelog = "https://github.com/sghng/typ2docx/blob/${src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ hhr2020 ];
mainProgram = "typ2docx";
};
}
18 changes: 18 additions & 0 deletions pkgs/by-name/ty/typ2docx/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts nix-update jq gnused

set -eou pipefail

currentVersion=$(nix eval --raw -f . typ2docx.version)
latestVersion=$(curl --fail --silent https://api.github.com/repos/sghng/typ2docx/releases/latest | jq --raw-output .tag_name | sed 's/^v//')

echo "latest version: $latestVersion"
echo "current version: $currentVersion"

if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi

update-source-version typ2docx $latestVersion --source-key=lockFile --ignore-same-version
nix-update typ2docx --version skip
48 changes: 48 additions & 0 deletions pkgs/development/python-modules/pdfservices-sdk/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
setuptools,
defusedxml,
requests,
sphinx,
sphinx-rtd-theme,
}:

buildPythonPackage rec {
pname = "pdfservices-sdk";
version = "4.2.0";
pyproject = true;

src = fetchFromGitHub {
owner = "adobe";
repo = "pdfservices-python-sdk";
tag = "v${version}";
hash = "sha256-m2k+IS+M8UrdrpLnk2OwRolAVq73StMY1WnxzOujBIM=";
};

pythonRelaxDeps = true;

build-system = [
setuptools
];

dependencies = [
defusedxml
requests
sphinx
sphinx-rtd-theme
];

pythonImportsCheck = [
"adobe.pdfservices"
];

meta = {
description = "Adobe PDFServices Python SDK";
homepage = "https://github.com/adobe/pdfservices-python-sdk";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ hhr2020 ];
sourceProvenance = with lib.sourceTypes; [ fromSource ];
};
}
50 changes: 50 additions & 0 deletions pkgs/development/python-modules/saxonche/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
lib,
autoPatchelfHook,
buildPythonPackage,
fetchPypi,
python,
stdenv,
zlib,
}:
let
pythonVersionNoDot = builtins.replaceStrings [ "." ] [ "" ] python.pythonVersion;
inherit (stdenv.hostPlatform) system;
releases = lib.importJSON ./releases.json;
in
buildPythonPackage rec {
pname = "saxonche";
inherit (releases) version;
format = "wheel";

src = fetchPypi {
pname = "saxonche";
inherit version;
format = "wheel";
python = "cp${pythonVersionNoDot}";
abi = "cp${pythonVersionNoDot}";
dist = "cp${pythonVersionNoDot}";
platform = releases."${pythonVersionNoDot}-${system}".platform or (throw "unsupported system");
hash = releases."${pythonVersionNoDot}-${system}".hash or (throw "unsupported system");
};

dontBuild = true;

nativeBuildInputs = lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ];

buildInputs = [
zlib
];

pythonImportsCheck = [ "saxonche" ];

passthru.updateScript = ./update.py;

meta = {
description = "Official Python package for the SaxonC-HE processor";
homepage = "https://www.saxonica.com/saxon-c/index.xml";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ hhr2020 ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
};
}
83 changes: 83 additions & 0 deletions pkgs/development/python-modules/saxonche/releases.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"314-x86_64-linux": {
"platform": "manylinux_2_24_x86_64",
"hash": "sha256-tq0/kHqHERdyuIexF1QrT9AwJTwjaxu3GQKXLO/PVdo="
},
"314-aarch64-linux": {
"platform": "manylinux_2_24_aarch64",
"hash": "sha256-oaebbnE665TMMIFSU73pbG36vo6m8hSWntDkrmCYD2g="
},
"314-x86_64-darwin": {
"platform": "macosx_11_0_x86_64",
"hash": "sha256-y1k0A3c3+3ly9T6UCBZfGHxOzqXvIT/NvCG3hvRnp4Q="
},
"314-aarch64-darwin": {
"platform": "macosx_11_0_arm64",
"hash": "sha256-O0UUZ3D2RZ4QxwkR/SjodB/NLN4HtTY58gCPmNWxUGc="
},
"313-x86_64-linux": {
"platform": "manylinux_2_24_x86_64",
"hash": "sha256-t9KV3erj58NVz1MDXsR6HbMBqLm8kXY2+JO1ajGkgYc="
},
"313-aarch64-linux": {
"platform": "manylinux_2_24_aarch64",
"hash": "sha256-Wxap5a54viT4PaaixeaYtZyk3o9ogAIvBRNRFwtp+dA="
},
"313-x86_64-darwin": {
"platform": "macosx_10_11_x86_64",
"hash": "sha256-pnAVA41KuwOaUbk1ry6YaoMTj5/ibIPyiOlydkS/g9c="
},
"313-aarch64-darwin": {
"platform": "macosx_11_0_arm64",
"hash": "sha256-uqw/nArOticdA6hwBfbFMaq6wjserj7ssdxl1/iBfpE="
},
"312-x86_64-linux": {
"platform": "manylinux_2_24_x86_64",
"hash": "sha256-SQ8w6UhnUPagZt4rRnEU39bhTSPIzmRcrWTmY/WASQo="
},
"312-aarch64-linux": {
"platform": "manylinux_2_24_aarch64",
"hash": "sha256-Us12nO+baJ731z1Jfs/Lr3m+CuH1GtcZDMK6awsFw/E="
},
"312-x86_64-darwin": {
"platform": "macosx_10_11_x86_64",
"hash": "sha256-wDl0O7SuQgqkzar66IBIqXNdP6jns9iS0orklSjbo7E="
},
"312-aarch64-darwin": {
"platform": "macosx_11_0_arm64",
"hash": "sha256-mXKva5ajdH5Lb6enbgNtK8SDEI3HH+ufeA7OUeNOBr4="
},
"311-x86_64-linux": {
"platform": "manylinux_2_24_x86_64",
"hash": "sha256-hlqyyA2T1wSBZmKdE0KJ4TY+wUd3ADuTd5pFeY5C4MY="
},
"311-aarch64-linux": {
"platform": "manylinux_2_24_aarch64",
"hash": "sha256-ZWN2m242Q8u/cZ8rHzipx0YdfY3elQGnfFuFbCemGOI="
},
"311-x86_64-darwin": {
"platform": "macosx_10_11_x86_64",
"hash": "sha256-C+swRRRBF43QEVkjQp/0M00phpr+/PcDoesjIEuuS8o="
},
"311-aarch64-darwin": {
"platform": "macosx_11_0_arm64",
"hash": "sha256-DlHMuRRdBtkYdEGok8PomfSHcRXHuVpqKCM4rek5prg="
},
"310-x86_64-linux": {
"platform": "manylinux_2_24_x86_64",
"hash": "sha256-ITbgS01T8huu8QAUw2SHSCQgWdeoghX+UAsOVL2c4ww="
},
"310-aarch64-linux": {
"platform": "manylinux_2_24_aarch64",
"hash": "sha256-8nTz+9AWp4sle4wahXJKZL72OMfAP+moTJXBH3ILn5U="
},
"310-x86_64-darwin": {
"platform": "macosx_10_11_x86_64",
"hash": "sha256-SnYpDIY8EFfSkb3BynBB4ZH0+nZyPuWLNPXWR1CIMLY="
},
"310-aarch64-darwin": {
"platform": "macosx_11_0_arm64",
"hash": "sha256-3o9mr1BFQLZZCcpDZBxMmt88FD7XHJEBuJegXYBjaak="
},
"version": "12.9.0"
}
85 changes: 85 additions & 0 deletions pkgs/development/python-modules/saxonche/update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p 'python3.withPackages(ps: [ps.requests ps.plumbum])' nix-prefetch
import json
import requests
from pathlib import Path
from plumbum.cmd import nix_prefetch

HERE = Path(__file__).parent


def write_release(releases):
with HERE.joinpath("releases.json").open("w") as fd:
json.dump(releases, fd, indent=2)
fd.write("\n")


wheels = {}

python_versions = ["314", "313", "312", "311", "310"]
systems = [
"x86_64-linux",
"aarch64-linux",
"x86_64-darwin",
"aarch64-darwin",
]


def system_to_platform(python_version, system):
match system:
case "x86_64-linux":
return "manylinux_2_24_x86_64"
case "aarch64-linux":
return "manylinux_2_24_aarch64"
case "x86_64-darwin":
return (
"macosx_11_0_x86_64"
if python_version == "314"
else "macosx_10_11_x86_64"
)
case "aarch64-darwin":
return "macosx_11_0_arm64"


for python_version in python_versions:
for system in systems:
platform = system_to_platform(python_version, system)
wheels[f"{python_version}-{system}"] = {
"platform": platform,
}


resp = requests.get("https://pypi.org/pypi/saxonche/json")
assert resp.status_code == 200
resp = resp.json()
version = resp["info"]["version"]
wheels["version"] = version


for system in systems:
for python_version in python_versions:
cp_version = f"cp{python_version}"
platform = system_to_platform(python_version, system)
print(f"downloading {python_version}-{system}: ", end="", flush=True)
hash = nix_prefetch.with_cwd(HERE)[
"fetchPypi",
"--version",
version,
"--pname",
"saxonche",
"--format",
"wheel",
"--python",
cp_version,
"--abi",
cp_version,
"--dist",
cp_version,
"--platform",
platform,
"--quiet",
]().strip()
print(f"{hash}")
wheels[f"{python_version}-{system}"]["hash"] = hash

write_release(wheels)
4 changes: 4 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11922,6 +11922,8 @@ self: super: with self; {

pdfrw2 = callPackage ../development/python-modules/pdfrw2 { };

pdfservices-sdk = callPackage ../development/python-modules/pdfservices-sdk { };

pdftotext = callPackage ../development/python-modules/pdftotext { };

pdm-backend = callPackage ../development/python-modules/pdm-backend { };
Expand Down Expand Up @@ -16829,6 +16831,8 @@ self: super: with self; {

satel-integra = callPackage ../development/python-modules/satel-integra { };

saxonche = callPackage ../development/python-modules/saxonche { };

sbom2dot = callPackage ../development/python-modules/sbom2dot { };

sbom4files = callPackage ../development/python-modules/sbom4files { };
Expand Down
Loading