Skip to content

Commit aa5b5e1

Browse files
authored
Merge pull request #1 from idom-team/archmonger
organize for dist as pypi package
2 parents 182cbd6 + edeadbe commit aa5b5e1

37 files changed

+1043
-92
lines changed

.github/FUNDING.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# These are supported funding model platforms
2+
3+
github: [rmorshea]
4+
patreon: # Replace with a single Patreon username
5+
open_collective: # Replace with a single Open Collective username
6+
ko_fi: # Replace with a single Ko-fi username
7+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9+
liberapay: # Replace with a single Liberapay username
10+
issuehunt: # Replace with a single IssueHunt username
11+
otechie: # Replace with a single Otechie username
12+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: Documentation
4+
url: https://idom-docs.herokuapp.com/
5+
about: Refer to the documentation before starting a discussion
6+
- name: Community Support
7+
url: https://github.com/idom-team/idom/discussions
8+
about: Report issues, request features, and ask questions

.github/workflows/test.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
schedule:
11+
- cron: "0 0 * * *"
12+
13+
jobs:
14+
test-python-versions:
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.7, 3.8, 3.9]
19+
steps:
20+
- uses: actions/checkout@v2
21+
- uses: nanasess/setup-chromedriver@master
22+
- uses: actions/setup-node@v2-beta
23+
with:
24+
node-version: "14"
25+
- name: Use Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v2
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
- name: Install Python Dependencies
30+
run: pip install -r requirements/test-run.txt
31+
- name: Run Tests
32+
run: |
33+
npm install -g [email protected]
34+
nox -s test

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Django #
32
logs
43
*.log
@@ -61,6 +60,7 @@ pip-delete-this-directory.txt
6160
# Unit test / coverage reports
6261
htmlcov/
6362
.tox/
63+
.nox/
6464
.coverage
6565
.coverage.*
6666
.cache
@@ -125,4 +125,4 @@ GitHub.sublime-settings
125125
%SystemDrive%
126126

127127
# Mac file system
128-
.DS_Store
128+
.DS_Store

dj_idom/consumers.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

dj_idom/static/scripts.js

Lines changed: 0 additions & 40 deletions
This file was deleted.

dj_idom/templates/base.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

noxfile.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from __future__ import annotations
2+
3+
import os
4+
import re
5+
import subprocess
6+
from pathlib import Path
7+
from typing import List, Tuple
8+
9+
import nox
10+
from nox.sessions import Session
11+
12+
13+
HERE = Path(__file__).parent
14+
POSARGS_PATTERN = re.compile(r"^(\w+)\[(.+)\]$")
15+
16+
17+
@nox.session(reuse_venv=True)
18+
def manage(session: Session) -> None:
19+
session.install("-r", "requirements.txt")
20+
session.install("idom[stable]")
21+
session.install("-e", ".")
22+
session.chdir("tests")
23+
24+
build_js_on_commands = ["runserver"]
25+
if set(session.posargs).intersection(build_js_on_commands):
26+
session.run("python", "manage.py", "build_js")
27+
28+
session.run("python", "manage.py", *session.posargs)
29+
30+
31+
@nox.session(reuse_venv=True)
32+
def format(session: Session) -> None:
33+
install_requirements_file(session, "check-style")
34+
session.run("black", ".")
35+
session.run("isort", ".")
36+
37+
38+
@nox.session
39+
def test(session: Session) -> None:
40+
"""Run the complete test suite"""
41+
session.install("--upgrade", "pip", "setuptools", "wheel")
42+
session.notify("test_suite")
43+
session.notify("test_style")
44+
45+
46+
@nox.session
47+
def test_suite(session: Session) -> None:
48+
"""Run the Python-based test suite"""
49+
session.env["IDOM_DEBUG_MODE"] = "1"
50+
install_requirements_file(session, "test-env")
51+
session.install(".[all]")
52+
session.chdir("tests")
53+
session.run("figure-it-out")
54+
55+
56+
@nox.session
57+
def test_style(session: Session) -> None:
58+
"""Check that style guidelines are being followed"""
59+
install_requirements_file(session, "check-style")
60+
session.run("flake8", "src/django_idom", "tests")
61+
black_default_exclude = r"\.eggs|\.git|\.hg|\.mypy_cache|\.nox|\.tox|\.venv|\.svn|_build|buck-out|build|dist"
62+
session.run(
63+
"black",
64+
".",
65+
"--check",
66+
"--exclude",
67+
rf"/({black_default_exclude}|venv|node_modules)/",
68+
)
69+
session.run("isort", ".", "--check-only")
70+
71+
72+
def install_requirements_file(session: Session, name: str) -> None:
73+
file_path = HERE / "requirements" / (name + ".txt")
74+
assert file_path.exists(), f"requirements file {file_path} does not exist"
75+
session.install("-r", str(file_path))

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[build-system]
2+
requires = ["setuptools>=42", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.isort]
6+
multi_line_output = 3
7+
force_grid_wrap = 0
8+
use_parentheses = "True"
9+
ensure_newline_before_comments = "True"
10+
include_trailing_comma = "True"
11+
line_length = 88
12+
lines_after_imports = 2

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
django<4.0.0 # Django Library
2-
daphne<4.0.0 # Production ASGI webserver
3-
channels<4.0.0 # Django websocket features
4-
idom<1.0.0 # Python React
1+
-r requirements/pkg-deps.txt
2+
-r requirements/check-style.txt
3+
-r requirements/test-env.txt
4+
-r requirements/test-run.txt

requirements/check-style.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
black
2+
flake8
3+
isort

requirements/pkg-deps.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
channels<4.0.0 # Django websocket features
2+
idom<1.0.0 # Python React

requirements/test-env.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
django

requirements/test-run.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nox

setup.cfg

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[bdist_wheel]
2+
universal=1
3+
4+
[flake8]
5+
ignore = E203, E266, E501, W503, F811, N802
6+
max-line-length = 88
7+
max-complexity = 18
8+
select = B,C,E,F,W,T4,B9,N,ROH
9+
exclude =
10+
.eggs/*
11+
.nox/*

setup.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
import os
2+
import sys
3+
from pathlib import Path
4+
5+
from setuptools import find_packages, setup
6+
7+
8+
# the name of the project
9+
name = "django_idom"
10+
11+
# basic paths used to gather files
12+
root_dir = Path(__file__).parent
13+
src_dir = root_dir / "src"
14+
package_dir = src_dir / name
15+
16+
17+
# -----------------------------------------------------------------------------
18+
# Package Definition
19+
# -----------------------------------------------------------------------------
20+
21+
22+
package = {
23+
"name": name,
24+
"python_requires": ">=3.7",
25+
"packages": find_packages(str(src_dir)),
26+
"package_dir": {"": "src"},
27+
"description": "Control the web with Python",
28+
"author": "Ryan Morshead",
29+
"author_email": "[email protected]",
30+
"url": "https://github.com/idom-team/django-idom",
31+
"license": "MIT",
32+
"platforms": "Linux, Mac OS X, Windows",
33+
"keywords": ["interactive", "widgets", "DOM", "React"],
34+
"zip_safe": False,
35+
"classifiers": [
36+
"Framework :: Django",
37+
"Framework :: Django :: 3.1",
38+
"Framework :: Django :: 3.2",
39+
"Operating System :: OS Independent",
40+
"Intended Audience :: Developers",
41+
"Intended Audience :: Science/Research",
42+
"Topic :: Multimedia :: Graphics",
43+
"Programming Language :: Python :: 3.7",
44+
"Programming Language :: Python :: 3.8",
45+
"Programming Language :: Python :: 3.9",
46+
"Environment :: Web Environment",
47+
],
48+
}
49+
50+
51+
# -----------------------------------------------------------------------------
52+
# Library Version
53+
# -----------------------------------------------------------------------------
54+
55+
with open(os.path.join(package_dir, "__init__.py")) as f:
56+
for line in f.read().split("\n"):
57+
if line.startswith("__version__ = "):
58+
package["version"] = eval(line.split("=", 1)[1])
59+
break
60+
else:
61+
print("No version found in %s/__init__.py" % package_dir)
62+
sys.exit(1)
63+
64+
65+
# -----------------------------------------------------------------------------
66+
# Requirements
67+
# -----------------------------------------------------------------------------
68+
69+
70+
requirements = []
71+
with (root_dir / "requirements" / "pkg-deps.txt").open() as f:
72+
for line in map(str.strip, f):
73+
if not line.startswith("#"):
74+
requirements.append(line)
75+
package["install_requires"] = requirements
76+
77+
78+
# -----------------------------------------------------------------------------
79+
# Library Description
80+
# -----------------------------------------------------------------------------
81+
82+
83+
with (root_dir / "README.md").open() as f:
84+
long_description = f.read()
85+
86+
package["long_description"] = long_description
87+
package["long_description_content_type"] = "text/markdown"
88+
89+
90+
# -----------------------------------------------------------------------------
91+
# Install It
92+
# -----------------------------------------------------------------------------
93+
94+
95+
if __name__ == "__main__":
96+
setup(**package)

src/django_idom/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
__version__ = "0.0.1"
2+
3+
from .websocket_consumer import IdomAsyncWebSocketConsumer
4+
5+
__all__ = ["IdomAsyncWebSocketConsumer"]

0 commit comments

Comments
 (0)