Consolidate to pyproject

Consolidates configs to pyproject.toml and updates workflows accordingly as well as sets sane minimums for dev requirements.

adds version check to main script.
This commit is contained in:
OMEGARAZER 2022-12-16 23:45:36 -05:00
parent d0da9be376
commit 8c01a9e7a0
No known key found for this signature in database
GPG Key ID: D89925310D306E35
15 changed files with 114 additions and 68 deletions

View File

@ -10,4 +10,4 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: paolorechia/pox@v1.0.1 - uses: paolorechia/pox@v1.0.1
with: with:
tox_env: "format_check" tox_env: "format_check"

View File

@ -11,25 +11,25 @@ jobs:
deploy: deploy:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: '3.9' python-version: '3.9'
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip python -m pip install --upgrade pip
pip install setuptools wheel twine pip install build setuptools wheel twine
- name: Build and publish - name: Build and publish
env: env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: | run: |
python setup.py sdist bdist_wheel python -m build
twine upload dist/* twine upload dist/*
- name: Upload coverage report - name: Upload dist folder
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: dist name: dist
path: dist/ path: dist/

View File

@ -19,16 +19,16 @@ jobs:
python-version: 3.9 python-version: 3.9
ext: .ps1 ext: .ps1
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v3
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v2 uses: actions/setup-python@v4
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Install dependencies - name: Install dependencies
run: | run: |
python -m pip install --upgrade pip flake8 pytest pytest-cov python -m pip install --upgrade pip flake8 pytest pytest-cov
pip install -r requirements.txt pip install .
- name: Make configuration for tests - name: Make configuration for tests
env: env:
@ -43,9 +43,9 @@ jobs:
- name: Test with pytest - name: Test with pytest
run: | run: |
pytest -m 'not slow' --verbose --cov=./bdfr/ --cov-report term:skip-covered --cov-report html pytest -m 'not slow' --verbose --cov=./bdfr/ --cov-report term:skip-covered --cov-report html
- name: Upload coverage report - name: Upload coverage report
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: coverage_report name: coverage_report
path: htmlcov/ path: htmlcov/

View File

@ -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 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` **To install shell completions**, run `bdfr completions`
### AUR Package ### AUR Package

View File

@ -0,0 +1 @@
__version__ = "2.6.2"

View File

@ -4,7 +4,9 @@ import logging
import sys import sys
import click import click
import requests
from bdfr import __version__
from bdfr.archiver import Archiver from bdfr.archiver import Archiver
from bdfr.cloner import RedditCloner from bdfr.cloner import RedditCloner
from bdfr.completion import Completion from bdfr.completion import Completion
@ -74,8 +76,25 @@ def _add_options(opts: list):
return wrap 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.group()
@click.help_option("-h", "--help") @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(): def cli():
"""BDFR is used to download and archive content from Reddit.""" """BDFR is used to download and archive content from Reddit."""
pass pass

View File

@ -12,7 +12,7 @@ class Completion:
self.shell = shell self.shell = shell
self.env = os.environ.copy() self.env = os.environ.copy()
self.share_dir = appdirs.user_data_dir() self.share_dir = appdirs.user_data_dir()
self.entry_points = ["bdfr"] self.entry_points = ["bdfr", "bdfr-archive", "bdfr-clone", "bdfr-download"]
def install(self): def install(self):
if self.shell in ("all", "bash"): if self.shell in ("all", "bash"):

View File

@ -1,5 +0,0 @@
black
isort
pre-commit
pytest
tox

View File

@ -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: There are additional Python packages that are required to develop the BDFR. These can be installed with the following command:
```bash ```bash
python3 -m pip install -r dev-requirements.txt python3 -m pip install -e .[dev]
``` ```
### Tools ### Tools

View File

@ -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] [tool.black]
line-length = 120 line-length = 120
[tool.isort] [tool.isort]
profile = "black" profile = "black"
py_version = 39
multi_line_output = 3 multi_line_output = 3
line_length = 120 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",
]

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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')

View File

@ -1,4 +1,6 @@
[tox] [tox]
requires =
tox>=3.27.1
envlist = envlist =
format format
format_check format_check