Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.10"]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "pypy3.11"]
include:
- os: windows-latest
python-version: "3.11"
Expand All @@ -30,11 +30,11 @@ jobs:
python-version: "3.13"
exclude:
- os: macos-latest
python-version: 3.9
python-version: 3.12
- os: macos-latest
python-version: 3.10
python-version: 3.13
- os: macos-latest
python-version: "pypy3.10"
python-version: "pypy3.11"


steps:
Expand Down
24 changes: 15 additions & 9 deletions src/calmjs/parse/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from io import StringIO
from os.path import basename
from os.path import dirname
from pkg_resources import get_distribution

examples = {
'/tmp/html4.js': dedent("""
Expand Down Expand Up @@ -63,14 +62,21 @@ def open(p, flag='r'):
doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
)

dist = get_distribution('calmjs.parse')
if dist:
if dist.has_metadata('PKG-INFO'):
pkgdesc = dist.get_metadata('PKG-INFO').replace('\r', '')
elif dist.has_metadata('METADATA'):
pkgdesc = dist.get_metadata('METADATA').replace('\r', '')
else:
pkgdesc = ''
try:
from importlib import metadata
pkgdesc = metadata.metadata('calmjs.parse').get('description')
pkgdesc = pkgdesc.replace('\r', '') if pkgdesc else ''
except ImportError:
from pkg_resources import get_distribution
dist = get_distribution('calmjs.parse')
if dist:
if dist.has_metadata('PKG-INFO'):
pkgdesc = dist.get_metadata('PKG-INFO').replace('\r', '')
elif dist.has_metadata('METADATA'):
pkgdesc = dist.get_metadata('METADATA').replace('\r', '')
else:
pkgdesc = ''

pkgdesc_tests = [
t for t in parser.parse(pkgdesc) if isinstance(t, doctest.Example)]

Expand Down
51 changes: 39 additions & 12 deletions src/calmjs/parse/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,47 @@
from os.path import normpath
from os.path import relpath


class _Distribution(object):
def __init__(self, project_name, version):
self.project_name = project_name
self.version = version


try:
from pkg_resources import working_set
from pkg_resources import Requirement
ply_dist = working_set.find(Requirement.parse('ply'))
# note that for **extremely** ancient versions of setuptools, e.g.
# setuptools<0.6c11, or some very non-standard environment that does
# not include the required metadata (e.g. pyinstaller without the
# required metadata), will require the following workaround...
if ply_dist is None: # pragma: no cover
from pkg_resources import Distribution
import ply
ply_dist = Distribution(project_name='ply', version=ply.__version__)
from importlib import metadata
try:
ply_version = metadata.version('ply')
except Exception: # pragma: no cover
ply_dist = None
else:
ply_dist = _Distribution(project_name='ply', version=ply_version)
except ImportError: # pragma: no cover
ply_dist = None
try:
from pkg_resources import working_set
from pkg_resources import Requirement
ply_dist = working_set.find(Requirement.parse('ply'))
# note that for **extremely** ancient versions of setuptools, e.g.
# setuptools<0.6c11, or some very non-standard environment that does
# not include the required metadata (e.g. pyinstaller without the
# required metadata), will require the following workaround...
if ply_dist:
# convert to our private version class
ply_dist = _Distribution(
project_name='ply',
version=ply_dist.version,
)
else:
try:
import ply
ply_dist = _Distribution(
project_name='ply',
version=ply.__version__,
)
except ImportError:
ply_dist = None
except ImportError: # pragma: no cover
ply_dist = None

py_major = sys.version_info.major
unicode = unicode if py_major < 3 else None # noqa: F821
Expand Down
Loading