From 044243a876cf83559485e557a7b6bd5950ddb1b9 Mon Sep 17 00:00:00 2001 From: Giacomo Leidi Date: Sat, 26 Oct 2024 02:04:48 +0200 Subject: [PATCH] Switch build system to flit. Signed-off-by: Giacomo Leidi --- .envrc | 29 +- .github/workflows/python-package.yml | 39 +-- .gitignore | 3 +- .guix/modules/ocui.scm | 4 +- ocui/__init__.py | 11 + poetry.lock | 397 --------------------------- poetry.toml | 3 - pyproject.toml | 43 +-- scripts/release.sh | 22 +- 9 files changed, 84 insertions(+), 467 deletions(-) delete mode 100644 poetry.lock delete mode 100644 poetry.toml diff --git a/.envrc b/.envrc index 56f8a54..8f58717 100644 --- a/.envrc +++ b/.envrc @@ -1,29 +1,30 @@ if has guix; then GUIX_PROFILE="${PWD}/.guix-root" rm -f "$GUIX_PROFILE" - use guix git-cal python-wrapper poetry pre-commit + use guix git-cal python-wrapper python-virtualenv python-flit python-keyring +else + venv_dir="${PWD}/.venv" + export FLIT_INSTALL_PYTHON="${venv_dir}/bin/python" - # Add development scripts to PATH - PATH_add "$(pwd)/scripts" - - venv_dir=".venv" - - if [ ! -e "$venv_dir/bin/python" ] ; then + if [ ! -e "$FLIT_INSTALL_PYTHON" ] ; then rm -rvf "$venv_dir" - pre-commit uninstall fi if [ ! -d "$venv_dir" ] ; then - poetry install - pre-commit install + virtualenv -p `which python3` "$venv_dir" + flit install fi +fi +# Add development scripts to PATH +PATH_add "$(pwd)/scripts" + +if has git-cal; then clear git-cal --author="$(git config user.name)" +fi - cat << EOF +cat << EOF The 'scripts' directory has been added to your PATH: you can now invoke scripts without typing the relative path. -EOF - -fi \ No newline at end of file +EOF \ No newline at end of file diff --git a/.github/workflows/python-package.yml b/.github/workflows/python-package.yml index 8e47799..a4e6620 100644 --- a/.github/workflows/python-package.yml +++ b/.github/workflows/python-package.yml @@ -30,34 +30,39 @@ jobs: strategy: fail-fast: false matrix: - python-version: ["3.10", "3.11"] - poetry-version: ["1.1.12", "1.7.0"] - os: [ubuntu-latest, macos-latest, windows-latest] + python-version: ["3.10", "3.11", "3.12"] + os: [ubuntu-latest, macos-latest] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - - name: Run image - uses: abatilo/actions-poetry@v2 - with: - poetry-version: ${{ matrix.poetry-version }} + - name: Install flit and virtualenv + run: | + pip install flit virtualenv - name: Setup a local virtual environment run: | - poetry config virtualenvs.create true --local - poetry config virtualenvs.in-project true --local - - uses: actions/cache@v3 - name: Define a cache for the virtual environment based on the dependencies lock file - with: - path: ./.venv - key: venv-${{ hashFiles('poetry.lock') }} + virtualenv .venv + # - uses: actions/cache@v3 + # name: Define a cache for the virtual environment based on the dependencies lock file + # with: + # path: ./.venv + # key: venv-${{ hashFiles('pyproject.toml') }} - name: Install dependencies run: | - poetry install + . ./.venv/bin/activate + export FLIT_INSTALL_PYTHON="./.venv/bin/python" + flit install - name: Lint with flake8 run: | + . ./.venv/bin/activate # stop the build if there are Python syntax errors or undefined names - poetry run flake8 . --exclude .venv --count --select=E9,F63,F7,F82 --show-source --statistics + flake8 . --exclude .venv --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide - poetry run flake8 . --exclude .venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + flake8 . --exclude .venv --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Build wheel + run: | + . ./.venv/bin/activate + export FLIT_INSTALL_PYTHON="./.venv/bin/python" + flit build diff --git a/.gitignore b/.gitignore index 7ee2a12..98acef5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ +.pypirc .idea .venv *.pyc __pycache__ dist -.vscode \ No newline at end of file +.vscode diff --git a/.guix/modules/ocui.scm b/.guix/modules/ocui.scm index 46db58e..3fb2555 100644 --- a/.guix/modules/ocui.scm +++ b/.guix/modules/ocui.scm @@ -36,9 +36,9 @@ (list ;; There are no unit tests currently. #:tests? #f)) - (native-inputs (list poetry - python-debugpy + (native-inputs (list python-debugpy python-flake8 + python-flit python-textual-dev)) (propagated-inputs (list python-appdirs python-textual-0.41 diff --git a/ocui/__init__.py b/ocui/__init__.py index e69de29..85be65a 100644 --- a/ocui/__init__.py +++ b/ocui/__init__.py @@ -0,0 +1,11 @@ +""" +ocui is a terminal user interface to facilitate the most common tasks around +OCI containers running on a single host. You can create, start and kill +containers with few keystrokes, as well as look at logs in real time, or +inspect images. + +ocui continually watches the system for changes and offers adequate commands +to interact with the system resources. +""" + +__version__ = "0.1.0" \ No newline at end of file diff --git a/poetry.lock b/poetry.lock deleted file mode 100644 index 5822b51..0000000 --- a/poetry.lock +++ /dev/null @@ -1,397 +0,0 @@ -[[package]] -name = "aiohappyeyeballs" -version = "2.4.0" -description = "Happy Eyeballs for asyncio" -category = "dev" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "aiohttp" -version = "3.10.5" -description = "Async http client/server framework (asyncio)" -category = "dev" -optional = false -python-versions = ">=3.8" - -[package.dependencies] -aiohappyeyeballs = ">=2.3.0" -aiosignal = ">=1.1.2" -async-timeout = {version = ">=4.0,<5.0", markers = "python_version < \"3.11\""} -attrs = ">=17.3.0" -frozenlist = ">=1.1.1" -multidict = ">=4.5,<7.0" -yarl = ">=1.0,<2.0" - -[package.extras] -speedups = ["brotlicffi", "brotli", "aiodns (>=3.2.0)"] - -[[package]] -name = "aiosignal" -version = "1.3.1" -description = "aiosignal: a list of registered asynchronous callbacks" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -frozenlist = ">=1.1.0" - -[[package]] -name = "appdirs" -version = "1.4.4" -description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "main" -optional = false -python-versions = "*" - -[[package]] -name = "async-timeout" -version = "4.0.3" -description = "Timeout context manager for asyncio programs" -category = "dev" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "attrs" -version = "24.2.0" -description = "Classes Without Boilerplate" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.extras] -benchmark = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest-codspeed", "pytest-mypy-plugins", "pytest-xdist", "pytest (>=4.3.0)"] -cov = ["cloudpickle", "coverage[toml] (>=5.3)", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest-mypy-plugins", "pytest-xdist", "pytest (>=4.3.0)"] -dev = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pre-commit", "pympler", "pytest-mypy-plugins", "pytest-xdist", "pytest (>=4.3.0)"] -docs = ["cogapp", "furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier (<24.7)"] -tests = ["cloudpickle", "hypothesis", "mypy (>=1.11.1)", "pympler", "pytest-mypy-plugins", "pytest-xdist", "pytest (>=4.3.0)"] -tests-mypy = ["mypy (>=1.11.1)", "pytest-mypy-plugins"] - -[[package]] -name = "click" -version = "8.1.7" -description = "Composable command line interface toolkit" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -colorama = {version = "*", markers = "platform_system == \"Windows\""} - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -category = "dev" -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" - -[[package]] -name = "debugpy" -version = "1.6.7.post1" -description = "An implementation of the Debug Adapter Protocol for Python" -category = "dev" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "flake8" -version = "6.1.0" -description = "the modular source code checker: pep8 pyflakes and co" -category = "dev" -optional = false -python-versions = ">=3.8.1" - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.1.0,<3.2.0" - -[[package]] -name = "frozenlist" -version = "1.4.1" -description = "A list-like structure which implements collections.abc.MutableSequence" -category = "dev" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "idna" -version = "3.8" -description = "Internationalized Domain Names in Applications (IDNA)" -category = "dev" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "importlib-metadata" -version = "8.4.0" -description = "Read metadata from Python packages" -category = "main" -optional = false -python-versions = ">=3.8" - -[package.dependencies] -zipp = ">=0.5" - -[package.extras] -doc = ["sphinx (>=3.5)", "jaraco.packaging (>=9.3)", "rst.linker (>=1.9)", "furo", "sphinx-lint", "jaraco.tidelift (>=1.4)"] -perf = ["ipython"] -test = ["pytest (>=6,<8.1.0 || >=8.2.0)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-mypy", "pytest-enabler (>=2.2)", "packaging", "pyfakefs", "flufl.flake8", "pytest-perf (>=0.9.2)", "jaraco.test (>=5.4)", "importlib-resources (>=1.3)", "pytest-ruff (>=0.2.1)"] - -[[package]] -name = "linkify-it-py" -version = "2.0.3" -description = "Links recognition library with FULL unicode support." -category = "main" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -uc-micro-py = "*" - -[package.extras] -benchmark = ["pytest", "pytest-benchmark"] -dev = ["pre-commit", "isort", "flake8", "black", "pyproject-flake8"] -doc = ["sphinx", "sphinx-book-theme", "myst-parser"] -test = ["pytest", "coverage", "pytest-cov"] - -[[package]] -name = "markdown-it-py" -version = "3.0.0" -description = "Python port of markdown-it. Markdown parsing, done right!" -category = "main" -optional = false -python-versions = ">=3.8" - -[package.dependencies] -linkify-it-py = {version = ">=1,<3", optional = true, markers = "extra == \"linkify\""} -mdit-py-plugins = {version = "*", optional = true, markers = "extra == \"plugins\""} -mdurl = ">=0.1,<1.0" - -[package.extras] -benchmarking = ["psutil", "pytest", "pytest-benchmark"] -code_style = ["pre-commit (>=3.0,<4.0)"] -compare = ["commonmark (>=0.9,<1.0)", "markdown (>=3.4,<4.0)", "mistletoe (>=1.0,<2.0)", "mistune (>=2.0,<3.0)", "panflute (>=2.3,<3.0)"] -linkify = ["linkify-it-py (>=1,<3)"] -plugins = ["mdit-py-plugins"] -profiling = ["gprof2dot"] -rtd = ["mdit-py-plugins", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "sphinx-book-theme", "jupyter-sphinx"] -testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] - -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -category = "dev" -optional = false -python-versions = ">=3.6" - -[[package]] -name = "mdit-py-plugins" -version = "0.4.1" -description = "Collection of plugins for markdown-it-py" -category = "main" -optional = false -python-versions = ">=3.8" - -[package.dependencies] -markdown-it-py = ">=1.0.0,<4.0.0" - -[package.extras] -code-style = ["pre-commit"] -rtd = ["myst-parser", "sphinx-book-theme"] -testing = ["coverage", "pytest", "pytest-cov", "pytest-regressions"] - -[[package]] -name = "mdurl" -version = "0.1.2" -description = "Markdown URL utilities" -category = "main" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "msgpack" -version = "1.0.8" -description = "MessagePack serializer" -category = "dev" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "multidict" -version = "6.0.5" -description = "multidict implementation" -category = "dev" -optional = false -python-versions = ">=3.7" - -[[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" -category = "dev" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "pyflakes" -version = "3.1.0" -description = "passive checker of Python programs" -category = "dev" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "pygments" -version = "2.18.0" -description = "Pygments is a syntax highlighting package written in Python." -category = "main" -optional = false -python-versions = ">=3.8" - -[package.extras] -windows-terminal = ["colorama (>=0.4.6)"] - -[[package]] -name = "rich" -version = "13.8.0" -description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" -category = "main" -optional = false -python-versions = ">=3.7.0" - -[package.dependencies] -markdown-it-py = ">=2.2.0" -pygments = ">=2.13.0,<3.0.0" - -[package.extras] -jupyter = ["ipywidgets (>=7.5.1,<9)"] - -[[package]] -name = "textual" -version = "0.41.0" -description = "Modern Text User Interface framework" -category = "main" -optional = false -python-versions = ">=3.7,<4.0" - -[package.dependencies] -importlib-metadata = ">=4.11.3" -markdown-it-py = {version = ">=2.1.0", extras = ["linkify", "plugins"]} -rich = ">=13.3.3" -typing-extensions = ">=4.4.0,<5.0.0" - -[package.extras] -syntax = ["tree-sitter (>=0.20.1,<0.21.0)", "tree_sitter_languages (>=1.7.0)"] - -[[package]] -name = "textual-dev" -version = "1.2.1" -description = "Development tools for working with Textual" -category = "dev" -optional = false -python-versions = ">=3.7,<4.0" - -[package.dependencies] -aiohttp = ">=3.8.1" -click = ">=8.1.2" -msgpack = ">=1.0.3" -textual = ">=0.33.0" -typing-extensions = ">=4.4.0,<5.0.0" - -[[package]] -name = "toml" -version = "0.10.2" -description = "Python Library for Tom's Obvious, Minimal Language" -category = "main" -optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" - -[[package]] -name = "typing-extensions" -version = "4.12.2" -description = "Backported and Experimental Type Hints for Python 3.8+" -category = "main" -optional = false -python-versions = ">=3.8" - -[[package]] -name = "uc-micro-py" -version = "1.0.3" -description = "Micro subset of unicode data files for linkify-it-py projects." -category = "main" -optional = false -python-versions = ">=3.7" - -[package.extras] -test = ["pytest", "coverage", "pytest-cov"] - -[[package]] -name = "yarl" -version = "1.9.4" -description = "Yet another URL library" -category = "dev" -optional = false -python-versions = ">=3.7" - -[package.dependencies] -idna = ">=2.0" -multidict = ">=4.0" - -[[package]] -name = "zipp" -version = "3.20.1" -description = "Backport of pathlib-compatible object wrapper for zip files" -category = "main" -optional = false -python-versions = ">=3.8" - -[package.extras] -check = ["pytest-checkdocs (>=2.4)", "pytest-ruff (>=0.2.1)"] -cover = ["pytest-cov"] -doc = ["sphinx (>=3.5)", "jaraco.packaging (>=9.3)", "rst.linker (>=1.9)", "furo", "sphinx-lint", "jaraco.tidelift (>=1.4)"] -enabler = ["pytest-enabler (>=2.2)"] -test = ["pytest (>=6,<8.1.0 || >=8.2.0)", "jaraco.itertools", "jaraco.functools", "more-itertools", "big-o", "pytest-ignore-flaky", "jaraco.test", "importlib-resources"] -type = ["pytest-mypy"] - -[metadata] -lock-version = "1.1" -python-versions = "^3.10" -content-hash = "4a9cf2c1ef05cb390c79366e0b3c56cba6eff4a30b61a607654f55c7678eceff" - -[metadata.files] -aiohappyeyeballs = [] -aiohttp = [] -aiosignal = [] -appdirs = [] -async-timeout = [] -attrs = [] -click = [] -colorama = [] -debugpy = [] -flake8 = [] -frozenlist = [] -idna = [] -importlib-metadata = [] -linkify-it-py = [] -markdown-it-py = [] -mccabe = [] -mdit-py-plugins = [] -mdurl = [] -msgpack = [] -multidict = [] -pycodestyle = [] -pyflakes = [] -pygments = [] -rich = [] -textual = [] -textual-dev = [] -toml = [] -typing-extensions = [] -uc-micro-py = [] -yarl = [] -zipp = [] diff --git a/poetry.toml b/poetry.toml deleted file mode 100644 index 53b35d3..0000000 --- a/poetry.toml +++ /dev/null @@ -1,3 +0,0 @@ -[virtualenvs] -create = true -in-project = true diff --git a/pyproject.toml b/pyproject.toml index 94c39ec..32e0c07 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,24 +1,29 @@ -[tool.poetry] +[build-system] +requires = ["flit_core >=3.2,<4"] +build-backend = "flit_core.buildapi" + +[project] name = "ocui" -version = "0.1.0" -description = "This is a simple and handy text based GUI utility for dealing with boring and repetitive tasks when managing containers." -authors = ["Giacomo Leidi "] +license = {file = "LICENSE"} readme = "README.md" +authors = [{name = "Giacomo Leidi", email = "goodoldpaul@autistici.org"}] +dynamic = ["version", "description"] +dependencies = [ + "appdirs ~=1.4", + "textual ~=0.41", + "toml ~=0.10", +] +requires-python = ">=3.10" -[tool.poetry.dependencies] -python = "^3.10" -appdirs = "~1.4" -textual = "~0.41" -toml = "~0.10" +[project.optional-dependencies] +test = [ + "flake8 ~=6.1", + "debugpy ~=1.6", + "textual-dev ~=1.2", +] -[tool.poetry.dev-dependencies] -flake8 = "~6.1" -debugpy = "~1.6" -textual-dev = "~1.2" - -[build-system] -requires = ["poetry-core"] -build-backend = "poetry.core.masonry.api" +[project.scripts] +ocui="ocui.app:main" -[tool.poetry.scripts] -ocui="ocui.app:main" \ No newline at end of file +[project.urls] +Home = "https://github.com/fishinthecalculator/ocui" \ No newline at end of file diff --git a/scripts/release.sh b/scripts/release.sh index 2bfde5b..a073c6d 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -4,7 +4,7 @@ set -eu myself="$(basename "$0")" version_file="$(pwd)/ocui/res/VERSION" -pyproject_toml="$(pwd)/pyproject.toml" +init_py="$(pwd)/ocui/__init__.py" channel_scm="$(pwd)/.guix/modules/ocui.scm" generate_badges="$(pwd)/scripts/generate_badges.sh" imgs="$(pwd)/.img" @@ -16,7 +16,7 @@ verbose=0 publish=0 bump="INVALID" -required_commands=("getopt" "pysemver" "git" "poetry") +required_commands=("getopt" "pysemver" "git" "flit") valid_types=('major' 'minor' 'patch' 'prerelease' 'build') error() { @@ -64,12 +64,6 @@ validate-bump-type() { fi } -validate-pypi-token() { - if [ -z ${PYPI_TOKEN+x} ]; then - crash "The PYPI_TOKEN environment variable is required but unset. Please set it to upload the new release to PyPI." - fi -} - current-version() { cat "${version_file}" } @@ -82,15 +76,14 @@ release-new-version() { [ "$verbose" = "1" ] && echo "Updating ${version_file}..." [ "$dryrun" = "0" ] && printf "%s" "$next" >"$version_file" - [ "$verbose" = "1" ] && echo "Updating ${pyproject_toml}..." - [ "$dryrun" = "0" ] && sed -i -E "s/version.*=.*\"${current}\"$/version = \"${next}\"/" "$pyproject_toml" + [ "$verbose" = "1" ] && echo "Updating ${init_py}..." + [ "$dryrun" = "0" ] && sed -i -E "s/__version__.*=.*\"${current}\"$/__version__ = \"${next}\"/" "$init_py" [ "$verbose" = "1" ] && echo "Updating ${channel_scm}..." [ "$dryrun" = "0" ] && sed -i "s/${current}/${next}/g" "$channel_scm" if command -v "guix" >/dev/null; then - [ "$verbose" = "1" ] && echo "Generating badges..." [ "$dryrun" = "0" ] && guix shell python-wrapper python-pybadges -- "${generate_badges}" && git add "${imgs}" @@ -106,7 +99,7 @@ release-new-version() { [ "$dryrun" = "0" ] && git tag "v${next}" [ "$verbose" = "1" ] && echo "Building package..." - [ "$dryrun" = "0" ] && poetry build + [ "$dryrun" = "0" ] && flit build } @@ -178,14 +171,15 @@ if [ "$bump" != "INVALID" ]; then fi if [ "$publish" = "1" ]; then - validate-pypi-token # We make sure to actually publish the tagged version git checkout "v$(current-version)" set +e # If this command fails we still want to go back to the # branch we were on. - poetry publish -u "__token__" -p "$PYPI_TOKEN" + FLIT_USERNAME="__token__" + SOURCE_DATE_EPOCH=$(date +%s) + flit publish set -e restore-git-state fi