diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 21b3ded..b6c0e61 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -18,7 +18,7 @@ } }, - "postCreateCommand": "pip3 install --user -r requirements.txt -r docs/requirements.txt && pip install --editable .", + "postCreateCommand": "pip3 install -r docs/requirements.txt && pip install --editable .", "customizations": { "vscode": { diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5128a8c..7a8f4bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,7 @@ on: branches: [ "main" ] paths-ignore: - '**/*.md' + - '**/*.rst' - '**/*.txt' jobs: @@ -30,7 +31,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip pylint black mypy sphinx-lint - pip install -r requirements.txt + pip install . - name: Run Pylint run: | diff --git a/docs/source/conf.py b/docs/source/conf.py index 372d38d..b9a784c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -3,25 +3,50 @@ # For the full list of built-in configuration values, see the documentation: # https://www.sphinx-doc.org/en/master/usage/configuration.html +import os +import re +import sys +from datetime import datetime, timezone + # -- Path setup -------------------------------------------------------------- # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os -import sys + +docs_dir = os.path.dirname(os.path.dirname(__file__)) sys.path.insert(0, os.path.abspath('../..')) # -- Project information ----------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information +# Find the version and release information. +# We have a single source of truth for our version number: the __init__.py file. +# This next bit of code reads from it. +file_with_version = os.path.join(docs_dir, "..", "src", "instawebhooks", "__init__.py") +with open(file_with_version) as f: + for line in f: + m = re.match(r'__version__ = "(.*)"', line) + if m: + __version__ = m.group(1) + # The short X.Y version. + version = ".".join(__version__.split(".")[:2]) + # The full version, including alpha/beta/rc tags. + release = __version__ + break + else: # AKA no-break + version = release = "dev" + +print("version:", version) +print("release:", release) + project = 'InstaWebhooks' -copyright = '2024-2025, Ryan Luu' +copyright = f'2024-{datetime.now(tz=timezone.utc).year}, Ryan Luu' author = 'Ryan Luu' -release = '1.0' -version = '1.0.0' +version = ".".join(__version__.split(".")[:2]) +release = __version__ # -- General configuration --------------------------------------------------- # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration diff --git a/pyproject.toml b/pyproject.toml index 244903e..238baa8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,9 +4,8 @@ build-backend = "setuptools.build_meta" [project] name = "instawebhooks" -version = "0.1.3" description = "Discord webhooks for new Instagram posts from any profile" -readme = "README.md" +readme = "README.rst" requires-python = ">=3.8" keywords = ["webhooks", "feed", "embed", "Instagram", "Discord", "CLI"] authors = [ @@ -34,6 +33,7 @@ dependencies = [ "requests", "instaloader", ] +dynamic = ["version"] [project.urls] Homepage = "https://github.com/RyanLua/InstaWebhooks" @@ -46,6 +46,9 @@ Sponsor = "https://github.com/sponsors/RyanLua" [project.scripts] instawebhooks = "instawebhooks.__main__:main" +[tool.setuptools.dynamic] +version = {attr = "instawebhooks.__version__"} + [tool.isort] profile = "black" diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e3d9716..0000000 Binary files a/requirements.txt and /dev/null differ diff --git a/src/instawebhooks/__init__.py b/src/instawebhooks/__init__.py index 8babeac..32e8bdf 100644 --- a/src/instawebhooks/__init__.py +++ b/src/instawebhooks/__init__.py @@ -2,6 +2,9 @@ import sys +__version__ = "0.1.3" + + if __name__ == "__main__": from instawebhooks.__main__ import main