diff --git a/.github/workflows/formatting_check.yml b/.github/workflows/formatting_check.yml index deb44d5..5a45479 100644 --- a/.github/workflows/formatting_check.yml +++ b/.github/workflows/formatting_check.yml @@ -10,4 +10,4 @@ jobs: - uses: actions/checkout@v3 - uses: paolorechia/pox@v1.0.1 with: - tox_env: "format_check" \ No newline at end of file + tox_env: "format_check" diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6f15a00..589c201 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -11,25 +11,25 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine + pip install build setuptools wheel twine - name: Build and publish env: TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} run: | - python setup.py sdist bdist_wheel + python -m build twine upload dist/* - - - name: Upload coverage report - uses: actions/upload-artifact@v2 + + - name: Upload dist folder + uses: actions/upload-artifact@v3 with: name: dist path: dist/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5aa8c61..0d52ef6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,16 +19,16 @@ jobs: python-version: 3.9 ext: .ps1 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - name: Setup Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip flake8 pytest pytest-cov - pip install -r requirements.txt + pip install . - name: Make configuration for tests env: @@ -43,9 +43,9 @@ jobs: - name: Test with pytest run: | pytest -m 'not slow' --verbose --cov=./bdfr/ --cov-report term:skip-covered --cov-report html - + - name: Upload coverage report - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: coverage_report path: htmlcov/ diff --git a/README.md b/README.md index 4b634ec..f732f6e 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,8 @@ python3 -m pipx install bdfr **To update BDFR**, run the above command again for pip or `pipx upgrade bdfr` for pipx installations. +**To check your version of BDFR**, run `bdfr --version` + **To install shell completions**, run `bdfr completions` ### AUR Package diff --git a/bdfr/__init__.py b/bdfr/__init__.py index e69de29..b482efe 100644 --- a/bdfr/__init__.py +++ b/bdfr/__init__.py @@ -0,0 +1 @@ +__version__ = "2.6.2" diff --git a/bdfr/__main__.py b/bdfr/__main__.py index d0c6664..57373c9 100644 --- a/bdfr/__main__.py +++ b/bdfr/__main__.py @@ -4,7 +4,9 @@ import logging import sys import click +import requests +from bdfr import __version__ from bdfr.archiver import Archiver from bdfr.cloner import RedditCloner from bdfr.completion import Completion @@ -74,8 +76,25 @@ def _add_options(opts: list): return wrap +def _check_version(context, param, value): + if not value or context.resilient_parsing: + return + current = __version__ + latest = requests.get("https://pypi.org/pypi/bdfr/json").json()["info"]["version"] + print(f"You are currently using v{current} the latest is v{latest}") + context.exit() + + @click.group() @click.help_option("-h", "--help") +@click.option( + "--version", + is_flag=True, + is_eager=True, + expose_value=False, + callback=_check_version, + help="Check version and exit.", +) def cli(): """BDFR is used to download and archive content from Reddit.""" pass diff --git a/bdfr/completion.py b/bdfr/completion.py index 1902319..8f4f122 100644 --- a/bdfr/completion.py +++ b/bdfr/completion.py @@ -12,7 +12,7 @@ class Completion: self.shell = shell self.env = os.environ.copy() self.share_dir = appdirs.user_data_dir() - self.entry_points = ["bdfr"] + self.entry_points = ["bdfr", "bdfr-archive", "bdfr-clone", "bdfr-download"] def install(self): if self.shell in ("all", "bash"): diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 34597e7..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -black -isort -pre-commit -pytest -tox diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index ea2d37f..72666e7 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -61,7 +61,7 @@ bdfr There are additional Python packages that are required to develop the BDFR. These can be installed with the following command: ```bash -python3 -m pip install -r dev-requirements.txt +python3 -m pip install -e .[dev] ``` ### Tools diff --git a/pyproject.toml b/pyproject.toml index 4dced2f..23ae690 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,82 @@ +[build-system] +requires = ["setuptools>=65.6.0", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "bdfr" +description = "Downloads and archives content from reddit" +readme = "README.md" +requires-python = ">=3.9" +license = {file = "LICENSE"} +keywords = ["reddit", "download", "archive",] +authors = [{name = "Ali Parlakci", email = "parlakciali@gmail.com"}] +maintainers = [{name = "Serene Arc", email = "serenical@gmail.com"}] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Console", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Natural Language :: English", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", +] +dependencies = [ + "appdirs>=1.4.4", + "beautifulsoup4>=4.10.0", + "click>=8.0.0", + "dict2xml>=1.7.0", + "praw>=7.2.0", + "pyyaml>=5.4.1", + "requests>=2.25.1", + "yt-dlp>=2022.11.11", +] +dynamic = ["version"] + +[tool.setuptools] +dynamic = {"version" = {attr = 'bdfr.__version__'}} +packages = ["bdfr", "bdfr.archive_entry", "bdfr.site_downloaders", "bdfr.site_downloaders.fallback_downloaders",] +data-files = {"config" = ["bdfr/default_config.cfg",]} + +[project.optional-dependencies] +dev = [ + "black>=22.10.0", + "isort>=5.10.1", + "pre-commit>=2.20.0", + "pytest>=7.1.0", + "tox>=3.27.1", +] + +[project.urls] +"Homepage" = "https://aliparlakci.github.io/bulk-downloader-for-reddit" +"Source" = "https://github.com/aliparlakci/bulk-downloader-for-reddit" +"Bug Reports" = "https://github.com/aliparlakci/bulk-downloader-for-reddit/issues" + +[project.scripts] +bdfr = "bdfr.__main__:cli" +bdfr-archive = "bdfr.__main__:cli_archive" +bdfr-clone = "bdfr.__main__:cli_clone" +bdfr-download = "bdfr.__main__:cli_download" + [tool.black] line-length = 120 [tool.isort] profile = "black" +py_version = 39 multi_line_output = 3 line_length = 120 +indent = 4 + +[tool.pytest.ini_options] +minversion = "7.1" +addopts = "--strict-markers" +testpaths = "tests" +markers = [ + "online: tests require a connection to the internet", + "reddit: tests require a connection to Reddit", + "slow: test is slow to run", + "authenticated: test requires an authenticated Reddit instance", + "testing: incomplete tests", +] diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 09df53c..0000000 --- a/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -[pytest] -addopts = --strict-markers -markers = - online: tests require a connection to the internet - reddit: tests require a connection to Reddit - slow: test is slow to run - authenticated: test requires an authenticated Reddit instance diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 62e6925..0000000 --- a/requirements.txt +++ /dev/null @@ -1,9 +0,0 @@ -appdirs>=1.4.4 -bs4>=0.0.1 -click>=7.1.2 -dict2xml>=1.7.0 -ffmpeg-python>=0.2.0 -praw>=7.2.0 -pyyaml>=5.4.1 -requests>=2.25.1 -yt-dlp>=2022.11.11 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index bb0ea60..0000000 --- a/setup.cfg +++ /dev/null @@ -1,26 +0,0 @@ -[metadata] -name = bdfr -description_file = README.md -description_content_type = text/markdown -home_page = https://github.com/aliparlakci/bulk-downloader-for-reddit -keywords = reddit, download, archive -version = 2.6.2 -author = Ali Parlakci -author_email = parlakciali@gmail.com -maintainer = Serene Arc -maintainer_email = serenical@gmail.com -license = GPLv3 -classifiers = - Programming Language :: Python :: 3 - License :: OSI Approved :: GNU General Public License v3 (GPLv3) - Natural Language :: English - Environment :: Console - Operating System :: OS Independent -platforms = any - -[files] -packages = bdfr - -[entry_points] -console_scripts = - bdfr = bdfr.__main__:cli diff --git a/setup.py b/setup.py deleted file mode 100644 index c5518a6..0000000 --- a/setup.py +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env python3 -# encoding=utf-8 - -from setuptools import setup - -setup(setup_requires=['pbr', 'appdirs'], pbr=True, data_files=[('config', ['bdfr/default_config.cfg'])], python_requires='>=3.9.0') diff --git a/tox.ini b/tox.ini index be451e6..01ece39 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,6 @@ [tox] +requires = + tox>=3.27.1 envlist = format format_check