Skip to content

Commit 885add8

Browse files
authored
Merge pull request #427 from hpyproject/fa/prepare_0.9
Prepare next release (version 0.9.0).
2 parents b804cb2 + 25b4742 commit 885add8

File tree

8 files changed

+286
-37
lines changed

8 files changed

+286
-37
lines changed

.github/workflows/release-pypi.yml

Lines changed: 93 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,36 @@
11
---
2-
name: Release to PyPI
2+
name: Publish to PyPI
33

4+
# manually trigger this workflow
45
on:
5-
release:
6-
types: [created]
7-
6+
workflow_dispatch:
7+
inputs:
8+
tag:
9+
description: 'The Git tag to create or test a release for. Official releases should always be made from an existing tag.'
10+
required: true
11+
type: string
12+
official:
13+
description: 'If true, publish to official PyPI and create GitHub release. Otherwise publish only to test PyPI.'
14+
default: false
15+
type: boolean
816

917
jobs:
1018
build_sdist:
1119
name: Build source package
1220
runs-on: 'ubuntu-latest'
1321
steps:
14-
- uses: actions/checkout@v2
22+
- uses: actions/checkout@v3
23+
with:
24+
ref: ${{ inputs.tag }}
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v4
28+
with:
29+
# HPy requires at least Python 3.8; we mostly work with >=3.10
30+
python-version: '>=3.10'
1531

1632
- name: Install/Upgrade Python dependencies
17-
run: python -m pip install --upgrade pip wheel
33+
run: python -m pip install --upgrade pip wheel 'setuptools>=60.2'
1834

1935
- name: Build and install Python source package
2036
run: |
@@ -23,12 +39,14 @@ jobs:
2339
2440
- name: Run tests
2541
run: |
26-
pip install pytest pytest-xdist
42+
make
43+
pip install pytest pytest-xdist filelock
2744
pytest -n auto test/
2845
29-
- uses: actions/upload-artifact@v2
46+
- uses: actions/upload-artifact@v3
3047
with:
3148
path: dist/*.tar.gz
49+
retention-days: 5
3250

3351

3452
build_bdist:
@@ -37,46 +55,87 @@ jobs:
3755
strategy:
3856
matrix:
3957
# Windows tests fail when built as a binary wheel for some reason
40-
os: [ubuntu-latest, macos-latest] # windows-latest
58+
# 'macos-12' doesn't pass the tests
59+
os: [ubuntu-latest, macos-11] # windows-latest
4160

4261
steps:
43-
- uses: actions/checkout@v2
62+
- uses: actions/checkout@v3
63+
with:
64+
ref: ${{ inputs.tag }}
4465

4566
# setup Python for cibuildwheel
4667
- name: Set up Python
47-
uses: actions/setup-python@v2
68+
uses: actions/setup-python@v4
4869
with:
4970
python-version: '3.x'
5071

5172
# for other architectures, see: https://cibuildwheel.readthedocs.io/en/stable/faq/#emulation
5273
- name: Build wheels for CPython
53-
uses: pypa/cibuildwheel@v2.1.1
74+
uses: pypa/cibuildwheel@v2.12.3
5475
env:
55-
CIBW_BUILD: 'cp*' # no PyPI builds
56-
CIBW_SKIP: 'cp310-*' # 3.10 builds are broken
57-
CIBW_ARCHS: 'auto64' # only 64-bit
58-
CIBW_TEST_REQUIRES: pytest pytest-xdist
59-
CIBW_TEST_COMMAND: pytest -n auto {project}/test/
60-
61-
- uses: actions/upload-artifact@v2
76+
# cibuildwheel automatically reads 'python_requires' from 'setup.py'
77+
CIBW_BUILD: 'cp*' # no PyPy builds
78+
CIBW_ARCHS_LINUX: "x86_64" # only Intel 64-bit
79+
CIBW_ARCHS_MACOS: "x86_64" # only Intel 64-bit
80+
CIBW_TEST_REQUIRES: pytest pytest-xdist filelock setuptools>=60.2
81+
# only copy test dir to current working dir
82+
CIBW_TEST_COMMAND: cp -R {project}/test ./ && pytest --basetemp=.tmpdir --ignore=test/hpy_devel -n auto ./test/
83+
84+
- uses: actions/upload-artifact@v3
6285
with:
6386
path: ./wheelhouse/*.whl
64-
87+
retention-days: 5
6588

6689
upload_pypi:
67-
name: Publish packages to PyPI
68-
# only publish packages once everything is successful
69-
needs: [build_bdist, build_sdist]
90+
name: Publish packages to (Test) PyPI
91+
needs: [build_sdist, build_bdist]
92+
runs-on: ubuntu-latest
93+
# don't do this action on forks by default
94+
if: github.event_name == 'push' && github.repository == 'hpyproject/hpy'
95+
steps:
96+
- uses: actions/download-artifact@v3
97+
with:
98+
name: artifact
99+
path: dist
100+
101+
- name: Upload to Test PyPI
102+
uses: pypa/[email protected]
103+
if: ${{ !inputs.official }}
104+
with:
105+
verbose: true
106+
user: __token__
107+
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
108+
repository-url: https://test.pypi.org/legacy/
109+
110+
- name: Upload to PyPI
111+
uses: pypa/[email protected]
112+
if: ${{ inputs.official }}
113+
with:
114+
verbose: true
115+
user: __token__
116+
password: ${{ secrets.PYPI_API_TOKEN }}
117+
118+
create_gh_release:
119+
needs: [upload_pypi]
70120
runs-on: ubuntu-latest
121+
# don't do this action on forks by default
122+
if: github.event_name == 'push' && github.repository == 'hpyproject/hpy'
71123
steps:
72-
- uses: actions/download-artifact@v2
73-
with:
74-
name: artifact
75-
path: dist
76-
77-
- uses: pypa/[email protected]
78-
with:
79-
user: __token__
80-
password: ${{ secrets.pypi_api_token }}
81-
# uncomment the following to upload to test.pypi.org
82-
# repository_url: https://test.pypi.org/legacy/
124+
- uses: actions/download-artifact@v3
125+
with:
126+
name: artifact
127+
path: dist
128+
129+
- name: Checkout
130+
uses: actions/checkout@v3
131+
with:
132+
ref: ${{ inputs.tag }}
133+
134+
- name: Release
135+
uses: softprops/action-gh-release@v1
136+
with:
137+
files: dist/*
138+
# consider tags in form '*.*.*rc*' to indicate a pre-release
139+
prerelease: ${{ contains(github.ref, 'rc') }}
140+
draft: ${{ !inputs.official }}
141+
tag_name: ${{ inputs.tag }}

docs/api-reference/hpy-dict.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HPy Dict
2+
========
3+
4+
.. autocmodule:: autogen/public_api.h
5+
:members: HPyDict_Check, HPyDict_New, HPyDict_Keys, HPyDict_Copy

docs/api-reference/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ between the modes.
2727
hpy-call
2828
hpy-field
2929
hpy-global
30+
hpy-dict
3031
hpy-gil
3132
hpy-err
3233
builder

docs/changelog.rst

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,159 @@
11
Changelog
22
=========
33

4+
Version 0.9 (April 25th, 2023)
5+
------------------------------
6+
7+
This release adds numerous major features and indicates the end of HPy's *alhpa*
8+
phase. We've migrated several key packages to HPy (for a list, see our website
9+
https://hpyproject.org) and we are now confident that HPy is mature enough for
10+
being used as serious extension API. We also plan that the next major release
11+
will be ``1.0``.
12+
13+
Major new features
14+
~~~~~~~~~~~~~~~~~~
15+
16+
Support subclasses of built-in types
17+
It is now possible to create pure HPy types that inherit from built-in types
18+
like ``type`` or ``float``. This was already possible before but in a very
19+
limited way, i.e., by setting :c:member:`HPyType_Spec.basicsize` to ``0``. In
20+
this case, the type implicitly inherited the basic size of the supertype but
21+
that also means that you cannot have a custom C struct. It is now possible
22+
inherit from a built-in type **AND** have a custom C struct. For further
23+
reference, see :c:member:`HPyType_Spec.builtin_shape` and
24+
:c:enum:`HPyType_BuiltinShape`.
25+
26+
Support for metaclasses
27+
HPy now supports creating types with metaclasses. This can be done by passing
28+
type specification parameter with kind
29+
:c:enumerator:`HPyType_SpecParam_Metaclass` when calling
30+
:c:func:`HPyType_FromSpec`.
31+
32+
:term:`HPy Hybrid ABI`
33+
In addition to :term:`CPython ABI` and :term:`HPy Universal ABI`, we now
34+
introduced the Hybrid ABI. The major difference is that whenever you use a
35+
legacy API like :c:func:`HPy_AsPyObject` or :c:func:`HPy_FromPyObject`, the
36+
prdouced binary will then be specific to one interpreter. This was necessary
37+
to ensure that universal binaries are really portable and can be used on any
38+
HPy-capable interpreter.
39+
40+
:doc:`trace-mode`
41+
Similar to the :doc:`debug-mode`, HPy now provides the Trace Mode that can be
42+
enabled at runtime and helps analyzing API usage and identifying performance
43+
issues.
44+
45+
:ref:`porting-guide:multi-phase module initialization`
46+
HPy now support multi-phase module initialization which is an important
47+
feature in particular needed for two important use cases: (1) module state
48+
support (which is planned to be introduced in the next major release), and (2)
49+
subinterpreters. We decided to drop support for single-phase module
50+
initialization since this makes the API cleaner and easier to use.
51+
52+
HPy :ref:`porting-guide:calling protocol`
53+
This was a big missing piece and is now eventually available. It enables slot
54+
``HPy_tp_call``, which can now be used in the HPy type specification. We
55+
decided to use a calling convention similar to CPython's vectorcall calling
56+
convention. This is: the arguments are passed in a C array and the keyword
57+
argument names are provided as a Python tuple. Before this release, the only
58+
way to create a callable type was to set the special method ``__call__``.
59+
However, this has several disadvantages. In particlar, poor performance on
60+
CPython (and maybe other implementations) and it was not possible to have
61+
specialized call function implementations per object (see
62+
:c:func:`HPy_SetCallFunction`)
63+
64+
Added APIs
65+
~~~~~~~~~~
66+
67+
Deleting attributes and items
68+
:c:func:`HPy_DelAttr`, :c:func:`HPy_DelAttr_s`, :c:func:`HPy_DelItem`, :c:func:`HPy_DelItem_i`, :c:func:`HPy_DelItem_s`
69+
70+
Capsule API
71+
:c:func:`HPyCapsule_New`, :c:func:`HPyCapsule_IsValid`, :c:func:`HPyCapsule_Get`, :c:func:`HPyCapsule_Set`
72+
73+
Eval API
74+
:c:func:`HPy_Compile_s` and :c:func:`HPy_EvalCode`
75+
76+
Formatting helpers
77+
:c:func:`HPyUnicode_FromFormat` and :c:func:`HPyErr_Format`
78+
79+
Contextvar API
80+
:c:func:`HPyContextVar_New`, :c:func:`HPyContextVar_Get`, :c:func:`HPyContextVar_Set`
81+
82+
Unicode API
83+
:c:func:`HPyUnicode_FromEncodedObject` and :c:func:`HPyUnicode_Substring`
84+
85+
Dict API
86+
:c:func:`HPyDict_Keys` and :c:func:`HPyDict_Copy`
87+
88+
Type API
89+
:c:func:`HPyType_GetName` and :c:func:`HPyType_IsSubtype`
90+
91+
Slice API
92+
:c:func:`HPySlice_Unpack` and :c:func:`HPySlice_AdjustIndices`
93+
94+
Structseq API
95+
:c:func:`HPyStructSequence_NewType`, :c:func:`HPyStructSequence_New`
96+
97+
Call API
98+
:c:func:`HPy_Call`, :c:func:`HPy_CallMethod`, :c:func:`HPy_CallMethodTupleDict`, :c:func:`HPy_CallMethodTupleDict_s`
99+
100+
HPy call protocol
101+
:c:func:`HPy_SetCallFunction`
102+
103+
Debug mode
104+
~~~~~~~~~~
105+
106+
* Detect closing and returning (without dup) of context handles
107+
* Detect invalid usage of stored ``HPyContext *`` pointer
108+
* Detect invalid usage of tuple and list builders
109+
* Added Windows support for checking invalid use of raw data pointers (e.g
110+
``HPyUnicode_AsUTF8AndSize``) after handle was closed.
111+
* Added support for backtrace on MacOS
112+
113+
Documentation
114+
~~~~~~~~~~~~~
115+
116+
* Added incremental :doc:`porting-example/index`
117+
* Added :doc:`quickstart` guide
118+
* Extended :doc:`api-reference/index`
119+
* Added :doc:`api-reference/function-index`
120+
* Added possiblity to generate examples from tests with argument ``--dump-dir``
121+
(see :ref:`api:hpy unit tests`)
122+
* Added initial :doc:`contributing/index` docs
123+
124+
Incompatible changes to version 0.0.4
125+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
126+
127+
* Simplified ``HPyDef_*`` macros
128+
* Changed macro :c:macro:`HPy_MODINIT` because of multi-phase module init
129+
support.
130+
* Replace environment variable ``HPY_DEBUG`` by ``HPY`` (see :doc:`debug-mode`
131+
or :doc:`trace-mode`).
132+
* Changed signature of ``HPyFunc_VARARGS`` and ``HPyFunc_ KEYWORDS`` to align
133+
with HPy's call protocol calling convention.
134+
135+
Supported Python versions
136+
~~~~~~~~~~~~~~~~~~~~~~~~~
137+
138+
* Added Python 3.11 support
139+
* Preliminary Python 3.12 support
140+
* Dropped Python 3.6 support (since EOL)
141+
* Dropped Python 3.7 support (since EOL by June 2023)
142+
143+
Misc
144+
~~~~
145+
146+
* Ensure deterministic auto-generation
147+
* Ensure ABI backwards compatibility
148+
149+
* Explicitly define slot within HPyContext of function pointers and handles
150+
* Compile HPy ABI version into binary and verify at load time
151+
* Added proper support for object members ``HPyMember_OBJECT``
152+
* Changed :c:func:`HPyBytes_AsString` and :c:func:`HPyBytes_AS_STRING` to return ``const char *``
153+
* Use fixed-width integers in context functions
154+
155+
156+
4157
Version 0.0.4 (May 25th, 2022)
5158
------------------------------
6159

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
author = "HPy Collective"
2727

2828
# The full version, including alpha/beta/rc tags
29-
release = "0.0.4"
29+
release = "0.9"
3030

3131

3232
# -- General configuration ---------------------------------------------------

hpy/devel/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ def handle_hpy_ext_modules(dist, attr, hpy_ext_modules):
177177
"""
178178
assert attr == 'hpy_ext_modules'
179179

180+
# It can happen that this hook will be called multiple times depending on
181+
# which command was used. So, skip patching if we already patched the
182+
# distribution.
183+
if getattr(dist, 'hpydevel', None):
184+
return
185+
180186
# add a global option --hpy-abi to setup.py
181187
dist.__class__.hpy_abi = DEFAULT_HPY_ABI
182188
dist.__class__.hpy_use_static_libs = False

0 commit comments

Comments
 (0)