Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serving output directory from a cdn url #53

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from
Open
49 changes: 49 additions & 0 deletions .github/workflows/manifest_loader_ci.yml
Original file line number Diff line number Diff line change
@@ -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/*
7 changes: 6 additions & 1 deletion manifest_loader/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import os
from urllib import request

from django.templatetags.static import StaticNode
from django.conf import settings
Expand Down Expand Up @@ -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)
Expand Down
32 changes: 0 additions & 32 deletions setup.cfg

This file was deleted.

73 changes: 71 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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': '[email protected]',
'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
)