Skip to content

Commit

Permalink
Python 3.12: partially switching from pkg_resources to packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanDunfield committed Oct 10, 2023
1 parent 92e54e3 commit 2471f18
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
3 changes: 2 additions & 1 deletion python/pari.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
while supporting both old and new versions of cypari and sage.pari and
accounting for all of the various idiosyncrasies.
"""
from pkg_resources import parse_version

from packaging.version import parse as parse_version
from .sage_helper import _within_sage

if _within_sage:
Expand Down
3 changes: 2 additions & 1 deletion python/phone_home.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import sys
from threading import Thread
from .version import version as current
from pkg_resources import parse_version
from packaging.version import parse as parse_version

import ssl
from urllib import request
version_url = 'http://snappy.computop.org/current.txt'
Expand Down
17 changes: 6 additions & 11 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
"""

no_sphinx_message = """
You need to have Sphinx (>= 1.7) installed to rebuild the
You need to have Sphinx installed to rebuild the
documentation for snappy module, e.g.
sudo python -m pip install "sphinx>=1.7"
sudo python -m pip install sphinx
"""

Expand All @@ -38,13 +38,8 @@

try:
import setuptools
import pkg_resources
except ImportError:
raise ImportError(no_setuptools_message)
try:
pkg_resources.working_set.require('setuptools>=1.0')
except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict):
raise ImportError(old_setuptools_message)

import os, platform, shutil, site, subprocess, sys, sysconfig, re
from os.path import getmtime, exists
Expand Down Expand Up @@ -108,8 +103,8 @@ def run(self):
if not os.path.exists('doc_src'):
return # Are in an sdist and may not have sphinx
try:
pkg_resources.working_set.require('sphinx>=1.7')
except (pkg_resources.DistributionNotFound, pkg_resources.VersionConflict):
import sphinx
except ImportError
raise ImportError(no_sphinx_message)
sphinx_cmd = load_entry_point('sphinx>=1.7', 'console_scripts', 'sphinx-build')
sphinx_args = ['-a', '-E', '-d', 'doc_src/_build/doctrees',
Expand Down Expand Up @@ -498,8 +493,8 @@ def add(self, source_file, dependency_mod_time=0.0):
ext_modules = [SnapPyC, SnapPyHP, TwisterCore]

install_requires = ['plink>=2.4.2', 'spherogram>=2.2', 'FXrays>=1.3',
'pypng', 'decorator', 'snappy_manifolds>=1.2',
'low_index>=1.2']
'snappy_manifolds>=1.2', 'low_index>=1.2',
'pypng', 'decorator', 'packaging']
try:
import sage
except ImportError:
Expand Down

0 comments on commit 2471f18

Please sign in to comment.