diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce00c9d..f31588e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,79 +1,74 @@ # badge: https://github.com/xstatic-py/xstatic/workflows/CI/badge.svg?branch=master - +--- name: CI - on: push: - branches: [ master ] + branches: ["master"] paths: - - '**.py' - - '**.yml' - - '**.toml' - - '!docs/**' + - '**.py' + - '**.yml' + - '**.toml' + - '!docs/**' pull_request: - branches: [ master ] + branches: ["master"] paths: - - '**.py' - - '**.yml' - - '**.toml' - - '!docs/**' + - '**.py' + - '**.yml' + - '**.toml' + - '!docs/**' jobs: lint: - runs-on: ubuntu-24.04 timeout-minutes: 5 - steps: - - uses: actions/checkout@v4 - - uses: chartboost/ruff-action@v1 + - uses: actions/checkout@v7 + - uses: astral-sh/ruff-action@v4.1.0 CI: - needs: lint strategy: fail-fast: false matrix: include: - - os: macos-latest - python-version: '3.9' - - os: ubuntu-24.04 - python-version: '3.10' - - os: ubuntu-24.04 - python-version: '3.11' - - os: ubuntu-24.04 - python-version: '3.12' - - os: ubuntu-24.04 - python-version: '3.13' - + - os: macos-latest + python-version: '3.11' + - os: macos-latest + python-version: '3.14' + - os: ubuntu-24.04 + python-version: '3.11' + - os: ubuntu-24.04 + python-version: '3.12' + - os: ubuntu-24.04 + python-version: '3.13' + - os: ubuntu-26.04 + python-version: '3.14' env: TOXENV: ${{ matrix.toxenv }} - runs-on: ${{ matrix.os }} timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install Python requirements - run: | - python -m pip install --upgrade pip setuptools wheel build - - name: try building a package - run: python -m build - - name: Install and import xstatic packages (modernize branch) - run: | - python -m venv venv - . venv/bin/activate - pip install . - pip install git+https://github.com/xstatic-py/xstatic-bootstrap.git@modernize - pip install git+https://github.com/xstatic-py/xstatic-font-awesome.git@modernize - python -c "import xstatic; print('Importing...')" - python -c "from xstatic.pkg import bootstrap as xs; assert xs.NAME == 'bootstrap'" - python -c "from xstatic.pkg import font_awesome as xs; assert xs.NAME == 'font_awesome'" - deactivate - rm -rf venv + - uses: actions/checkout@v7 + with: + fetch-depth: 0 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v7 + with: + python-version: ${{ matrix.python-version }} + - name: Install Python requirements + run: | + python -m pip install --upgrade pip setuptools wheel build + - name: try building a package + run: python -m build + - name: Install and import xstatic packages (modernize branch) + run: | + python -m venv venv + . venv/bin/activate + pip install . + pip install git+https://github.com/xstatic-py/xstatic-bootstrap.git@modernize + pip install git+https://github.com/xstatic-py/xstatic-font-awesome.git@modernize + python -c "import xstatic; print('Importing...')" + python -c "from xstatic.pkg import bootstrap as xs; assert xs.NAME == 'bootstrap'" + python -c "from xstatic.pkg import font_awesome as xs; assert xs.NAME == 'font_awesome'" + deactivate + rm -rf venv diff --git a/docs/source/conf.py b/docs/source/conf.py index 034d869..cc18ca2 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -20,199 +20,195 @@ # -- General configuration ----------------------------------------------------- # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.viewcode'] +extensions = ["sphinx.ext.todo", "sphinx.ext.coverage", "sphinx.ext.viewcode"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix of source filenames. -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = 'XStatic' -copyright = '2011-2025, Thomas Waldmann' +project = "XStatic" +copyright = "2011-2026, Thomas Waldmann" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = '2.0' +version = "2.0" # The full version, including alpha/beta/rc tags. -release = '2.0.0' +release = "2.0.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. -#language = None +# language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. exclude_patterns = [] # The reST default role (used for this markup: `text`) to use for all documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # -- Options for HTML output --------------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'default' +html_theme = "default" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = 'XStaticdoc' +htmlhelp_basename = "XStaticdoc" # -- Options for LaTeX output -------------------------------------------------- # The paper size ('letter' or 'a4'). -#latex_paper_size = 'letter' +# latex_paper_size = 'letter' # The font size ('10pt', '11pt' or '12pt'). -#latex_font_size = '10pt' +# latex_font_size = '10pt' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'XStatic.tex', 'XStatic Documentation', - 'Thomas Waldmann', 'manual'), + ("index", "XStatic.tex", "XStatic Documentation", "Thomas Waldmann", "manual"), ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Additional stuff for the LaTeX preamble. -#latex_preamble = '' +# latex_preamble = '' # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output -------------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - ('index', 'xstatic', 'XStatic Documentation', - ['Thomas Waldmann'], 1) -] +man_pages = [("index", "xstatic", "XStatic Documentation", ["Thomas Waldmann"], 1)] # -- Options for Texinfo output ------------------------------------------------ @@ -220,8 +216,15 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'XStatic', 'XStatic Documentation', 'Thomas Waldmann', - 'XStatic', 'One line description of project.', 'Miscellaneous'), + ( + "index", + "XStatic", + "XStatic Documentation", + "Thomas Waldmann", + "XStatic", + "One line description of project.", + "Miscellaneous", + ), ] # Documents to append as an appendix to all manuals. diff --git a/pyproject.toml b/pyproject.toml index de7740e..c0782ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,10 @@ -# Copyright: 2011-2025 by the XStatic authors, see AUTHORS.rst for details. +# Copyright: 2011-2026 by the XStatic authors, see AUTHORS.rst for details. # License: MIT license, see LICENSE.txt for details. +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + [project] name = "XStatic" version = "2.0.0" @@ -8,7 +12,7 @@ description = "XStatic base package with minimal support code" readme = {file="README.rst", content-type="text/x-rst"} authors = [{name="Thomas Waldmann", email="tw@waldmann-edv.de"}, ] maintainers = [{name="Thomas Waldmann", email="tw@waldmann-edv.de"}, ] -requires-python = ">=3.9" +requires-python = ">=3.11" classifiers = [ "Development Status :: 5 - Production/Stable", "Intended Audience :: Developers", @@ -34,7 +38,3 @@ include-package-data = true [tool.setuptools.packages.find] where = ["src"] - -[build-system] -requires = ["setuptools", "wheel", ] -build-backend = "setuptools.build_meta" diff --git a/src/xstatic/__init__.py b/src/xstatic/__init__.py index 41bf875..ea8c20f 100644 --- a/src/xstatic/__init__.py +++ b/src/xstatic/__init__.py @@ -1,2 +1,2 @@ -# Copyright: 2011-2025 by the XStatic authors, see AUTHORS.rst for details. +# Copyright: 2011-2026 by the XStatic authors, see AUTHORS.rst for details. # License: MIT license, see LICENSE.txt for details. diff --git a/src/xstatic/main.py b/src/xstatic/main.py index efc43b2..e0effed 100644 --- a/src/xstatic/main.py +++ b/src/xstatic/main.py @@ -1,16 +1,18 @@ -# Copyright: 2011-2025 by the XStatic authors, see AUTHORS.rst for details. +# Copyright: 2011-2026 by the XStatic authors, see AUTHORS.rst for details. # License: MIT license, see LICENSE.txt for details. """ XStatic - main package with minimal support code to work with static file packages """ + class XStatic: """ minimal support code to access resources from xstatic.pkg.* files or CDN locations. """ - def __init__(self, module, root_url='/xstatic', provider='local', protocol='http'): + + def __init__(self, module, root_url="/xstatic", provider="local", protocol="http"): """ :arg module: xstatic resource package/module, has metadata as attributes :arg root_url: the common root url path for all local xstatic @@ -19,12 +21,15 @@ def __init__(self, module, root_url='/xstatic', provider='local', protocol='http a name of another source (e.g. CDN) :arg protocol: 'http' (default) or 'https' """ - self.__dict__.update([(name.lower(), getattr(module, name)) - for name in dir(module) - if name.isupper() - ]) + self.__dict__.update( + [ + (name.lower(), getattr(module, name)) + for name in dir(module) + if name.isupper() + ] + ) self.provider = provider - if provider == 'local': + if provider == "local": self.base_url = f"{root_url}/{self.name}" else: self.base_url = self.locations[(provider, protocol)] @@ -34,7 +39,7 @@ def get_mapping(self): query the mapping url -> directory, use this to setup your own static file serving. """ - if self.provider == 'local': + if self.provider == "local": return self.base_url, self.base_dir def url_for(self, path): @@ -49,4 +54,3 @@ def url_for(self, path): elif isinstance(loc, dict): loc = loc[path] return loc -