Skip to content

Commit

Permalink
Update build & test matrix and use GitHub Actions as a Trusted Publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed Oct 5, 2023
1 parent aeb63ee commit 3fefaa6
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 27 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/build-and-deploy.yml
Expand Up @@ -27,12 +27,12 @@ jobs:

- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
uses: docker/setup-qemu-action@v3
with:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.11.4
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_TEST_COMMAND: >-
python -m simplejson.tests._cibw_runner "{project}"
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- uses: actions/setup-python@v2
name: Install Python
with:
python-version: '3.11'
python-version: '3.12'

- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel
Expand Down Expand Up @@ -94,6 +94,11 @@ jobs:
upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/simplejson/
permissions:
id-token: write
# upload to PyPI on every tag starting with 'v'
if: "github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')"
# alternatively, to publish when a GitHub Release is created, use the following rule:
Expand All @@ -104,16 +109,17 @@ jobs:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD }}
# To test: repository_url: https://test.pypi.org/legacy/
- uses: pypa/gh-action-pypi-publish@v1.8.10

upload_pypi_test:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
# upload to PyPI on every tag starting with 'v'
environment:
name: "testpypi"
url: https://test.pypi.org/p/simplejson/
permissions:
id-token: write
# upload to test PyPI on every tag starting with 'test-v'
if: "github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/test-v')"
# alternatively, to publish when a GitHub Release is created, use the following rule:
# if: github.event_name == 'release' && github.event.action == 'published'
Expand All @@ -123,8 +129,6 @@ jobs:
name: artifact
path: dist

- uses: pypa/gh-action-pypi-publish@v1.4.2
- uses: pypa/gh-action-pypi-publish@v1.8.10
with:
user: __token__
password: ${{ secrets.PYPI_PASSWORD_TEST }}
repository_url: https://test.pypi.org/legacy/
repository-url: https://test.pypi.org/legacy/
6 changes: 6 additions & 0 deletions CHANGES.txt
@@ -1,3 +1,9 @@
Version 3.19.2 released 2023-10-05

* Updated test & build matrix to include Python 3.12 and use
GitHub Actions as a Trusted Publisher (OIDC)
https://github.com/simplejson/simplejson/pull/317

Version 3.19.1 released 2023-04-06

* This release contains security hardening measures based on recommendations
Expand Down
2 changes: 1 addition & 1 deletion conf.py
Expand Up @@ -44,7 +44,7 @@
# The short X.Y version.
version = '3.19'
# The full version, including alpha/beta/rc tags.
release = '3.19.1'
release = '3.19.2'

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down
33 changes: 21 additions & 12 deletions setup.py
Expand Up @@ -12,11 +12,11 @@
DistutilsPlatformError

IS_PYPY = hasattr(sys, 'pypy_translation_info')
VERSION = '3.19.1'
VERSION = '3.19.2'
DESCRIPTION = "Simple, fast, extensible JSON encoder/decoder for Python"

with open('README.rst', 'r') as f:
LONG_DESCRIPTION = f.read()
LONG_DESCRIPTION = f.read()

PYTHON_REQUIRES = '>=2.5, !=3.0.*, !=3.1.*, !=3.2.*'

Expand All @@ -40,23 +40,26 @@
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3.11',
'Programming Language :: Python :: 3.12',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries :: Python Modules',
]

if sys.platform == 'win32' and sys.version_info < (2, 7):
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
# It can also raise ValueError https://bugs.python.org/issue7511
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
IOError, ValueError)
# 2.6's distutils.msvc9compiler can raise an IOError when failing to
# find the compiler
# It can also raise ValueError https://bugs.python.org/issue7511
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError,
IOError, ValueError)
else:
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)
ext_errors = (CCompilerError, DistutilsExecError, DistutilsPlatformError)


class BuildFailed(Exception):
pass


class ve_build_ext(build_ext):
# This class allows C extension building to fail.

Expand All @@ -83,18 +86,20 @@ def finalize_options(self):
pass

def run(self):
import sys, subprocess
import sys
import subprocess
raise SystemExit(
subprocess.call([sys.executable,
# Turn on deprecation warnings
'-Wd',
'simplejson/tests/__init__.py']))


def run_setup(with_binary):
cmdclass = dict(test=TestCommand)
if with_binary:
kw = dict(
ext_modules = [
ext_modules=[
Extension("simplejson._speedups", ["simplejson/_speedups.c"]),
],
cmdclass=dict(cmdclass, build_ext=ve_build_ext),
Expand All @@ -117,10 +122,14 @@ def run_setup(with_binary):
platforms=['any'],
**kw)


DISABLE_SPEEDUPS = IS_PYPY or os.environ.get('DISABLE_SPEEDUPS') == '1'
CIBUILDWHEEL = os.environ.get('CIBUILDWHEEL') == '1'
REQUIRE_SPEEDUPS = CIBUILDWHEEL or os.environ.get('REQUIRE_SPEEDUPS') == '1'
try:
run_setup(not IS_PYPY and os.environ.get('DISABLE_SPEEDUPS') != '1')
run_setup(not DISABLE_SPEEDUPS)
except BuildFailed:
if os.environ.get('REQUIRE_SPEEDUPS') or os.environ.get('CIBUILDWHEEL', '0') == '1':
if REQUIRE_SPEEDUPS:
raise
BUILD_EXT_WARNING = ("WARNING: The C extension could not be compiled, "
"speedups are not enabled.")
Expand Down
2 changes: 1 addition & 1 deletion simplejson/__init__.py
Expand Up @@ -118,7 +118,7 @@
"""
from __future__ import absolute_import
__version__ = '3.19.1'
__version__ = '3.19.2'
__all__ = [
'dump', 'dumps', 'load', 'loads',
'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
Expand Down

0 comments on commit 3fefaa6

Please sign in to comment.