Skip to content

Commit

Permalink
Use TOML setup.py...
Browse files Browse the repository at this point in the history
Better PyPy tolerance
  • Loading branch information
rocky committed Mar 26, 2024
1 parent 3f1aabc commit 9673903
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 34 deletions.
15 changes: 15 additions & 0 deletions .circleci/config-tox.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: 2

jobs:

# using tox
toxifiy:
docker:
- image: python:3.3

steps:
- checkout
- run pip install tox && tox

workflows:
version: 2
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[build-system]
requires = [
"setuptools>=61.2",
]

build-backend = "setuptools.build_meta"

[project]
authors = [
{name = "Rocky Bernstein", email = "rb@dustyfeet.com"},
{name = "Ned Batchelder"},
{name = "Paul Swartz"},
{name = "Allison Kaptur"},
{name = "Ned Batchelder"},
]

name = "x-python"
description = "Python cross-version byte-code interpeter"
dependencies = [
"click",
"six",
"xdis >= 6.0.3,<6.2.0",
]
readme = "README.rst"
license = {text = "GPL"}
keywords = ["Python bytecode", "bytecode", "disassembler"]
classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: PyPy",
]
dynamic = ["version"]

[project.urls]
Homepage = "https://pypi.org/project/x-python/"
Downloads = "https://github.com/rocky/x-python/releases"

[project.optional-dependencies]
dev = [
"flake8",
"pre-commit",
"pytest",
]

[project.scripts]
xpython = "xpython.__main__:main"

[tool.setuptools.dynamic]
version = {attr = "xpython.version.__version__"}
30 changes: 1 addition & 29 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,4 @@

from distutils.core import setup

from setuptools import find_packages
from __pkginfo__ import (
__version__,
author,
author_email,
classifiers,
entry_points,
install_requires,
long_description,
py_modules,
short_desc,
url,
)

setup(
name="x-python",
version=__version__,
author=author,
author_email=author_email,
classifiers=classifiers,
description=short_desc,
entry_points=entry_points,
long_description=long_description,
long_description_content_type="text/x-rst",
packages=find_packages(),
py_modules=py_modules,
install_requires=install_requires,
url=url,
)
setup(packages=["xpython"])
17 changes: 15 additions & 2 deletions xpython/byteop/byteoppypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ def JUMP_IF_NOT_DEBUG(self, jump_offset):
"""
self.vm.jump(jump_offset)

# For Python 3.7 this is not correct
# For Python 3.7+ this is not correct
def LOOKUP_METHOD(self, name):
"""
"""From
https://doc.pypy.org/en/latest/interpreter-optimizations.html#lookup-method-call-method
LOOKUP_METHOD contains exactly the same attribute lookup logic
as LOAD_ATTR - thus fully preserving semantics - but pushes
two values onto the stack instead of one. These two values are
an “inlined” version of the bound method object: the im_func
and im_self, i.e. respectively the underlying Python function
object and a reference to obj. This is only possible when the
attribute actually refers to a function object from the class;
when this is not the case, LOOKUP_METHOD still pushes two
values, but one (im_func) is simply the regular result that
LOAD_ATTR would have returned, and the other (im_self) is an
interpreter-level None placeholder.
For now, we'll assume this is the same as LOAD_ATTR:
Replaces TOS with getattr(TOS, co_names[namei]).
Expand Down
5 changes: 2 additions & 3 deletions xpython/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,8 @@ def __init__(

variant = "pypy" if is_pypy else None

# FIXME: HACK alert - until the next release of xpython > 6.0.3
if is_pypy and python_version == (3, 8, 0):
python_version = (3, 8, 12)
if is_pypy:
python_version = tuple(python_version[:2])

self.opc = get_opcode_module(python_version, variant)
self.byteop = get_byteop(self, python_version, is_pypy)
Expand Down

0 comments on commit 9673903

Please sign in to comment.