Skip to content

Commit

Permalink
Merge pull request #11 from cookiecutter-openedx/mcdaniel_20230331
Browse files Browse the repository at this point in the history
publish to PyPi
  • Loading branch information
lpm0073 authored Mar 31, 2023
2 parents 1e061cc + 879ee55 commit 18c788d
Show file tree
Hide file tree
Showing 17 changed files with 151 additions and 22 deletions.
12 changes: 10 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,15 @@ 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
- add Makefile
- refactor version modules
- add shields to README
- add meta data to pyproject.toml

## [0.1.3] (2023-3-30)

- add AGPLv3 license
- make xmodule imports backward compatible to nutmeg and earlier
Expand All @@ -17,7 +25,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

Expand Down
94 changes: 94 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# -------------------------------------------------------------------------
# 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://test.pypi.org/project/openedx-plugin-example/0.2.0/
# -------------------------------------------------------------------------
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/*
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# Open edX Plugin Examples

[![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
Expand All @@ -27,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

Expand Down
2 changes: 1 addition & 1 deletion __about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion openedx_plugin/version.py → openedx_plugin/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
usage: semantic version control for openedx_plugin
"""
__version__ = "0.1.3"
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion openedx_plugin/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions openedx_plugin/scripts/init-db.sql
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
usage: version control for openedx_plugin_api plugin
"""
__version__ = "0.1.1"
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion openedx_plugin_api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion openedx_plugin_api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
2 changes: 2 additions & 0 deletions openedx_plugin_cms/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# coding=utf-8
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion openedx_plugin_cms/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
2 changes: 0 additions & 2 deletions openedx_plugin_cms/version.py

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
usage: semantic version control for openedx_plugin_mobile_api
"""
__version__ = "0.1.1"
__version__ = "0.2.0"
2 changes: 1 addition & 1 deletion openedx_plugin_mobile_api/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__))
Expand Down
23 changes: 18 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,29 @@ build-backend = "setuptools.build_meta:__legacy__"
#------------------------------------------------------------------------------
[project]
name = "openedx-plugin-example"
version = "0.1.3"
version = "0.2.0"
authors = [
{ name="Lawrence McDaniel", email="[email protected]" }
]
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",
"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",
Expand All @@ -47,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
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down

0 comments on commit 18c788d

Please sign in to comment.