From 2732363f42cd1ceed1138f911d6b1198c340b87d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 30 Sep 2023 10:04:21 +0100 Subject: [PATCH] Modernize buildsystem (#199) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * flake.lock: Update Flake lock file updates: • Updated input 'flake-parts': 'github:hercules-ci/flake-parts/59cf3f1447cfc75087e7273b04b31e689a8599fb' (2023-08-01) → 'github:hercules-ci/flake-parts/7f53fdb7bdc5bb237da7fefef12d099e4fd611ca' (2023-09-01) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/cf73a86c35a84de0e2f3ba494327cf6fb51c0dfd' (2023-08-10) → 'github:NixOS/nixpkgs/517501bcf14ae6ec47efd6a17dda0ca8e6d866f9' (2023-09-27) • Updated input 'treefmt-nix': 'github:numtide/treefmt-nix/19dee4bf6001849006a63f3435247316b0488e99' (2023-08-12) → 'github:numtide/treefmt-nix/720bd006d855b08e60664e4683ccddb7a9ff614a' (2023-09-27) * nix-update: convert to pyproject * drop old pkgs.nixVersions.stable fallback * add create-release.sh script --- bin/create-release.sh | 38 ++++++++++++++++++++++++++++++++++++++ default.nix | 7 +++++-- flake.lock | 18 +++++++++--------- pyproject.toml | 24 ++++++++++++++++++++++++ setup.cfg | 42 ------------------------------------------ setup.py | 5 ----- 6 files changed, 76 insertions(+), 58 deletions(-) create mode 100755 bin/create-release.sh delete mode 100644 setup.cfg delete mode 100755 setup.py diff --git a/bin/create-release.sh b/bin/create-release.sh new file mode 100755 index 0000000..cc2efce --- /dev/null +++ b/bin/create-release.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -eu -o pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null && pwd)" +cd "$SCRIPT_DIR/.." + +version=${1:-} +if [[ -z "$version" ]]; then + echo "USAGE: $0 version" >&2 + exit 1 +fi + +if [[ "$(git symbolic-ref --short HEAD)" != "master" ]]; then + echo "must be on master branch" >&2 + exit 1 +fi + +# ensure we are up-to-date +uncommitted_changes=$(git diff --compact-summary) +if [[ -n "$uncommitted_changes" ]]; then + echo -e "There are uncommitted changes, exiting:\n${uncommitted_changes}" >&2 + exit 1 +fi +git pull git@github.com:Mic92/nix-update master +unpushed_commits=$(git log --format=oneline origin/master..master) +if [[ "$unpushed_commits" != "" ]]; then + echo -e "\nThere are unpushed changes, exiting:\n$unpushed_commits" >&2 + exit 1 +fi +sed -i -e "s!^version = \".*\"\$!version = \"${version}\"!" pyproject.toml default.nix +git add pyproject.toml default.nix +nix flake check -vL +nix develop -c pytest -s . +git commit -m "bump version ${version}" +git tag -e "${version}" + +echo "now run 'git push --tags origin master'" diff --git a/default.nix b/default.nix index 2c44082..b2a235d 100644 --- a/default.nix +++ b/default.nix @@ -3,13 +3,16 @@ pkgs.python311.pkgs.buildPythonApplication { - name = "nix-update"; + pname = "nix-update"; + version = "0.19.3"; src = ./.; + format = "pyproject"; buildInputs = [ pkgs.makeWrapper ]; + nativeBuildInputs = [ pkgs.python311.pkgs.setuptools ]; nativeCheckInputs = [ pkgs.python311.pkgs.pytest # technically not test inputs, but we need it for development in PATH - pkgs.nixVersions.stable or pkgs.nix_2_4 + pkgs.nixVersions.stable pkgs.nix-prefetch-git ]; checkPhase = '' diff --git a/flake.lock b/flake.lock index 05137bb..3943317 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1690933134, - "narHash": "sha256-ab989mN63fQZBFrkk4Q8bYxQCktuHmBIBqUG1jl6/FQ=", + "lastModified": 1693611461, + "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "59cf3f1447cfc75087e7273b04b31e689a8599fb", + "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", "type": "github" }, "original": { @@ -22,11 +22,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1691709280, - "narHash": "sha256-zmfH2OlZEXwv572d0g8f6M5Ac6RiO8TxymOpY3uuqrM=", + "lastModified": 1695837737, + "narHash": "sha256-KcqmJ5hNacLuE7fkz5586kp/vt4NLo6+Prq3DMgrxpQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "cf73a86c35a84de0e2f3ba494327cf6fb51c0dfd", + "rev": "517501bcf14ae6ec47efd6a17dda0ca8e6d866f9", "type": "github" }, "original": { @@ -50,11 +50,11 @@ ] }, "locked": { - "lastModified": 1691833704, - "narHash": "sha256-ASGhgGduEgcD3gQZhGr8xtmZ3PlVY+m2HuPnIZDbu78=", + "lastModified": 1695822946, + "narHash": "sha256-IQU3fYo0H+oGlqX5YrgZU3VRhbt2Oqe6KmslQKUO4II=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "19dee4bf6001849006a63f3435247316b0488e99", + "rev": "720bd006d855b08e60664e4683ccddb7a9ff614a", "type": "github" }, "original": { diff --git a/pyproject.toml b/pyproject.toml index 321e975..a594e25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,26 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "nix-update" +description = "Swiss-knife for updating nix packages" +version = "0.19.3" +authors = [{ name = "Jörg Thalheim", email = "joerg@thalheim.io" }] +license = { text = "MIT" } +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "Topic :: Utilities", + "Intended Audience :: Developers", +] + +[project.urls] +Homepage = "https://github.com/Mic92/nix-update" + +[project.scripts] +nix-update = "nix_update:main" + [tool.ruff] target-version = "py311" line-length = 88 @@ -7,6 +30,7 @@ ignore = [ "E501" ] [tool.mypy] python_version = "3.11" +pretty = true warn_redundant_casts = true disallow_untyped_calls = true disallow_untyped_defs = true diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index a63aa98..0000000 --- a/setup.cfg +++ /dev/null @@ -1,42 +0,0 @@ -[metadata] -name = nix-update -version = 0.0.0 -author = Jörg Thalheim -author-email = joerg@thalheim.io -home-page = https://github.com/Mic92/nix-update -description = Update Nix packages like it is 2020 -long-description = file: README.rst -license = MIT -license-file = LICENSE.rst -platform = any -classifiers = - Development Status :: 5 - Production/Stable - Environment :: Console - Topic :: Utilities - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - -[options] -zip_safe = true -include_package_data = true -python_requires = >= 3.6 -packages = find: -setup_requires = - setuptools - -[options.entry_points] -console_scripts = - nix-update = nix_update:main - -[bdist_wheel] -universal = true - -[check] -metadata = true -restructuredtext = true -strict = true[wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100755 index beda28e..0000000 --- a/setup.py +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env python - -from setuptools import setup - -setup()