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

packaging: Avoid ast module, requires Python = 2.6 #1245

Merged
merged 1 commit into from
Feb 6, 2025
Merged
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
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ In progress (unreleased)
------------------------

* :gh:issue:`1121` :mod:`mitogen`: Log skipped :py:mod:`termios` attributes
* :gh:issue:`1238` packaging: Avoid :py:mod:`ast`, requires Python = 2.6


v0.3.22 (2025-02-04)
Expand Down
14 changes: 8 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import ast
import os
import re

from setuptools import find_packages, setup


def grep_version():
path = os.path.join(os.path.dirname(__file__), 'mitogen/__init__.py')
version_pattern = re.compile(
r"__version__ = \((\d+), (\d+), (\d+)(?:, '(dev)')?\)",
)
with open(path) as fp:
for line in fp:
if line.startswith('__version__'):
_, _, s = line.partition('=')
parts = ast.literal_eval(s.strip())
return '.'.join(str(part) for part in parts)
match = version_pattern.search(fp.read())
if match is None:
raise ValueError('Could not find __version__ string in %s', path)
return '.'.join(str(part) for part in match.groups())


def long_description():
Expand Down