1
0
Fork 0
mirror of synced 2024-05-05 12:52:35 +12:00

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: paolorechia/pox@v1.0.1
with:
tox_env: "format_check"
tox_env: "format_check"

View file

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

View file

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

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 check your version of BDFR**, run `bdfr --version`
**To install shell completions**, run `bdfr completions`
### AUR Package

View file

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

View file

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

View file

@ -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"):

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:
```bash
python3 -m pip install -r dev-requirements.txt
python3 -m pip install -e .[dev]
```
### 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]
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",
]

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]
requires =
tox>=3.27.1
envlist =
format
format_check