Skip to content

Commit 0cd50bb

Browse files
author
rocky
committed
Pass PyPy status to write pyc. Correct pyc-xasm entry. And more.
1 parent e01b608 commit 0cd50bb

File tree

9 files changed

+20
-11
lines changed

9 files changed

+20
-11
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ Installation
5454
A GNU makefile is also provided so ``make install`` (possibly as root or
5555
sudo) will do the steps above.
5656

57-
5857
*If you are using Python before 3.11*, do not install using PyPI, but instead install using a file in the `GitHub Releases section <https://github.com/rocky/python-xasm/releases>`_. Older Python used to use `easy_install <https://python101.pythonlibrary.org/chapter29_pip.html#using-easy-install>`_. But this is no longer supported in PyPi or newer Python versions. And vice versa, *poetry* nor *pip*, (the newer ways) are not supported on older Pythons.
5958

6059
If the Python version you are running xasm is between Python 3.6 through 3.11, use a tarball called xasm_36-*x.y.z*.tar.gz.

admin-tools/install-all-3.6-3.10.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fi
2121

2222
cd ../dist/
2323

24-
install_file="xasm_36-${__version__}.tar.gz"
2524
install_check_command="pyc-xasm --help"
25+
install_file="xasm_36-${__version__}.tar.gz"
2626
for version in $PYVERSIONS; do
2727
echo "*** Installing ${install_file} for Python ${version} ***"
2828
echo $version

admin-tools/install-all-newest.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ fi
2121

2222
cd ../dist/
2323

24-
install_check_command="xasm --help"
25-
install_file="pyc-xasm-${__version__}.tar.gz"
24+
install_check_command="pyc-xasm --help"
25+
install_file="xasm-${__version__}.tar.gz"
2626
for pyversion in $PYVERSIONS; do
2727
echo "*** Installing ${install_file} for Python ${pyversion} ***"
2828
pyenv local $pyversion

admin-tools/make-dist-newest.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fi
3434

3535
for pyversion in $PYVERSIONS; do
3636
case ${pyversion:0:4} in
37-
"graal" )
37+
"graa" )
3838
echo "$pyversion - Graal does not get special packaging"
3939
continue
4040
;;

admin-tools/pyenv-newest-versions

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# -*- shell-script -*-
22
# Sets PYVERSIONS to be pyenv versions that
33
# we can use in the master branch.
4-
export PYVERSIONS='3.11 3.12 3.13'
54
if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
65
typeset -p PYVERSIONS
76
echo "Note: this script should be *sourced* rather than run directly through bash"
87
exit 1
98
fi
9+
10+
export PYVERSIONS='3.11 pypy3.11 graalpy-24.2.2 pypy3.11 3.12 graalpy-community-25.0.0 3.13'

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ dev = [
4747
]
4848

4949
[project.scripts]
50-
python-cfg = "xasm.__main__:main"
50+
pyc-xasm = "xasm.xasm_cli:main"
5151

5252
[tool.setuptools]
5353
packages = [

xasm/assemble.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def __init__(self, python_version, is_pypy) -> None:
6969
self.codes = [] # FIXME use a better name
7070
self.status: str = "unfinished"
7171
self.size = 0 # Size of source code. Only relevant in version 3 and above
72+
self.is_pypy = is_pypy
7273
self.python_version = python_version
7374
self.timestamp = None
7475
self.backpatch = [] # list of backpatch dicts, one for each function

xasm/write_pyc.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import time
22
from struct import pack
3+
from typing import Optional
34

45
import xdis
56
from xdis import magic2int
@@ -8,8 +9,13 @@
89
from xdis.version_info import PYTHON3, version_tuple_to_str
910

1011

11-
def write_pycfile(fp, code_list, timestamp=None, version_triple=xdis.PYTHON_VERSION_TRIPLE) -> int:
12-
12+
def write_pycfile(
13+
fp,
14+
code_list,
15+
timestamp=None,
16+
version_triple=xdis.PYTHON_VERSION_TRIPLE,
17+
is_pypy: Optional[bool] = None,
18+
) -> int:
1319
rc = 0
1420
version_str = version_tuple_to_str(version_triple, end=2)
1521
magic_bytes = magics[version_str]
@@ -36,7 +42,7 @@ def write_pycfile(fp, code_list, timestamp=None, version_triple=xdis.PYTHON_VERS
3642

3743
for co in code_list:
3844
try:
39-
co_obj = dumps(co, python_version=version_triple)
45+
co_obj = dumps(co, python_version=version_triple, is_pypy=is_pypy)
4046
if PYTHON3 and version_triple < (3, 0):
4147
co_obj = str.encode(co_obj)
4248
pass

xasm/xasm_cli.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def main(pyc_file: List[str], asm_path):
4444
file_mode = "w"
4545

4646
with open(pyc_file, file_mode) as fp:
47-
rc = write_pycfile(fp, asm.code_list, asm.timestamp, asm.python_version)
47+
rc = write_pycfile(
48+
fp, asm.code_list, asm.timestamp, asm.python_version, asm.is_pypy
49+
)
4850
size = fp.tell()
4951
print(
5052
f"""Wrote Python {version_tuple_to_str(asm.python_version)} bytecode file "{pyc_file}"; {size} bytes."""

0 commit comments

Comments
 (0)