diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ce00c9d --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,79 @@ +# badge: https://github.com/xstatic-py/xstatic/workflows/CI/badge.svg?branch=master + +name: CI + +on: + push: + branches: [ master ] + paths: + - '**.py' + - '**.yml' + - '**.toml' + - '!docs/**' + pull_request: + branches: [ master ] + paths: + - '**.py' + - '**.yml' + - '**.toml' + - '!docs/**' + +jobs: + lint: + + runs-on: ubuntu-24.04 + timeout-minutes: 5 + + steps: + - uses: actions/checkout@v4 + - uses: chartboost/ruff-action@v1 + + 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' + + 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 diff --git a/AUTHORS.txt b/AUTHORS.rst similarity index 100% rename from AUTHORS.txt rename to AUTHORS.rst diff --git a/LICENSE.txt b/LICENSE.txt index 9a6033e..7b8a1ca 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ The MIT License (MIT) -Copyright (c) 2011-2018 Thomas Waldmann and -other contributors, see AUTHORS.txt. +Copyright (c) 2011-2025 Thomas Waldmann and +other contributors, see AUTHORS.rst. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MANIFEST.in b/MANIFEST.in index cd4db96..177de3a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,6 +1,6 @@ -include README.txt +include README.rst include LICENSE.txt -include AUTHORS.txt +include AUTHORS.rst recursive-include docs *.rst diff --git a/README.txt b/README.rst similarity index 100% rename from README.txt rename to README.rst diff --git a/docs/source/conf.py b/docs/source/conf.py index ff3e960..034d869 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # XStatic documentation build configuration file, created by # sphinx-quickstart on Fri Jun 24 01:34:29 2011. @@ -11,12 +10,12 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os - # 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. -#sys.path.insert(0, os.path.abspath('.')) +# import sys +# import os +# sys.path.insert(0, os.path.abspath('.')) # -- General configuration ----------------------------------------------------- @@ -40,17 +39,17 @@ master_doc = 'index' # General information about the project. -project = u'XStatic' -copyright = u'2011-2018, Thomas Waldmann' +project = 'XStatic' +copyright = '2011-2025, 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 = '1.0' +version = '2.0' # The full version, including alpha/beta/rc tags. -release = '1.0.1' +release = '2.0.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -178,8 +177,8 @@ # 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', u'XStatic Documentation', - u'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 @@ -211,8 +210,8 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'xstatic', u'XStatic Documentation', - [u'Thomas Waldmann'], 1) + ('index', 'xstatic', 'XStatic Documentation', + ['Thomas Waldmann'], 1) ] # -- Options for Texinfo output ------------------------------------------------ @@ -221,7 +220,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'XStatic', u'XStatic Documentation', u'Thomas Waldmann', + ('index', 'XStatic', 'XStatic Documentation', 'Thomas Waldmann', 'XStatic', 'One line description of project.', 'Miscellaneous'), ] diff --git a/docs/source/license.rst b/docs/source/license.rst index 27a23cf..904a300 100644 --- a/docs/source/license.rst +++ b/docs/source/license.rst @@ -6,5 +6,5 @@ License Authors ======= -.. include:: ../../AUTHORS.txt +.. include:: ../../AUTHORS.rst diff --git a/docs/source/packaging.rst b/docs/source/packaging.rst index 33e6a31..b63b5f8 100644 --- a/docs/source/packaging.rst +++ b/docs/source/packaging.rst @@ -122,12 +122,12 @@ You, as a package maintainer are interested in avoiding duplication, so that if you need to do a security update, you only need to fix in one place. XStatic-* packages support this. If you do not want to heavily patch some -Python software that uses XStatic ressource packages, you can alternatively +Python software that uses XStatic resource packages, you can alternatively just package the XStatic resource packages for your package system. In case that would add duplication (because you already have a package that provides the same static files), you can simply remove the static files below -data/ from the XStatic ressource package and adjust the path/filename so it +data/ from the XStatic resource package and adjust the path/filename so it points to the files provided by that other package. E.g. for the XStatic-jQuery package, change:: @@ -139,9 +139,9 @@ To:: BASE_DIR = '/usr/share/javascript/jquery' Of course you need to make sure that the files at the location you point to -are the same as the ones the XStatic ressource package provides below the +are the same as the ones the XStatic resource package provides below the data/ directory. -In your package dependencies for your repackaged XStatic ressource package +In your package dependencies for your repackaged XStatic resource package you would then just require (depend on) the package providing these files. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..de7740e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,40 @@ +# Copyright: 2011-2025 by the XStatic authors, see AUTHORS.rst for details. +# License: MIT license, see LICENSE.txt for details. + +[project] +name = "XStatic" +version = "2.0.0" +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" +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "Operating System :: OS Independent", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Archiving :: Packaging", + "Topic :: System :: Installation/Setup", + "Topic :: System :: Software Distribution", +] +keywords = ["xstatic", "static", "file", "resource", "python", "packages", "pypi", "require"] +license = "MIT" +dependencies = [] # there should never be a dependency! + +[project.urls] +"Homepage" = "https://github.com/xstatic-py/xstatic" + +[tool.setuptools] +# See also the MANIFEST.in file. +# We want to install all the files in the package directories. +include-package-data = true + +[tool.setuptools.packages.find] +where = ["src"] + +[build-system] +requires = ["setuptools", "wheel", ] +build-backend = "setuptools.build_meta" diff --git a/setup.py b/setup.py deleted file mode 100644 index b655222..0000000 --- a/setup.py +++ /dev/null @@ -1,48 +0,0 @@ -# Copyright: 2011-2018 by the XStatic authors, see AUTHORS.txt for details. -# License: MIT license, see LICENSE.txt for details. - -""" -XStatic - setup.py -""" - -import os - -from setuptools import setup, find_packages -import pkg_resources - -# The README.txt file should be written in reST so that PyPI can use -# it to generate your project's PyPI page. -readme_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'README.txt') - -with open(readme_path) as f: - long_description = f.read() - - -setup( - name='XStatic', - version='1.0.3', - description='XStatic base package with minimal support code', - long_description=long_description, - classifiers=[ - 'License :: OSI Approved :: MIT License', - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'Operating System :: OS Independent', - 'Programming Language :: Python', - 'Topic :: Software Development :: Libraries', - 'Topic :: System :: Archiving :: Packaging', - 'Topic :: System :: Installation/Setup', - 'Topic :: System :: Software Distribution', - ], - keywords="xstatic static file resource python packages setuptools pypi require", - author='Thomas Waldmann', - author_email='tw@waldmann-edv.de', - url='https://github.com/xstatic-py/xstatic', - license='MIT license', - packages=find_packages(), - namespace_packages=['xstatic', 'xstatic.pkg', ], - include_package_data=True, - zip_safe=False, - install_requires=[], # there should never be a dependency! -) - diff --git a/src/xstatic/__init__.py b/src/xstatic/__init__.py new file mode 100644 index 0000000..41bf875 --- /dev/null +++ b/src/xstatic/__init__.py @@ -0,0 +1,2 @@ +# Copyright: 2011-2025 by the XStatic authors, see AUTHORS.rst for details. +# License: MIT license, see LICENSE.txt for details. diff --git a/xstatic/main.py b/src/xstatic/main.py similarity index 89% rename from xstatic/main.py rename to src/xstatic/main.py index bcec803..efc43b2 100644 --- a/xstatic/main.py +++ b/src/xstatic/main.py @@ -1,11 +1,11 @@ -# Copyright: 2011-2018 by the XStatic authors, see AUTHORS.txt for details. +# Copyright: 2011-2025 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(object): +class XStatic: """ minimal support code to access resources from xstatic.pkg.* files or CDN locations. @@ -25,7 +25,7 @@ def __init__(self, module, root_url='/xstatic', provider='local', protocol='http ]) self.provider = provider if provider == 'local': - self.base_url = "%s/%s" % (root_url, self.name) + self.base_url = f"{root_url}/{self.name}" else: self.base_url = self.locations[(provider, protocol)] @@ -45,7 +45,7 @@ def url_for(self, path): """ loc = self.base_url if isinstance(loc, str): - loc = "%s/%s" % (loc, path) + loc = f"{loc}/{path}" elif isinstance(loc, dict): loc = loc[path] return loc diff --git a/xstatic/__init__.py b/xstatic/__init__.py deleted file mode 100644 index 28c0fc3..0000000 --- a/xstatic/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright: 2011-2018 by the XStatic authors, see AUTHORS.txt for details. -# License: MIT license, see LICENSE.txt for details. - -__import__('pkg_resources').declare_namespace(__name__) diff --git a/xstatic/pkg/__init__.py b/xstatic/pkg/__init__.py deleted file mode 100644 index 28c0fc3..0000000 --- a/xstatic/pkg/__init__.py +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright: 2011-2018 by the XStatic authors, see AUTHORS.txt for details. -# License: MIT license, see LICENSE.txt for details. - -__import__('pkg_resources').declare_namespace(__name__)