From af561b0ec9bf22182b132bc1d47b4a12cd0b9562 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 30 Apr 2026 15:53:39 -0400 Subject: [PATCH 1/2] refactor: move package source to src/ layout Moves sample_plugin/ into src/ to adopt the standard src-layout, which prevents accidental imports from the source tree during tests and fixes editable-install compatibility with mypy and other tools that rely on proper package discovery. - backend/sample_plugin/ moved to backend/src/sample_plugin/ - backend/pyproject.toml: add `where = ["src"]` to [tool.setuptools.packages.find] - backend/MANIFEST.in: update recursive-include path, remove stale requirements/ lines - backend/tox.ini: update quality tool invocations to use src/sample_plugin path Co-Authored-By: Claude Sonnet 4.6 --- backend/MANIFEST.in | 4 +--- backend/docs/conf.py | 4 ++-- backend/pyproject.toml | 1 + backend/{ => src}/sample_plugin/__init__.py | 0 backend/{ => src}/sample_plugin/apps.py | 0 backend/{ => src}/sample_plugin/conf/locale/config.yaml | 0 .../{ => src}/sample_plugin/migrations/0001_initial.py | 0 backend/{ => src}/sample_plugin/migrations/__init__.py | 0 backend/{ => src}/sample_plugin/models.py | 0 backend/{ => src}/sample_plugin/pipeline.py | 0 backend/{ => src}/sample_plugin/serializers.py | 0 backend/{ => src}/sample_plugin/settings/common.py | 0 backend/{ => src}/sample_plugin/settings/production.py | 0 backend/{ => src}/sample_plugin/settings/test.py | 0 backend/{ => src}/sample_plugin/signals.py | 0 .../sample_plugin/templates/sample_plugin/base.html | 0 backend/{ => src}/sample_plugin/urls.py | 0 backend/{ => src}/sample_plugin/views.py | 0 backend/tox.ini | 8 ++++---- 19 files changed, 8 insertions(+), 9 deletions(-) rename backend/{ => src}/sample_plugin/__init__.py (100%) rename backend/{ => src}/sample_plugin/apps.py (100%) rename backend/{ => src}/sample_plugin/conf/locale/config.yaml (100%) rename backend/{ => src}/sample_plugin/migrations/0001_initial.py (100%) rename backend/{ => src}/sample_plugin/migrations/__init__.py (100%) rename backend/{ => src}/sample_plugin/models.py (100%) rename backend/{ => src}/sample_plugin/pipeline.py (100%) rename backend/{ => src}/sample_plugin/serializers.py (100%) rename backend/{ => src}/sample_plugin/settings/common.py (100%) rename backend/{ => src}/sample_plugin/settings/production.py (100%) rename backend/{ => src}/sample_plugin/settings/test.py (100%) rename backend/{ => src}/sample_plugin/signals.py (100%) rename backend/{ => src}/sample_plugin/templates/sample_plugin/base.html (100%) rename backend/{ => src}/sample_plugin/urls.py (100%) rename backend/{ => src}/sample_plugin/views.py (100%) diff --git a/backend/MANIFEST.in b/backend/MANIFEST.in index e10fcc6..b47ddd8 100644 --- a/backend/MANIFEST.in +++ b/backend/MANIFEST.in @@ -1,5 +1,3 @@ include LICENSE.txt include README.md -include requirements/base.in -include requirements/constraints.txt -recursive-include sample_plugin *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg +recursive-include src/sample_plugin *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg diff --git a/backend/docs/conf.py b/backend/docs/conf.py index 798bfce..446cb06 100644 --- a/backend/docs/conf.py +++ b/backend/docs/conf.py @@ -522,8 +522,8 @@ def on_init(app): # pylint: disable=unused-argument # If we are, assemble the path manually bin_path = os.path.abspath(os.path.join(sys.prefix, 'bin')) apidoc_path = os.path.join(bin_path, apidoc_path) - check_call([apidoc_path, '-o', docs_path, os.path.join(root_path, 'sample_plugin'), - os.path.join(root_path, 'sample_plugin/migrations')]) + check_call([apidoc_path, '-o', docs_path, os.path.join(root_path, 'src/sample_plugin'), + os.path.join(root_path, 'src/sample_plugin/migrations')]) def setup(app): diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 96d1c47..09bda4b 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -95,6 +95,7 @@ dev = [ readme = {file = ["README.md"], content-type = "text/markdown" } [tool.setuptools.packages.find] +where = ["src"] include = ["sample_plugin*"] exclude = ["sample_plugin.tests*"] diff --git a/backend/sample_plugin/__init__.py b/backend/src/sample_plugin/__init__.py similarity index 100% rename from backend/sample_plugin/__init__.py rename to backend/src/sample_plugin/__init__.py diff --git a/backend/sample_plugin/apps.py b/backend/src/sample_plugin/apps.py similarity index 100% rename from backend/sample_plugin/apps.py rename to backend/src/sample_plugin/apps.py diff --git a/backend/sample_plugin/conf/locale/config.yaml b/backend/src/sample_plugin/conf/locale/config.yaml similarity index 100% rename from backend/sample_plugin/conf/locale/config.yaml rename to backend/src/sample_plugin/conf/locale/config.yaml diff --git a/backend/sample_plugin/migrations/0001_initial.py b/backend/src/sample_plugin/migrations/0001_initial.py similarity index 100% rename from backend/sample_plugin/migrations/0001_initial.py rename to backend/src/sample_plugin/migrations/0001_initial.py diff --git a/backend/sample_plugin/migrations/__init__.py b/backend/src/sample_plugin/migrations/__init__.py similarity index 100% rename from backend/sample_plugin/migrations/__init__.py rename to backend/src/sample_plugin/migrations/__init__.py diff --git a/backend/sample_plugin/models.py b/backend/src/sample_plugin/models.py similarity index 100% rename from backend/sample_plugin/models.py rename to backend/src/sample_plugin/models.py diff --git a/backend/sample_plugin/pipeline.py b/backend/src/sample_plugin/pipeline.py similarity index 100% rename from backend/sample_plugin/pipeline.py rename to backend/src/sample_plugin/pipeline.py diff --git a/backend/sample_plugin/serializers.py b/backend/src/sample_plugin/serializers.py similarity index 100% rename from backend/sample_plugin/serializers.py rename to backend/src/sample_plugin/serializers.py diff --git a/backend/sample_plugin/settings/common.py b/backend/src/sample_plugin/settings/common.py similarity index 100% rename from backend/sample_plugin/settings/common.py rename to backend/src/sample_plugin/settings/common.py diff --git a/backend/sample_plugin/settings/production.py b/backend/src/sample_plugin/settings/production.py similarity index 100% rename from backend/sample_plugin/settings/production.py rename to backend/src/sample_plugin/settings/production.py diff --git a/backend/sample_plugin/settings/test.py b/backend/src/sample_plugin/settings/test.py similarity index 100% rename from backend/sample_plugin/settings/test.py rename to backend/src/sample_plugin/settings/test.py diff --git a/backend/sample_plugin/signals.py b/backend/src/sample_plugin/signals.py similarity index 100% rename from backend/sample_plugin/signals.py rename to backend/src/sample_plugin/signals.py diff --git a/backend/sample_plugin/templates/sample_plugin/base.html b/backend/src/sample_plugin/templates/sample_plugin/base.html similarity index 100% rename from backend/sample_plugin/templates/sample_plugin/base.html rename to backend/src/sample_plugin/templates/sample_plugin/base.html diff --git a/backend/sample_plugin/urls.py b/backend/src/sample_plugin/urls.py similarity index 100% rename from backend/sample_plugin/urls.py rename to backend/src/sample_plugin/urls.py diff --git a/backend/sample_plugin/views.py b/backend/src/sample_plugin/views.py similarity index 100% rename from backend/sample_plugin/views.py rename to backend/src/sample_plugin/views.py diff --git a/backend/tox.ini b/backend/tox.ini index fc3361b..9523b16 100644 --- a/backend/tox.ini +++ b/backend/tox.ini @@ -76,11 +76,11 @@ allowlist_externals = touch commands = touch tests/__init__.py - pylint sample_plugin tests test_utils manage.py + pylint src/sample_plugin tests test_utils manage.py rm tests/__init__.py - pycodestyle sample_plugin tests manage.py - pydocstyle sample_plugin tests manage.py - isort --check-only --diff tests test_utils sample_plugin manage.py test_settings.py + pycodestyle src/sample_plugin tests manage.py + pydocstyle src/sample_plugin tests manage.py + isort --check-only --diff tests test_utils src/sample_plugin manage.py test_settings.py make selfcheck [testenv:pii_check] From e87b157256cb2368ea905e4e050f659709245282 Mon Sep 17 00:00:00 2001 From: Kyle D McCormick Date: Mon, 4 May 2026 14:04:27 -0400 Subject: [PATCH 2/2] build: Review comments --- backend/MANIFEST.in | 3 --- backend/pyproject.toml | 8 +++++--- backend/src/sample_plugin/py.typed | 0 tutor/pyproject.toml | 1 + 4 files changed, 6 insertions(+), 6 deletions(-) delete mode 100644 backend/MANIFEST.in create mode 100644 backend/src/sample_plugin/py.typed diff --git a/backend/MANIFEST.in b/backend/MANIFEST.in deleted file mode 100644 index b47ddd8..0000000 --- a/backend/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include LICENSE.txt -include README.md -recursive-include src/sample_plugin *.html *.png *.gif *.js *.css *.jpg *.jpeg *.svg diff --git a/backend/pyproject.toml b/backend/pyproject.toml index 09bda4b..7b720df 100644 --- a/backend/pyproject.toml +++ b/backend/pyproject.toml @@ -6,7 +6,8 @@ build-backend = "setuptools.build_meta" name = "openedx-sample-plugin" description = "A sample backend plugin for the Open edX Platform" requires-python = ">=3.12" -license="Apache-2.0" +license = "Apache-2.0" +license-files = ["LICENSE*"] authors = [ {name = "Open edX Project", email = "oscm@openedx.org"}, ] @@ -91,13 +92,14 @@ dev = [ "edx-i18n-tools", ] +[tool.setuptools] +include-package-data = true + [tool.setuptools.dynamic] readme = {file = ["README.md"], content-type = "text/markdown" } [tool.setuptools.packages.find] where = ["src"] -include = ["sample_plugin*"] -exclude = ["sample_plugin.tests*"] [tool.semantic_release] # We use SETUPTOOLS_SCM_PRETEND_VERSION to pull the version from python-semantic-release instead diff --git a/backend/src/sample_plugin/py.typed b/backend/src/sample_plugin/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/tutor/pyproject.toml b/tutor/pyproject.toml index 00e8877..2852ef6 100644 --- a/tutor/pyproject.toml +++ b/tutor/pyproject.toml @@ -7,6 +7,7 @@ name = "tutor-contrib-sample-plugin" description = "Tutor plugin for the Open edX Sample Plugin" requires-python = ">=3.11" license = "Apache-2.0" +license-files = ["LICENSE*"] authors = [ {name = "Open edX Project", email = "oscm@openedx.org"}, ]