Skip to content

Commit

Permalink
feat: migrate from setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
This is an attempt both to modernize the packaging and to fix mypy
testing in editable mode (issue #956).

Packaging seems to work, but mypy testing still fails. Will now attempt
to migrate from setuptools to hatch for building.
  • Loading branch information
regisb committed Nov 22, 2024
1 parent a666732 commit 1a7c096
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Print info about the current python installation
run: make ci-info
- name: Install requirements
run: make bootstrap-dev-plugins
run: make bootstrap-dev

##### Run tests, generate bundle
# - name: Run tests
Expand Down
20 changes: 7 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,17 @@ docs: ## Build HTML documentation
$(MAKE) -C docs

compile-requirements: ## Compile requirements files
pip-compile requirements/base.in
pip-compile requirements/dev.in
pip-compile requirements/docs.in
pip-compile ${COMPILE_OPTS} --output-file=requirements/base.txt
pip-compile ${COMPILE_OPTS} requirements/dev.in
pip-compile ${COMPILE_OPTS} --extra=docs --output-file=requirements/docs.txt

upgrade-requirements: ## Upgrade requirements files
pip-compile --upgrade requirements/base.in
pip-compile --upgrade requirements/dev.in
pip-compile --upgrade requirements/docs.in
$(MAKE) compile-requirements COMPILE_OPTS="--upgrade"

build-pythonpackage: build-pythonpackage-tutor ## 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 -m build --sdist

push-pythonpackage: ## Push python package to pypi
twine upload --skip-existing dist/tutor-$(shell make version).tar.gz
Expand Down Expand Up @@ -82,12 +80,8 @@ coverage-browse-report: coverage-html ## Open the HTML report in the browser
bundle: ## Bundle the tutor package in a single "dist/tutor" executable
pyinstaller tutor.spec

bootstrap-dev: ## Install dev requirements
pip install .
pip install -r requirements/dev.txt

bootstrap-dev-plugins: bootstrap-dev ## Install dev requirements and all supported plugins
pip install -r requirements/plugins.txt
bootstrap-dev: ## Install dev requirements and all supported plugins
pip install .[full,dev]

pull-base-images: # Manually pull base images
docker image pull docker.io/ubuntu:20.04
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Features

.. _readme_intro_end:

.. image:: ./docs/img/launch.webp
.. image:: https://github.com/overhangio/tutor/raw/master/docs/img/launch.webp
:alt: Tutor local launch
:target: https://www.terminalizer.com/view/3a8d55835686

Expand Down
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,51 @@
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
# https://setuptools.pypa.io/en/latest/userguide/quickstart.html

[project]
dynamic = ["version", "dependencies", "optional-dependencies"]
name = "tutor"
license = {file = "LICENSE.txt"}
authors = [
{name = "Edly", email = "[email protected]"},
]
description = "The Docker-based Open edX distribution designed for peace of mind"
readme = {file = "README.rst", content-type = "text/x-rst"}
requires-python = ">= 3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

[project.scripts]
tutor = "tutor.commands.cli:main"

# https://packaging.python.org/en/latest/specifications/well-known-project-urls/#well-known-labels
[project.urls]
Homepage = "https://docs.tutor.edly.io/"
Documentation = "https://docs.tutor.edly.io/"
Source = "https://github.com/overhangio/tutor"
Issues = "https://github.com/overhangio/tutor/issues"
Changelog = "https://github.com/overhangio/tutor/blob/master/CHANGELOG.md"
Community = "https://discuss.openedx.org/tag/tutor"

# Setuptools-specific configuration
[build-system]
requires = ["setuptools", "wheel"]

[tool.setuptools.dynamic]
version = {attr = "tutor.__about__.__package_version__"}
dependencies = {file = ["requirements/base.in"] }

[tool.setuptools.dynamic.optional-dependencies]
dev = {file = ["requirements/dev.txt"]}
full = {file = ["requirements/plugins.txt"]}

[tool.setuptools.packages.find]
exclude = ["tests*"]
32 changes: 14 additions & 18 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements/base.in
# pip-compile --output-file=requirements/base.txt
#
appdirs==1.4.4
# via -r requirements/base.in
# via tutor (pyproject.toml)
cachetools==5.5.0
# via google-auth
certifi==2024.8.30
Expand All @@ -15,47 +15,47 @@ certifi==2024.8.30
charset-normalizer==3.4.0
# via requests
click==8.1.7
# via -r requirements/base.in
# via tutor (pyproject.toml)
durationpy==0.9
# via kubernetes
google-auth==2.35.0
# via kubernetes
idna==3.10
# via requests
importlib-metadata==8.5.0
# via -r requirements/base.in
# via tutor (pyproject.toml)
importlib-resources==6.4.5
# via -r requirements/base.in
# via tutor (pyproject.toml)
jinja2==3.1.4
# via -r requirements/base.in
# via tutor (pyproject.toml)
kubernetes==31.0.0
# via -r requirements/base.in
# via tutor (pyproject.toml)
markupsafe==3.0.2
# via jinja2
mypy==1.13.0
# via -r requirements/base.in
# via tutor (pyproject.toml)
mypy-extensions==1.0.0
# via mypy
oauthlib==3.2.2
# via
# kubernetes
# requests-oauthlib
packaging==24.1
# via -r requirements/base.in
# via tutor (pyproject.toml)
pyasn1==0.6.1
# via
# pyasn1-modules
# rsa
pyasn1-modules==0.4.1
# via google-auth
pycryptodome==3.21.0
# via -r requirements/base.in
# via tutor (pyproject.toml)
python-dateutil==2.9.0.post0
# via kubernetes
pyyaml==6.0.2
# via
# -r requirements/base.in
# kubernetes
# tutor (pyproject.toml)
requests==2.32.3
# via
# kubernetes
Expand All @@ -68,19 +68,15 @@ six==1.16.0
# via
# kubernetes
# python-dateutil
tomli==2.0.2
# via mypy
typing-extensions==4.12.2
# via
# -r requirements/base.in
# mypy
# tutor (pyproject.toml)
urllib3==2.2.3
# via
# kubernetes
# requests
websocket-client==1.8.0
# via kubernetes
zipp==3.20.2
# via
# importlib-metadata
# importlib-resources
# via importlib-metadata
98 changes: 29 additions & 69 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,134 +1,105 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements/docs.in
# pip-compile --extra=docs --output-file=requirements/docs.txt
#
alabaster==0.7.16
# via sphinx
appdirs==1.4.4
# via -r requirements/base.txt
# via tutor (pyproject.toml)
babel==2.16.0
# via sphinx
cachetools==5.5.0
# via
# -r requirements/base.txt
# google-auth
# via google-auth
certifi==2024.8.30
# via
# -r requirements/base.txt
# kubernetes
# requests
charset-normalizer==3.4.0
# via
# -r requirements/base.txt
# requests
# via requests
click==8.1.7
# via
# -r requirements/base.txt
# sphinx-click
# tutor (pyproject.toml)
docutils==0.21.2
# via
# sphinx
# sphinx-click
# sphinx-rtd-theme
durationpy==0.9
# via
# -r requirements/base.txt
# kubernetes
# via kubernetes
google-auth==2.35.0
# via
# -r requirements/base.txt
# kubernetes
# via kubernetes
idna==3.10
# via
# -r requirements/base.txt
# requests
# via requests
imagesize==1.4.1
# via sphinx
importlib-metadata==8.5.0
# via
# -r requirements/base.txt
# sphinx
# via tutor (pyproject.toml)
importlib-resources==6.4.5
# via -r requirements/base.txt
# via tutor (pyproject.toml)
jinja2==3.1.4
# via
# -r requirements/base.txt
# sphinx
# tutor (pyproject.toml)
kubernetes==31.0.0
# via -r requirements/base.txt
# via tutor (pyproject.toml)
markupsafe==3.0.2
# via
# -r requirements/base.txt
# jinja2
# via jinja2
mypy==1.13.0
# via -r requirements/base.txt
# via tutor (pyproject.toml)
mypy-extensions==1.0.0
# via
# -r requirements/base.txt
# mypy
# via mypy
oauthlib==3.2.2
# via
# -r requirements/base.txt
# kubernetes
# requests-oauthlib
packaging==24.1
# via
# -r requirements/base.txt
# sphinx
# tutor (pyproject.toml)
pyasn1==0.6.1
# via
# -r requirements/base.txt
# pyasn1-modules
# rsa
pyasn1-modules==0.4.1
# via
# -r requirements/base.txt
# google-auth
# via google-auth
pycryptodome==3.21.0
# via -r requirements/base.txt
# via tutor (pyproject.toml)
pygments==2.18.0
# via sphinx
python-dateutil==2.9.0.post0
# via
# -r requirements/base.txt
# kubernetes
# via kubernetes
pyyaml==6.0.2
# via
# -r requirements/base.txt
# kubernetes
# tutor (pyproject.toml)
requests==2.32.3
# via
# -r requirements/base.txt
# kubernetes
# requests-oauthlib
# sphinx
requests-oauthlib==2.0.0
# via
# -r requirements/base.txt
# kubernetes
# via kubernetes
rsa==4.9
# via
# -r requirements/base.txt
# google-auth
# via google-auth
six==1.16.0
# via
# -r requirements/base.txt
# kubernetes
# python-dateutil
snowballstemmer==2.2.0
# via sphinx
sphinx==7.4.7
# via
# -r requirements/docs.in
# sphinx-click
# sphinx-rtd-theme
# sphinxcontrib-jquery
# tutor (pyproject.toml)
sphinx-click==6.0.0
# via -r requirements/docs.in
# via tutor (pyproject.toml)
sphinx-rtd-theme==3.0.1
# via -r requirements/docs.in
# via tutor (pyproject.toml)
sphinxcontrib-applehelp==2.0.0
# via sphinx
sphinxcontrib-devhelp==2.0.0
Expand All @@ -143,26 +114,15 @@ sphinxcontrib-qthelp==2.0.0
# via sphinx
sphinxcontrib-serializinghtml==2.0.0
# via sphinx
tomli==2.0.2
# via
# -r requirements/base.txt
# mypy
# sphinx
typing-extensions==4.12.2
# via
# -r requirements/base.txt
# mypy
# tutor (pyproject.toml)
urllib3==2.2.3
# via
# -r requirements/base.txt
# kubernetes
# requests
websocket-client==1.8.0
# via
# -r requirements/base.txt
# kubernetes
# via kubernetes
zipp==3.20.2
# via
# -r requirements/base.txt
# importlib-metadata
# importlib-resources
# via importlib-metadata
Loading

0 comments on commit 1a7c096

Please sign in to comment.