Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade: replace deprecated pkg_resources with importlib, resolves #966 #977

Conversation

Abdul-Muqadim-Arbisoft
Copy link
Contributor

Description:

This PR addresses the issue reported in Issue #966, where Tutor was facing compatibility problems with Python 3.12, particularly when using plugins. The root cause was identified as the continued use of the pkg_resources module, which is not available in Python 3.12 environments without explicit installation of setuptools.

Problem:

  • pkg_resources module deprecated due to availability of better alternatives.
  • Tutor claims support for Python 3.12 in setup.py classifiers.
  • When using Python 3.12, specifically in environments without setuptools, the usage of pkg_resources causes a ModuleNotFoundError.

Solution:

  • Replaced deprecated pkg_resources with modern importlib functionalities, aligning with Python's standard practices and enhancing compatibility.
  • Ensured that this change addresses the issue without affecting the existing functionalities of Tutor.

Testing:

  • Steps to reproduce the issue were followed as described in the original problem statement.
  • Verified that after replacing pkg_resources with importlib, Tutor plugins enable and work correctly in a Python 3.12 virtual environment and in all environments made of python3.8 and above .
  • Ran existing tests to ensure no other part of Tutor is adversely affected by this change.

@Abdul-Muqadim-Arbisoft Abdul-Muqadim-Arbisoft removed the request for review from regisb January 11, 2024 13:52
@Abdul-Muqadim-Arbisoft Abdul-Muqadim-Arbisoft marked this pull request as draft January 11, 2024 14:02
@regisb regisb marked this pull request as ready for review January 12, 2024 11:43
tutor/env.py Outdated Show resolved Hide resolved
tutor/env.py Outdated Show resolved Hide resolved
tutor/plugins/v0.py Outdated Show resolved Hide resolved
requirements/base.in Show resolved Hide resolved
@regisb regisb assigned regisb and unassigned regisb Jan 30, 2024
Copy link
Contributor

@regisb regisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Could you please just add a changelog entry? https://docs.tutor.overhang.io/tutor.html#contributing

@Danyal-Faheem
Copy link
Contributor

Awesome! Could you please just add a changelog entry? https://docs.tutor.overhang.io/tutor.html#contributing

Done. Thanks for reminding me once again. 😄

Copy link
Contributor

@regisb regisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Can you please rebase and squash your commits on top of master?

Copy link
Contributor

@regisb regisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks a lot! It looks like you still need to rebase your changes though.

@regisb
Copy link
Contributor

regisb commented Feb 9, 2024

I took the liberty to cherry-pick your commit and fix conflicts. This is now closed by d99b2fe
Thanks!

@regisb regisb closed this Feb 9, 2024
@@ -1,7 +1,7 @@
# -*- mode: python -*-
import importlib
import os
import pkg_resources
from importlib_metadata
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR, this line did cause an issue during the release. It was fixed by b69a8c7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants