diff --git a/.github/workflows/manifest_loader_ci.yml b/.github/workflows/manifest_loader_ci.yml new file mode 100644 index 0000000..446616d --- /dev/null +++ b/.github/workflows/manifest_loader_ci.yml @@ -0,0 +1,49 @@ +name: Django Manifest Loader CI +on: + push: + branches: + - 'main' +jobs: + test-and-build: + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.9] + + env: + GOOGLE_APPLICATION_CREDENTIALS: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}' + GCR_REPO_NAME: '${{ secrets.GCR_REPO_NAME }}' + GCR_REPO_LOCATION: '${{ secrets.GCR_REPO_LOCATION }}' + GCR_SERVICE_ACCOUNT_EMAIL: '${{ secrets.GCR_SERVICE_ACCOUNT_EMAIL }}' + GC_PROJECT_ID: '${{ secrets.GC_PROJECT_ID }}' + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - id: 'auth' + name: 'Authenticate to Google Cloud' + uses: 'google-github-actions/auth@v0' + with: + credentials_json: '${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}' + - name: Google Cloud Artifact Registry Setup + run: | + gcloud config set artifacts/repository $GCR_REPO_NAME + gcloud config set artifacts/location $GCR_REPO_LOCATION + gcloud config set account $GCR_SERVICE_ACCOUNT_EMAIL + gcloud auth activate-service-account $GCR_SERVICE_ACCOUNT_EMAIL --key-file=$GOOGLE_APPLICATION_CREDENTIALS --project=$GC_PROJECT_ID + gcloud artifacts print-settings python > ~/.pypirc + mkdir -p ~/.config/pip + cp ~/.pypirc ~/.config/pip/pip.conf + - name: Install Python Dependencies + run: | + python -m pip install --upgrade pip + python -m pip install mistune==0.8.4 + python -m pip install m2r + python -m pip install -e .'[build]' + - name: Build Package and Upload + run: | + python setup.py sdist bdist_wheel + python -m twine upload --repository $GCR_REPO_NAME dist/* diff --git a/manifest_loader/utils.py b/manifest_loader/utils.py index 1376697..a323a06 100644 --- a/manifest_loader/utils.py +++ b/manifest_loader/utils.py @@ -1,5 +1,6 @@ import json import os +from urllib import request from django.templatetags.static import StaticNode from django.conf import settings @@ -70,7 +71,11 @@ def _get_manifest(): manifest_path = _find_manifest_path() try: - with open(manifest_path) as manifest_file: + if _is_url(manifest_path): + open_manifest = request.urlopen + else: + open_manifest = open + with open_manifest(manifest_path) as manifest_file: data = json.load(manifest_file) except FileNotFoundError: raise WebpackManifestNotFound(manifest_path) diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 4b38348..0000000 --- a/setup.cfg +++ /dev/null @@ -1,32 +0,0 @@ -[metadata] -name = django-manifest-loader -version = 1.0.0 -description = A Django app to load webpack assets. -long_description = file: README.md -url = https://www.github.com/shonin/django-manifest-loader -author = Shonin -author_email = emc@hey.com -license = BSD-3-Clause -keywords = django, webpack, manifest, loader -long_description_content_type = text/markdown -classifiers = - Environment :: Web Environment - Framework :: Django - Framework :: Django :: 3.1 - Intended Audience :: Developers - License :: OSI Approved :: BSD License - Operating System :: OS Independent - Programming Language :: Python - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Topic :: Internet :: WWW/HTTP - Topic :: Internet :: WWW/HTTP :: Dynamic Content - -[options] -include_package_data = true -packages = find: -install_requires = - django \ No newline at end of file diff --git a/setup.py b/setup.py index 6068493..78a78bf 100644 --- a/setup.py +++ b/setup.py @@ -1,3 +1,72 @@ -from setuptools import setup +from os import path +from setuptools import setup, find_packages -setup() + +readme_file = path.join(path.dirname(path.abspath(__file__)), 'README.md') + +try: + from m2r import parse_from_file + long_description = parse_from_file(readme_file) # Convert the file to RST for PyPI +except ImportError: + # m2r may not be installed in user environment + with open(readme_file) as f: + long_description = f.read() + + +package_metadata = { + 'name': 'tc-django-manifest-loader', + 'version': "1.0.3", + 'description': 'A Django app to load webpack assets.', + 'long_description': 'A Django app to load webpack assets.', + 'url': 'https://github.com/WhiteMoonDreamsInc/django-manifest-loader/', + 'author': 'Shonin', + 'author_email': 'emc@hey.com', + 'license': 'BSD-3-Clause', + 'classifiers': [ + 'Environment :: Web Environment' + 'Framework :: Django' + 'Framework :: Django :: 3.1' + 'Intended Audience :: Developers' + 'License :: OSI Approved :: BSD License' + 'Operating System :: OS Independent' + 'Programming Language :: Python' + 'Programming Language :: Python :: 3' + 'Programming Language :: Python :: 3 :: Only' + 'Programming Language :: Python :: 3.6' + 'Programming Language :: Python :: 3.7' + 'Programming Language :: Python :: 3.8' + 'Topic :: Internet :: WWW/HTTP' + 'Topic :: Internet :: WWW/HTTP :: Dynamic Content' + ], + 'keywords': ['django', 'webpack', 'manifest', 'loader'], +} + +setup( + packages=find_packages(), + package_data={'manifest_loader': ['templatetags/*']}, + include_package_data=True, + python_requires=">=3.6", + install_requires=[ + 'Django>=3.0,<4.0', + ], + extras_require={ + 'test': [], + 'prod': [], + 'build': [ + 'setuptools', + 'wheel', + 'twine', + 'm2r', + ], + 'docs': [ + 'recommonmark', + 'm2r', + 'django_extensions', + 'coverage', + 'Sphinx', + 'rstcheck', + 'sphinx-rtd-theme' + ], + }, + **package_metadata +) \ No newline at end of file