From 61802ac3c7f0fd81e6adf8b0c979270f0bd534c4 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 31 Mar 2023 07:06:45 -0600 Subject: [PATCH 1/6] setup a Makefile --- Makefile | 95 ++++++++++++++++++++++++++++++ openedx_plugin/scripts/init-db.sql | 7 +++ pyproject.toml | 1 - 3 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 Makefile create mode 100644 openedx_plugin/scripts/init-db.sql diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9eaf8aa --- /dev/null +++ b/Makefile @@ -0,0 +1,95 @@ +# ------------------------------------------------------------------------- +# build a package for PyPi +# ------------------------------------------------------------------------- +.PHONY: build requirements deps-update deps-init + +dev-db: + mysql -uroot -p < openedx_plugin_example/scripts/init-db.sql + +dev-up: + brew services start mysql + brew services start redis + +dev-down: + brew services stop mysql + brew services stop redis + +django-server: + ./manage.py runserver 0.0.0.0:8000 + +django-migrate: + ./manage.py migrate + ./manage.py makemigrations openedx_plugin_example + ./manage.py migrate openedx_plugin_example + +django-shell: + ./manage.py shell_plus + + +django-quickstart: + pre-commit install + make requirements + make dev-up + make dev-db + make django-migrate + ./manage.py createsuperuser + make django-server + +django-test: + ./manage.py test + +requirements: + pre-commit autoupdate + python -m pip install --upgrade pip wheel + pip-compile requirements/common.in + pip-compile requirements/local.in + pip install -r requirements/common.txt + pip install -r requirements/local.txt + +deps-init: + rm -rf .tox + python -m pip install --upgrade pip wheel + python -m pip install --upgrade -r requirements/common.txt -r requirements/local.txt -e . + python -m pip check + +deps-update: + python -m pip install --upgrade pip-tools pip wheel + python -m piptools compile --upgrade --resolver backtracking -o ./requirements/common.txt pyproject.toml + python -m piptools compile --extra dev --upgrade --resolver backtracking -o ./requirements/local.txt pyproject.toml + + +report: + cloc $(git ls-files) + + +build: + python3 -m pip install --upgrade setuptools wheel twine + python -m pip install --upgrade build + + if [ -d "./build" ]; then sudo rm -r build; fi + if [ -d "./dist" ]; then sudo rm -r dist; fi + if [ -d "./openedx_plugin_example.egg-info" ]; then sudo rm -r openedx_plugin_example.egg-info; fi + + python3 -m build --sdist ./ + python3 -m build --wheel ./ + + python3 -m pip install --upgrade twine + twine check dist/* + + +# ------------------------------------------------------------------------- +# upload to PyPi Test +# https:// ????? +# ------------------------------------------------------------------------- +release-test: + make build + twine upload --verbose --skip-existing --repository testpypi dist/* + + +# ------------------------------------------------------------------------- +# upload to PyPi +# https://pypi.org/project/openedx-plugin-example/ +# ------------------------------------------------------------------------- +release-prod: + make build + twine upload --verbose --skip-existing dist/* diff --git a/openedx_plugin/scripts/init-db.sql b/openedx_plugin/scripts/init-db.sql new file mode 100644 index 0000000..be70a95 --- /dev/null +++ b/openedx_plugin/scripts/init-db.sql @@ -0,0 +1,7 @@ +DROP USER IF EXISTS `mp_user`@`localhost`; +DROP DATABASE IF EXISTS `openedx_plugin_example`; + +CREATE USER `mp_user`@`localhost` IDENTIFIED BY 'mp'; +CREATE DATABASE `openedx_plugin_example`; +GRANT ALL PRIVILEGES ON `openedx_plugin_example`.* TO "mp_user"@"localhost"; +FLUSH PRIVILEGES; diff --git a/pyproject.toml b/pyproject.toml index f15f2db..698b4e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,7 +30,6 @@ authors = [ ] description = "A Django plugin to enhance feature set of base Open edX platform" readme = "README.md" -license = "GPL-3.0-or-later" requires-python = ">=3.8" classifiers = [ "Programming Language :: Python :: 3", From 666b8e74b3010af13ba3cade0e5e944138911110 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 31 Mar 2023 07:16:45 -0600 Subject: [PATCH 2/6] add a Makefile. bump versions to 0.2.0. refactor version modules --- CHANGELOG.md | 8 ++++++-- Makefile | 1 - __about__.py | 2 +- openedx_plugin/{version.py => __about__.py} | 2 +- openedx_plugin/apps.py | 2 +- openedx_plugin_api/{version.py => __about__.py} | 2 +- openedx_plugin_api/api.py | 2 +- openedx_plugin_api/apps.py | 2 +- openedx_plugin_cms/__about__.py | 2 ++ openedx_plugin_cms/apps.py | 2 +- openedx_plugin_cms/version.py | 2 -- openedx_plugin_mobile_api/{version.py => __about__.py} | 2 +- openedx_plugin_mobile_api/apps.py | 2 +- pyproject.toml | 2 +- 14 files changed, 18 insertions(+), 15 deletions(-) rename openedx_plugin/{version.py => __about__.py} (89%) rename openedx_plugin_api/{version.py => __about__.py} (89%) create mode 100644 openedx_plugin_cms/__about__.py delete mode 100644 openedx_plugin_cms/version.py rename openedx_plugin_mobile_api/{version.py => __about__.py} (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e4f154f..bca92ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [0.1.3] (2022-3-30) +## [0.2.0] (2022-3-31) + +- publish to PyPi + +## [0.1.3] (2023-3-30) - add AGPLv3 license - make xmodule imports backward compatible to nutmeg and earlier @@ -17,7 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - line entire code base for PEP 263 and B950 compliance - setup pyproject.toml for PyPi publishing -## [0.1.2] (2022-3-29) +## [0.1.2] (2023-3-29) - add a module level IS_READY boolean to prevent ready() from running multiple times during init diff --git a/Makefile b/Makefile index 9eaf8aa..373bc41 100644 --- a/Makefile +++ b/Makefile @@ -85,7 +85,6 @@ release-test: make build twine upload --verbose --skip-existing --repository testpypi dist/* - # ------------------------------------------------------------------------- # upload to PyPi # https://pypi.org/project/openedx-plugin-example/ diff --git a/__about__.py b/__about__.py index 4b80029..3725e73 100644 --- a/__about__.py +++ b/__about__.py @@ -3,7 +3,7 @@ # Increment this version number to trigger a new release. See # CHANGELOG.md for information on the versioning scheme. -__version__ = "0.1.3" +__version__ = "0.2.0" # The version suffix will be appended to the actual version, separated by a # dash. Use this suffix to differentiate between the actual released version and diff --git a/openedx_plugin/version.py b/openedx_plugin/__about__.py similarity index 89% rename from openedx_plugin/version.py rename to openedx_plugin/__about__.py index 8f1208b..9b901d1 100644 --- a/openedx_plugin/version.py +++ b/openedx_plugin/__about__.py @@ -7,4 +7,4 @@ usage: semantic version control for openedx_plugin """ -__version__ = "0.1.3" +__version__ = "0.2.0" diff --git a/openedx_plugin/apps.py b/openedx_plugin/apps.py index 25a15c8..e74430a 100644 --- a/openedx_plugin/apps.py +++ b/openedx_plugin/apps.py @@ -139,7 +139,7 @@ def ready(self): return from . import signals # pylint: disable=unused-import - from .version import __version__ + from .__about__ import __version__ from .waffle import waffle_init from .utils import PluginJSONEncoder diff --git a/openedx_plugin_api/version.py b/openedx_plugin_api/__about__.py similarity index 89% rename from openedx_plugin_api/version.py rename to openedx_plugin_api/__about__.py index 49d7c20..43af982 100644 --- a/openedx_plugin_api/version.py +++ b/openedx_plugin_api/__about__.py @@ -7,4 +7,4 @@ usage: version control for openedx_plugin_api plugin """ -__version__ = "0.1.1" +__version__ = "0.2.0" diff --git a/openedx_plugin_api/api.py b/openedx_plugin_api/api.py index b6e27b2..b716764 100644 --- a/openedx_plugin_api/api.py +++ b/openedx_plugin_api/api.py @@ -60,7 +60,7 @@ # our stuff from .utils import get_course_info from .models import CoursePoints -from .version import __version__ +from .__about__ import __version__ User = get_user_model() diff --git a/openedx_plugin_api/apps.py b/openedx_plugin_api/apps.py index 82b203b..0781044 100644 --- a/openedx_plugin_api/apps.py +++ b/openedx_plugin_api/apps.py @@ -62,7 +62,7 @@ def ready(self): return from . import signals # pylint: disable=unused-import - from .version import __version__ + from .__about__ import __version__ from .waffle import waffle_init log.info("{label} {version} is ready.".format(label=self.label, version=__version__)) diff --git a/openedx_plugin_cms/__about__.py b/openedx_plugin_cms/__about__.py new file mode 100644 index 0000000..7ce65b8 --- /dev/null +++ b/openedx_plugin_cms/__about__.py @@ -0,0 +1,2 @@ +# coding=utf-8 +__version__ = "0.2.0" diff --git a/openedx_plugin_cms/apps.py b/openedx_plugin_cms/apps.py index 42e4f6e..68aa14b 100644 --- a/openedx_plugin_cms/apps.py +++ b/openedx_plugin_cms/apps.py @@ -68,7 +68,7 @@ def ready(self): return from . import signals # pylint: disable=unused-import - from .version import __version__ + from .__about__ import __version__ from .waffle import waffle_init log.info("{label} {version} is ready.".format(label=self.label, version=__version__)) diff --git a/openedx_plugin_cms/version.py b/openedx_plugin_cms/version.py deleted file mode 100644 index 42910c3..0000000 --- a/openedx_plugin_cms/version.py +++ /dev/null @@ -1,2 +0,0 @@ -# coding=utf-8 -__version__ = "0.1.1" diff --git a/openedx_plugin_mobile_api/version.py b/openedx_plugin_mobile_api/__about__.py similarity index 90% rename from openedx_plugin_mobile_api/version.py rename to openedx_plugin_mobile_api/__about__.py index 8754943..01b6819 100644 --- a/openedx_plugin_mobile_api/version.py +++ b/openedx_plugin_mobile_api/__about__.py @@ -7,4 +7,4 @@ usage: semantic version control for openedx_plugin_mobile_api """ -__version__ = "0.1.1" +__version__ = "0.2.0" diff --git a/openedx_plugin_mobile_api/apps.py b/openedx_plugin_mobile_api/apps.py index beee083..fead502 100644 --- a/openedx_plugin_mobile_api/apps.py +++ b/openedx_plugin_mobile_api/apps.py @@ -68,7 +68,7 @@ def ready(self): if IS_READY: return - from .version import __version__ + from .__about__ import __version__ from .waffle import waffle_init log.info("{label} {version} is ready.".format(label=self.label, version=__version__)) diff --git a/pyproject.toml b/pyproject.toml index 698b4e0..4e8081e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ build-backend = "setuptools.build_meta:__legacy__" #------------------------------------------------------------------------------ [project] name = "openedx-plugin-example" -version = "0.1.3" +version = "0.2.0" authors = [ { name="Lawrence McDaniel", email="lpm0073@gmail.com" } ] From 58eab3226dcbb07acabc2e16b3bb1d7624fd1da8 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 31 Mar 2023 07:40:50 -0600 Subject: [PATCH 3/6] more meta data --- Makefile | 2 +- README.md | 5 +++++ pyproject.toml | 20 +++++++++++++++++--- setup.py | 3 ++- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 373bc41..8488a76 100644 --- a/Makefile +++ b/Makefile @@ -79,7 +79,7 @@ build: # ------------------------------------------------------------------------- # upload to PyPi Test -# https:// ????? +# https://test.pypi.org/project/openedx-plugin-example/0.2.0/ # ------------------------------------------------------------------------- release-test: make build diff --git a/README.md b/README.md index 84adb9c..3782c8a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,11 @@ # Open edX Plugin Examples [![hack.d Lawrence McDaniel](https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg)](https://lawrencemcdaniel.com) +[![Source code](https://img.shields.io/static/v1?logo=github&label=Git&style=flat-square&color=brightgreen&message=Source%20code)](https://github.com/cookiecutter-openedx/openedx-plugin-example) +[![Forums](https://img.shields.io/static/v1?logo=discourse&label=Forums&style=flat-square&color=ff0080&message=discuss.openedx.org)](https://discuss.openedx.org/tag/cookiecutter) +[![Documentation](https://img.shields.io/static/v1?logo=discourse&label=Forums&style=flat-square&color=ff0080&message=discuss.openedx.org)](https://github.com/cookiecutter-openedx/openedx-plugin-example) +[![PyPI releases](https://img.shields.io/pypi/v/openedx-plugin-example?logo=python&logoColor=white)](https://pypi.org/project/openedx-plugin-example) +[![AGPL License](https://img.shields.io/github/license/overhangio/tutor.svg?style=flat-square)](https://www.gnu.org/licenses/agpl-3.0.en.html) A curated collection of code samples for extending the functionality of an Open edX installation using its built-in plugin architecture. diff --git a/pyproject.toml b/pyproject.toml index 4e8081e..7835a20 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,9 +32,21 @@ description = "A Django plugin to enhance feature set of base Open edX platform" readme = "README.md" requires-python = ">=3.8" classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Development Status :: 4 - Beta", + "Framework :: Django", + "Framework :: Django :: 2.2", + "Framework :: Django :: 3.0", + "Framework :: Django :: 3.1", + "Framework :: Django :: 3.2", + "Intended Audience :: Developers", + "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", + "Natural Language :: English", "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Topic :: Education", + "Topic :: Education :: Computer Aided Instruction (CAI)", ] dependencies = [ "Django>=3.2,<=3.3", @@ -46,8 +58,10 @@ keywords = ["Python", "Django", "Open edX", "Plugin", "REST API"] [project.urls] Homepage = "https://github.com/cookiecutter-openedx/openedx-plugin-example" -"Bug Tracker" = "https://github.com/cookiecutter-openedx/openedx-plugin-example/issues" +Documentation = "https://github.com/cookiecutter-openedx/openedx-plugin-example" Repository = "https://github.com/cookiecutter-openedx/openedx-plugin-example" +Changelog = "https://github.com/cookiecutter-openedx/openedx-plugin-example/blob/main/CHANGELOG.md" +"Bug Tracker" = "https://github.com/cookiecutter-openedx/openedx-plugin-example/issues" #------------------------------------------------------------------------------ # see: https://setuptools.pypa.io/en/latest/userguide/dependency_management.html diff --git a/setup.py b/setup.py index 4d7a1f3..5a5fb92 100644 --- a/setup.py +++ b/setup.py @@ -100,8 +100,9 @@ def is_requirement(line) -> bool: "Intended Audience :: Developers", "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)", "Natural Language :: English", + "Operating System :: OS Independent", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Education", "Topic :: Education :: Computer Aided Instruction (CAI)", From 7ecc04c47e4694d236622cd53ab1b56c17b1893f Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 31 Mar 2023 07:43:54 -0600 Subject: [PATCH 4/6] more meta data --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3782c8a..2dd90fb 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ [![hack.d Lawrence McDaniel](https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg)](https://lawrencemcdaniel.com) [![Source code](https://img.shields.io/static/v1?logo=github&label=Git&style=flat-square&color=brightgreen&message=Source%20code)](https://github.com/cookiecutter-openedx/openedx-plugin-example) -[![Forums](https://img.shields.io/static/v1?logo=discourse&label=Forums&style=flat-square&color=ff0080&message=discuss.openedx.org)](https://discuss.openedx.org/tag/cookiecutter) -[![Documentation](https://img.shields.io/static/v1?logo=discourse&label=Forums&style=flat-square&color=ff0080&message=discuss.openedx.org)](https://github.com/cookiecutter-openedx/openedx-plugin-example) +[![Forums](https://img.shields.io/static/v1?logo=discourse&label=Forums&style=flat-square&color=000000&message=discuss.openedx.org)](https://discuss.openedx.org/tag/cookiecutter) +[![Documentation](https://img.shields.io/static/v1?&label=Documentation&style=flat-square&color=000000&message=Documentation)](https://github.com/cookiecutter-openedx/openedx-plugin-example) [![PyPI releases](https://img.shields.io/pypi/v/openedx-plugin-example?logo=python&logoColor=white)](https://pypi.org/project/openedx-plugin-example) [![AGPL License](https://img.shields.io/github/license/overhangio/tutor.svg?style=flat-square)](https://www.gnu.org/licenses/agpl-3.0.en.html) From 92287d1d0ce3deae689f02ab5a5d85b498a12927 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 31 Mar 2023 07:52:05 -0600 Subject: [PATCH 5/6] documentation --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2dd90fb..ad57c3c 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,23 @@ # Open edX Plugin Examples -[![hack.d Lawrence McDaniel](https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg)](https://lawrencemcdaniel.com) [![Source code](https://img.shields.io/static/v1?logo=github&label=Git&style=flat-square&color=brightgreen&message=Source%20code)](https://github.com/cookiecutter-openedx/openedx-plugin-example) [![Forums](https://img.shields.io/static/v1?logo=discourse&label=Forums&style=flat-square&color=000000&message=discuss.openedx.org)](https://discuss.openedx.org/tag/cookiecutter) [![Documentation](https://img.shields.io/static/v1?&label=Documentation&style=flat-square&color=000000&message=Documentation)](https://github.com/cookiecutter-openedx/openedx-plugin-example) [![PyPI releases](https://img.shields.io/pypi/v/openedx-plugin-example?logo=python&logoColor=white)](https://pypi.org/project/openedx-plugin-example) [![AGPL License](https://img.shields.io/github/license/overhangio/tutor.svg?style=flat-square)](https://www.gnu.org/licenses/agpl-3.0.en.html) +[![hack.d Lawrence McDaniel](https://img.shields.io/badge/hack.d-Lawrence%20McDaniel-orange.svg)](https://lawrencemcdaniel.com) A curated collection of code samples for extending the functionality of an Open edX installation using its built-in plugin architecture. Technical features that are showcased in this repo include: -* semantic version control -* pre-commit with linting by flake8 and black, both of which are configured to match the opinionated styling that you'll find in Open edX repositories +* Semantic version control +* Pre-commit with linting by flake8 and black, both of which are configured to match the opinionated styling that you'll find in Open edX repositories * pip configuration, requirements, constraints, setup.py, pyproject.toml * How to bundle multiple plugins in a single pip package * How to redirect Open edX urls in lms and cms to endpoints created in this plugin * How to automatically initialize Django model data during app startup -* adding unit tests to plugin code +* Adding unit tests to plugin code * Django app setup * Open edX Django configuration settings * Open edX Django urls @@ -32,6 +32,7 @@ Technical features that are showcased in this repo include: * Django manage.py custom commands * Python environment variables * Waffle flags +* Setting up your repo to publish to PyPi ## Open edX Plugins in this Repository From 879ee555565a78e3f0a89cd39f26d7132af5ec60 Mon Sep 17 00:00:00 2001 From: lpm0073 Date: Fri, 31 Mar 2023 07:54:21 -0600 Subject: [PATCH 6/6] release notes --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bca92ca..d1e03ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [0.2.0] (2022-3-31) - publish to PyPi +- add Makefile +- refactor version modules +- add shields to README +- add meta data to pyproject.toml ## [0.1.3] (2023-3-30)