-
Notifications
You must be signed in to change notification settings - Fork 930
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from cs50/rongxin-patch-1
Replace pkg_resources with importlib.metadata for Python 3.12
- Loading branch information
Showing
3 changed files
with
18 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
from pkg_resources import get_distribution, DistributionNotFound | ||
from importlib.metadata import PackageNotFoundError, version | ||
import os | ||
|
||
# https://stackoverflow.com/questions/17583443/what-is-the-correct-way-to-share-package-version-with-setup-py-and-the-package | ||
try: | ||
_dist = get_distribution("submit50") | ||
# Normalize path for cross-OS compatibility. | ||
_dist_loc = os.path.normcase(_dist.location) | ||
_here = os.path.normcase(__file__) | ||
if not _here.startswith(os.path.join(_dist_loc, "submit50")): | ||
# This version is not installed, but another version is. | ||
raise DistributionNotFound | ||
except DistributionNotFound: | ||
__version__ = "locally installed, no version information available" | ||
else: | ||
__version__ = _dist.version | ||
__version__ = version("submit50") | ||
except PackageNotFoundError: | ||
__version__ = "UNKNOWN" | ||
|
||
CONFIG_LOADER = __import__("lib50").config.Loader("submit50") | ||
CONFIG_LOADER.scope("files", "include", "exclude", "require") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters