Skip to content

Commit

Permalink
Py 311 (#11)
Browse files Browse the repository at this point in the history
* Support for Python 3.11 and 3.12

* Use __inline with MSVC.

inline is a c99 keyword and c99 is not yet (fully) supported with MSVC.

https://stackoverflow.com/a/24736425/2080693

* Add Travis-CI for 3.11 and 3.12
  • Loading branch information
oohlaf authored Dec 30, 2023
1 parent 0268d81 commit 4e40d4d
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 10 deletions.
6 changes: 6 additions & 0 deletions .appveyor/appveyor-bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
("3.9", "32"): BASE_URL + "3.9.13/python-3.9.13.exe",
("3.10", "64"): BASE_URL + "3.10.11/python-3.10.11-amd64.exe",
("3.10", "32"): BASE_URL + "3.10.11/python-3.10.11.exe",
("3.11", "64"): BASE_URL + "3.11.7/python-3.11.7-amd64.exe",
("3.11", "32"): BASE_URL + "3.11.7/python-3.11.7.exe",
("3.12", "64"): BASE_URL + "3.12.1/python-3.12.1-amd64.exe",
("3.12", "32"): BASE_URL + "3.12.1/python-3.12.1.exe",
}
INSTALL_CMD = {
# Commands are allowed to fail only if they are not the last command.
Expand All @@ -71,6 +75,8 @@
"3.8": [["{path}", "/quiet", "TargetDir={home}"]],
"3.9": [["{path}", "/quiet", "TargetDir={home}"]],
"3.10": [["{path}", "/quiet", "TargetDir={home}"]],
"3.11": [["{path}", "/quiet", "TargetDir={home}"]],
"3.12": [["{path}", "/quiet", "TargetDir={home}"]],
}


Expand Down
2 changes: 2 additions & 0 deletions .appveyor/appveyor-with-compiler.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ IF "%PYTHON_VERSION%"=="3.7" GOTO main
IF "%PYTHON_VERSION%"=="3.8" GOTO main
IF "%PYTHON_VERSION%"=="3.9" GOTO main
IF "%PYTHON_VERSION%"=="3.10" GOTO main
IF "%PYTHON_VERSION%"=="3.11" GOTO main
IF "%PYTHON_VERSION%"=="3.12" GOTO main
IF "%PYTHON_ARCH%"=="32" GOTO main


Expand Down
18 changes: 10 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"

before_install:
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then
Expand All @@ -53,9 +55,9 @@ before_install:
brew install python@2 1>&2 || travis_terminate 1;
pip install virtualenv || travis_terminate 1;
virtualenv venv -p python2;
elif [[ $TRAVIS_PYTHON_VERSION == "3.10" ]]; then
elif [[ $TRAVIS_PYTHON_VERSION == "3.12" ]]; then
echo "Installing python 3.";
brew install python@3.10 1>&2 || travis_terminate 1;
brew install python@3.12 1>&2 || travis_terminate 1;
pip3 install virtualenv || travis_terminate 1;
virtualenv venv -p python3;
fi;
Expand All @@ -77,7 +79,7 @@ script:
- python --version || travis_terminate 1
- python setup.py test || travis_terminate 1
# Need to pick a Python version to create the source distribution.
- if [[ $TRAVIS_PYTHON_VERSION == "3.10" && $TRAVIS_OS_NAME == linux && $TRAVIS_PULL_REQUEST == false && -n $TRAVIS_TAG ]]; then
- if [[ $TRAVIS_PYTHON_VERSION == "3.12" && $TRAVIS_OS_NAME == linux && $TRAVIS_PULL_REQUEST == false && -n $TRAVIS_TAG ]]; then
echo "Creating source distribution.";
python setup.py sdist || travis_terminate 1;
else
Expand Down Expand Up @@ -139,7 +141,7 @@ jobs:
dist: xenial
env: TRAVIS_PYTHON_VERSION=3.6
# Manually include OSX in the job matrix, but only for
# Python 2.7 and 3.10.
# Python 2.7 and 3.12.
- stage: test
language: generic
python: 2.7
Expand All @@ -148,15 +150,15 @@ jobs:
env: TRAVIS_PYTHON_VERSION=2.7
- stage: test
language: generic
python: 3.10
python: 3.12
os: osx
osx_image: xcode14.2
env: TRAVIS_PYTHON_VERSION=3.10
env: TRAVIS_PYTHON_VERSION=3.12
# As the deploy script fetches all build artifacts uploaded to GitHub of
# all stages, we only need to run it once.
# So pinning it to Python 3.10 on Linux.
# So pinning it to Python 3.12 on Linux.
- stage: deploy
python: 3.10
python: 3.12
os: linux
cache: false
before_install: skip
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ project adheres to [Semantic Versioning][semver].

### Added

- Added newer Python versions to CI scripting up to Python 3.10
- Support for Python 3.11 and 3.12

### Changed

- Included newer Python versions in CI scripting up to Python 3.10
- Now also builds on PyPy3

## [1.0.0] (2018-02-19)
Expand Down
16 changes: 16 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ environment:
PYTHON_ARCH: '64'
PYTHON_HOME: C:\Python310-x64
PYTHON_EXE: C:\Python310-x64\python.exe
- PYTHON_VERSION: '3.11'
PYTHON_ARCH: '32'
PYTHON_HOME: C:\Python311
PYTHON_EXE: C:\Python311\python.exe
- PYTHON_VERSION: '3.11'
PYTHON_ARCH: '64'
PYTHON_HOME: C:\Python311-x64
PYTHON_EXE: C:\Python311-x64\python.exe
- PYTHON_VERSION: '3.12'
PYTHON_ARCH: '32'
PYTHON_HOME: C:\Python312
PYTHON_EXE: C:\Python312\python.exe
- PYTHON_VERSION: '3.12'
PYTHON_ARCH: '64'
PYTHON_HOME: C:\Python312-x64
PYTHON_EXE: C:\Python312-x64\python.exe

matrix:
fast_finish: true
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@
"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 :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Security :: Cryptography",
Expand Down
10 changes: 9 additions & 1 deletion whirlpool/pywhirlpool.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
#define HEXDIGITS(c) ((c>9) ? c+'a'-10 : c+'0')
#endif

#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
#if !defined(__cplusplus) && defined(_MSC_VER) && _MSC_VER < 1900
#define inline __inline
#endif
static inline void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type) { ob->ob_type = type; }
#define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
#endif

typedef struct {
PyObject_HEAD
NESSIEstruct whirlpool; /* the context holder */
Expand Down Expand Up @@ -408,7 +416,7 @@ moduleinit(void)
{
PyObject *m, *d;

Py_TYPE(&Whirlpooltype) = &PyType_Type;
Py_SET_TYPE(&Whirlpooltype, &PyType_Type);
if (PyType_Ready(&Whirlpooltype) < 0)
return NULL;

Expand Down

0 comments on commit 4e40d4d

Please sign in to comment.