From 8be574aac82f77861ae816213cf1d42645fe8fb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Behmo?= Date: Tue, 6 Jul 2021 09:42:57 +0200 Subject: [PATCH] fix: make sure that tutor-openedx is an empty package Previously, the tutor-openedx package was loading tons of template data from the MANIFEST.in. Turns out, we cannot ignore the MANIFEST.in file with setuptools. So we need to move tutor-openedx to a separate, dedicated folder. To auto-discover the package version, we copy it at runtime (in the make command). --- .gitignore | 3 +++ Makefile | 12 +++++++++--- tutor-openedx/MANIFEST.in | 0 tutor-openedx/README.rst | 3 +++ setup-obsolete.py => tutor-openedx/setup.py | 18 ++++++++---------- tutor-openedx/tutoropenedx/__init__.py | 0 6 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 tutor-openedx/MANIFEST.in create mode 100644 tutor-openedx/README.rst rename setup-obsolete.py => tutor-openedx/setup.py (86%) create mode 100644 tutor-openedx/tutoropenedx/__init__.py diff --git a/.gitignore b/.gitignore index 8e55cc4..347fc4d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ __pycache__ /build/ /dist/ /release_description.md + +# Copied at build-time +/tutor-openedx/tutoropenedx/__about__.py diff --git a/Makefile b/Makefile index ea4cfd5..9ddd9c3 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .DEFAULT_GOAL := help .PHONY: docs -SRC_DIRS = ./tutor ./tests ./bin +SRC_DIRS = ./tutor ./tests ./bin ./tutor-openedx BLACK_OPTS = --exclude templates ${SRC_DIRS} ###### Development @@ -18,9 +18,14 @@ upgrade-requirements: ## Upgrade requirements files pip-compile --upgrade requirements/dev.in pip-compile --upgrade requirements/docs.in -build-pythonpackage: ## Build a python package ready to upload to pypi +build-pythonpackage: build-pythonpackage-tutor build-pythonpackage-tutor-openedx ## Build python packages ready to upload to pypi + +build-pythonpackage-tutor: ## Build the "tutor" python package for upload to pypi python setup.py sdist - python setup-obsolete.py sdist + +build-pythonpackage-tutor-openedx: ## Build the obsolete "tutor-openedx" python package for upload to pypi + cp tutor/__about__.py tutor-openedx/tutoropenedx/ + cd tutor-openedx && python setup.py sdist --dist-dir ../dist push-pythonpackage: ## Push python package to pypi twine upload --skip-existing dist/tutor-$(shell make version).tar.gz @@ -42,6 +47,7 @@ test-types: ## Check type definitions test-pythonpackage: build-pythonpackage ## Test that package can be uploaded to pypi twine check dist/tutor-$(shell make version).tar.gz + twine check dist/tutor-openedx-$(shell make version).tar.gz format: ## Format code automatically black $(BLACK_OPTS) diff --git a/tutor-openedx/MANIFEST.in b/tutor-openedx/MANIFEST.in new file mode 100644 index 0000000..e69de29 diff --git a/tutor-openedx/README.rst b/tutor-openedx/README.rst new file mode 100644 index 0000000..5d4014e --- /dev/null +++ b/tutor-openedx/README.rst @@ -0,0 +1,3 @@ +WARNING: This project has moved to https://pypi.org/project/tutor/. You should now install Tutor with:: + + pip install tutor diff --git a/setup-obsolete.py b/tutor-openedx/setup.py similarity index 86% rename from setup-obsolete.py rename to tutor-openedx/setup.py index bbfe844..c9cf051 100644 --- a/setup-obsolete.py +++ b/tutor-openedx/setup.py @@ -1,24 +1,20 @@ import io import os import sys - from setuptools import setup HERE = os.path.abspath(os.path.dirname(__file__)) def load_readme(): - return """ -WARNING: This project has moved to https://pypi.org/project/tutor/. You should now install Tutor with:: - - pip install tutor - """ + with io.open(os.path.join(HERE, "README.rst"), "rt", encoding="utf8") as f: + return f.read() def load_about(): about = {} with io.open( - os.path.join(HERE, "tutor", "__about__.py"), "rt", encoding="utf-8" + os.path.join(HERE, "tutoropenedx", "__about__.py"), "rt", encoding="utf-8" ) as f: exec(f.read(), about) # pylint: disable=exec-used return about @@ -42,7 +38,7 @@ setup( description="The Docker-based Open edX distribution designed for peace of mind", long_description=load_readme(), long_description_content_type="text/x-rst", - packages=[], + packages=["tutoropenedx"], python_requires=">=3.5", install_requires=["tutor=={}".format(ABOUT["__version__"])], classifiers=[ @@ -59,8 +55,10 @@ setup( "Programming Language :: Python :: 3.10", ], ) -sys.stderr.write(""" +sys.stderr.write( + """ Installing Tutor from tutor-openedx is deprecated. You should instead install the "tutor" package with: pip install tutor -""") +""" +) diff --git a/tutor-openedx/tutoropenedx/__init__.py b/tutor-openedx/tutoropenedx/__init__.py new file mode 100644 index 0000000..e69de29