diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 683fffd..772104f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -56,7 +56,7 @@ - name: Install Dependencies run: poetry install --no-interaction - name: Build Executable - run: poetry run make rename + run: poetry run make dist env: RUNNER_OS: ${{ runner.os }} RUNNER_ARCH: ${{ runner.arch }} diff --git a/Makefile b/Makefile index 341551e..2ec0c2f 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,13 @@ DIST := $(CURDIR)/dist NAME := tld -OS := $(shell echo $(RUNNER_OS) | tr '[:upper:]' '[:lower:]') -ARCH := $(shell echo $(RUNNER_ARCH) | tr '[:upper:]' '[:lower:]') +OS != echo $(RUNNER_OS) | tr '[:upper:]' '[:lower:]' +ARCH != echo $(RUNNER_ARCH) | tr '[:upper:]' '[:lower:]' + +ifneq ($(and $(OS), $(ARCH)),) + NAME := $(NAME)-$(OS)-$(ARCH) +endif + ifeq ($(OS), windows) EXE := .exe else @@ -12,9 +17,6 @@ TARGET := $(DIST)/$(NAME)$(EXE) TARGET_INSTALL := $(BIN)/$(NAME)$(EXE) -TARGET_RENAME := $(DIST)/$(NAME)-$(OS)-$(ARCH)$(EXE) - -build: $(TARGET) clean: $(RM) --recursive $(CURDIR)/build @@ -23,24 +25,21 @@ demo: $(CURDIR)/demo.gif -deps: $(CURDIR)/poetry.lock $(CURDIR)/requirements.txt +dist: $(TARGET) install: $(TARGET_INSTALL) +poetry: $(CURDIR)/poetry.lock $(CURDIR)/requirements.txt + pretty: isort --profile black $(CURDIR) black $(CURDIR) -rename: $(TARGET_RENAME) - ALWAYS: $(TARGET_INSTALL): $(TARGET) install -D --mode=u=rwx,go=rx --no-target-directory $< $@ -$(TARGET_RENAME): $(TARGET) - mv $< $@ - $(CURDIR)/demo.gif: $(CURDIR)/demo.tape ifeq ($(BW_SESSION),) $(error Bitwarden Locked) @@ -55,4 +54,4 @@ poetry export --output=$@ --without-hashes --without-urls $(TARGET): - pyinstaller --distpath $(DIST) --onefile --name $(NAME) $(CURDIR)/main.py + pyinstaller --onefile --name $(NAME) $(CURDIR)/main.py diff --git a/README.md b/README.md index 6c44bb1..67dd6d7 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ **Usage**: -```shell-session +```console $ tld [OPTIONS] ``` @@ -38,8 +38,6 @@ - `-c, --course TEXT` - `--prefix PATH`: [default: /home/liblaf/Desktop/thu-learn] - `-s, --size-limit INTEGER`: [default: 9223372036854775807] -- `--install-completion`: Install completion for the current shell. -- `--show-completion`: Show completion for the current shell, to copy it or customize the installation. - `--help`: Show this message and exit. ## Features diff --git a/poetry.lock b/poetry.lock index 0056174..355ff0e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -72,7 +72,6 @@ packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" -tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} [package.extras] colorama = ["colorama (>=0.4.3)"] @@ -205,21 +204,6 @@ ] [[package]] -name = "commonmark" -version = "0.9.1" -description = "Python parser for the CommonMark Markdown spec" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "commonmark-0.9.1-py2.py3-none-any.whl", hash = "sha256:da2f38c92590f83de410ba1a3cbceafbc74fee9def35f9251ba9a971d6d66fd9"}, - {file = "commonmark-0.9.1.tar.gz", hash = "sha256:452f9dc859be7f06631ddcb328b6919c67984aca654e5fefb3914d54691aed60"}, -] - -[package.extras] -test = ["flake8 (==3.7.8)", "hypothesis (==3.55.3)"] - -[[package]] name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" @@ -265,6 +249,43 @@ altgraph = ">=0.17" [[package]] +name = "markdown-it-py" +version = "2.2.0" +description = "Python port of markdown-it. Markdown parsing, done right!" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "markdown-it-py-2.2.0.tar.gz", hash = "sha256:7c9a5e412688bc771c67432cbfebcdd686c93ce6484913dccf06cb5a0bea35a1"}, + {file = "markdown_it_py-2.2.0-py3-none-any.whl", hash = "sha256:5a35f8d1870171d9acc47b99612dc146129b631baf04970128b568f190d0cc30"}, +] + +[package.dependencies] +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 = ["attrs", "myst-parser", "pyyaml", "sphinx", "sphinx-copybutton", "sphinx-design", "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" +files = [ + {file = "mdurl-0.1.2-py3-none-any.whl", hash = "sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8"}, + {file = "mdurl-0.1.2.tar.gz", hash = "sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"}, +] + +[[package]] name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." @@ -314,19 +335,19 @@ [[package]] name = "platformdirs" -version = "3.2.0" +version = "3.5.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "platformdirs-3.2.0-py3-none-any.whl", hash = "sha256:ebe11c0d7a805086e99506aa331612429a72ca7cd52a1f0d277dc4adc20cb10e"}, - {file = "platformdirs-3.2.0.tar.gz", hash = "sha256:d5b638ca397f25f979350ff789db335903d7ea010ab28903f57b27e1b16c2b08"}, + {file = "platformdirs-3.5.0-py3-none-any.whl", hash = "sha256:47692bc24c1958e8b0f13dd727307cff1db103fca36399f457da8e05f222fdc4"}, + {file = "platformdirs-3.5.0.tar.gz", hash = "sha256:7954a68d0ba23558d753f73437c55f89027cf8f5108c19844d4b82e5af396335"}, ] [package.extras] -docs = ["furo (>=2022.12.7)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.22,!=1.23.4)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.2.2)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] +docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] [[package]] name = "pygments" @@ -403,14 +424,14 @@ [[package]] name = "requests" -version = "2.28.2" +version = "2.29.0" description = "Python HTTP for Humans." category = "main" optional = false -python-versions = ">=3.7, <4" +python-versions = ">=3.7" files = [ - {file = "requests-2.28.2-py3-none-any.whl", hash = "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa"}, - {file = "requests-2.28.2.tar.gz", hash = "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf"}, + {file = "requests-2.29.0-py3-none-any.whl", hash = "sha256:e8f3c9be120d3333921d213eef078af392fba3933ab7ed2d1cba3b56f2568c3b"}, + {file = "requests-2.29.0.tar.gz", hash = "sha256:f2e34a75f4749019bb0e3effb66683630e4ffeaf75819fb51bebef1bf5aef059"}, ] [package.dependencies] @@ -425,33 +446,33 @@ [[package]] name = "rich" -version = "12.6.0" +version = "13.3.5" description = "Render rich text, tables, progress bars, syntax highlighting, markdown and more to the terminal" category = "main" optional = false -python-versions = ">=3.6.3,<4.0.0" +python-versions = ">=3.7.0" files = [ - {file = "rich-12.6.0-py3-none-any.whl", hash = "sha256:a4eb26484f2c82589bd9a17c73d32a010b1e29d89f1604cd9bf3a2097b81bb5e"}, - {file = "rich-12.6.0.tar.gz", hash = "sha256:ba3a3775974105c221d31141f2c116f4fd65c5ceb0698657a11e9f295ec93fd0"}, + {file = "rich-13.3.5-py3-none-any.whl", hash = "sha256:69cdf53799e63f38b95b9bf9c875f8c90e78dd62b2f00c13a911c7a3b9fa4704"}, + {file = "rich-13.3.5.tar.gz", hash = "sha256:2d11b9b8dd03868f09b4fffadc84a6a8cda574e40dc90821bd845720ebb8e89c"}, ] [package.dependencies] -commonmark = ">=0.9.0,<0.10.0" -pygments = ">=2.6.0,<3.0.0" +markdown-it-py = ">=2.2.0,<3.0.0" +pygments = ">=2.13.0,<3.0.0" [package.extras] -jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"] +jupyter = ["ipywidgets (>=7.5.1,<9)"] [[package]] name = "setuptools" -version = "67.7.1" +version = "67.7.2" description = "Easily download, build, install, upgrade, and uninstall Python packages" category = "dev" optional = false python-versions = ">=3.7" files = [ - {file = "setuptools-67.7.1-py3-none-any.whl", hash = "sha256:6f0839fbdb7e3cfef1fc38d7954f5c1c26bf4eebb155a55c9bf8faf997b9fb67"}, - {file = "setuptools-67.7.1.tar.gz", hash = "sha256:bb16732e8eb928922eabaa022f881ae2b7cdcfaf9993ef1f5e841a96d32b8e0c"}, + {file = "setuptools-67.7.2-py3-none-any.whl", hash = "sha256:23aaf86b85ca52ceb801d32703f12d77517b2556af839621c641fca11287952b"}, + {file = "setuptools-67.7.2.tar.gz", hash = "sha256:f104fa03692a2602fa0fec6c6a9e63b6c8a968de13e17c026957dd1f53d80990"}, ] [package.extras] @@ -461,14 +482,14 @@ [[package]] name = "shellingham" -version = "1.5.0.post1" +version = "1.4.0" description = "Tool to Detect Surrounding Shell" -category = "main" +category = "dev" optional = false -python-versions = ">=3.7" +python-versions = "!=3.0,!=3.1,!=3.2,!=3.3,>=2.6" files = [ - {file = "shellingham-1.5.0.post1-py2.py3-none-any.whl", hash = "sha256:368bf8c00754fd4f55afb7bbb86e272df77e4dc76ac29dbcbb81a59e9fc15744"}, - {file = "shellingham-1.5.0.post1.tar.gz", hash = "sha256:823bc5fb5c34d60f285b624e7264f4dda254bc803a3774a147bf99c0e3004a28"}, + {file = "shellingham-1.4.0-py2.py3-none-any.whl", hash = "sha256:536b67a0697f2e4af32ab176c00a50ac2899c5a05e0d8e2dadac8e58888283f9"}, + {file = "shellingham-1.4.0.tar.gz", hash = "sha256:4855c2458d6904829bd34c299f11fdeed7cfefbf8a2c522e4caea6cd76b3171e"}, ] [[package]] @@ -484,18 +505,6 @@ ] [[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -category = "dev" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] - -[[package]] name = "typer" version = "0.7.0" description = "Typer, build great CLIs. Easy to code. Based on Python type hints." @@ -509,9 +518,6 @@ [package.dependencies] click = ">=7.1.1,<9.0.0" -colorama = {version = ">=0.4.3,<0.5.0", optional = true, markers = "extra == \"all\""} -rich = {version = ">=10.11.0,<13.0.0", optional = true, markers = "extra == \"all\""} -shellingham = {version = ">=1.3.0,<2.0.0", optional = true, markers = "extra == \"all\""} [package.extras] all = ["colorama (>=0.4.3,<0.5.0)", "rich (>=10.11.0,<13.0.0)", "shellingham (>=1.3.0,<2.0.0)"] @@ -520,6 +526,23 @@ test = ["black (>=22.3.0,<23.0.0)", "coverage (>=6.2,<7.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.910)", "pytest (>=4.4.0,<8.0.0)", "pytest-cov (>=2.10.0,<5.0.0)", "pytest-sugar (>=0.9.4,<0.10.0)", "pytest-xdist (>=1.32.0,<4.0.0)", "rich (>=10.11.0,<13.0.0)", "shellingham (>=1.3.0,<2.0.0)"] [[package]] +name = "typer-cli" +version = "0.0.13" +description = "Run Typer scripts with completion, without having to create a package, using Typer CLI." +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typer_cli-0.0.13-py3-none-any.whl", hash = "sha256:5ae0f99dce8f8f9669137a2c98eb42485cd4412e0ec225c8eb29ce8ac3378731"}, + {file = "typer_cli-0.0.13.tar.gz", hash = "sha256:f5b85764e56fb3fe835ed008ad5bc7db4961f7bcce1f1c1698ac46b6c5d9b86f"}, +] + +[package.dependencies] +colorama = ">=0.4.3,<=0.5.0" +shellingham = ">=1.3.2,<=1.4.0" +typer = ">=0.4.0,<=0.7.0" + +[[package]] name = "urllib3" version = "1.26.15" description = "HTTP library with thread-safe connection pooling, file post, and more." @@ -538,5 +561,5 @@ [metadata] lock-version = "2.0" -python-versions = ">=3.10,<3.12" -content-hash = "1bcafc1a0b862e4d4b1f8a235b6588c9be4ec5844f48195e0d52a036e130ca6d" +python-versions = ">=3.11,<3.12" +content-hash = "6e20d13961c61be2391b159dabcb1bbe32aef4ef41987f7509f2cc0503f60dce" diff --git a/pyproject.toml b/pyproject.toml index 60fe825..4f3135f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,16 +16,17 @@ version = "0.1.12" [tool.poetry.dependencies] -beautifulsoup4 = "^4.11.2" -python = ">=3.10,<3.12" -requests = "^2.28.2" -rich = "^12.0.0" -typer = { extras = ["all"], version = "^0.7.0" } +beautifulsoup4 = "^4.12.2" +python = ">=3.11,<3.12" +requests = "^2.29.0" +rich = "^13.3.5" +typer = "^0.7.0" [tool.poetry.group.dev.dependencies] -black = "^23.1.0" +black = "^23.3.0" isort = "^5.12.0" -pyinstaller = "^5.8.0" +pyinstaller = "^5.10.1" +typer-cli = "^0.0.13" [tool.poetry.scripts] thu-learn-downloader = "thu_learn_downloader.__main__:app" diff --git a/requirements.txt b/requirements.txt index c5e1a90..0288d64 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ -beautifulsoup4==4.12.2 ; python_version >= "3.10" and python_version < "3.12" -certifi==2022.12.7 ; python_version >= "3.10" and python_version < "3.12" -charset-normalizer==3.1.0 ; python_version >= "3.10" and python_version < "3.12" -click==8.1.3 ; python_version >= "3.10" and python_version < "3.12" -colorama==0.4.6 ; python_version >= "3.10" and python_version < "3.12" -commonmark==0.9.1 ; python_version >= "3.10" and python_version < "3.12" -idna==3.4 ; python_version >= "3.10" and python_version < "3.12" -pygments==2.15.1 ; python_version >= "3.10" and python_version < "3.12" -requests==2.28.2 ; python_version >= "3.10" and python_version < "3.12" -rich==12.6.0 ; python_version >= "3.10" and python_version < "3.12" -shellingham==1.5.0.post1 ; python_version >= "3.10" and python_version < "3.12" -soupsieve==2.4.1 ; python_version >= "3.10" and python_version < "3.12" -typer[all]==0.7.0 ; python_version >= "3.10" and python_version < "3.12" -urllib3==1.26.15 ; python_version >= "3.10" and python_version < "3.12" +beautifulsoup4==4.12.2 ; python_version >= "3.11" and python_version < "3.12" +certifi==2022.12.7 ; python_version >= "3.11" and python_version < "3.12" +charset-normalizer==3.1.0 ; python_version >= "3.11" and python_version < "3.12" +click==8.1.3 ; python_version >= "3.11" and python_version < "3.12" +colorama==0.4.6 ; python_version >= "3.11" and python_version < "3.12" and platform_system == "Windows" +idna==3.4 ; python_version >= "3.11" and python_version < "3.12" +markdown-it-py==2.2.0 ; python_version >= "3.11" and python_version < "3.12" +mdurl==0.1.2 ; python_version >= "3.11" and python_version < "3.12" +pygments==2.15.1 ; python_version >= "3.11" and python_version < "3.12" +requests==2.29.0 ; python_version >= "3.11" and python_version < "3.12" +rich==13.3.5 ; python_version >= "3.11" and python_version < "3.12" +soupsieve==2.4.1 ; python_version >= "3.11" and python_version < "3.12" +typer==0.7.0 ; python_version >= "3.11" and python_version < "3.12" +urllib3==1.26.15 ; python_version >= "3.11" and python_version < "3.12"