Skip to content

Commit

Permalink
fix: make sure that tutor-openedx is an empty package
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
regisb committed Jul 6, 2021
1 parent db5852e commit 8be574a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ __pycache__
/build/
/dist/
/release_description.md

# Copied at build-time
/tutor-openedx/tutoropenedx/__about__.py
12 changes: 9 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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)
Expand Down
Empty file added tutor-openedx/MANIFEST.in
Empty file.
3 changes: 3 additions & 0 deletions tutor-openedx/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
WARNING: This project has moved to https://pypi.org/project/tutor/. You should now install Tutor with::

pip install tutor
18 changes: 8 additions & 10 deletions setup-obsolete.py → tutor-openedx/setup.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -42,7 +38,7 @@ def load_about():
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=[
Expand All @@ -59,8 +55,10 @@ def load_about():
"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
""")
"""
)
Empty file.

0 comments on commit 8be574a

Please sign in to comment.