Skip to content

Commit

Permalink
Add support for Python 3.12 (except Windows)
Browse files Browse the repository at this point in the history
Requires latest version of cffi.
For Windows we wait support in AppVeyor.
Review and update header files for cffi.
  • Loading branch information
jdavid committed Sep 29, 2023
1 parent 8b92361 commit aab211a
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- os: ubuntu-22.04
python-version: 3.8
- os: ubuntu-22.04
python-version: '3.11'
python-version: '3.12'
- os: ubuntu-22.04
python-version: 'pypy3.9'
- os: macos-latest
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ jobs:
run: python -m cibuildwheel --output-dir wheelhouse
env:
CIBW_BEFORE_ALL: sh build.sh
CIBW_ENVIRONMENT: LIBGIT2_VERSION=1.7.1 LIBSSH2_VERSION=1.11.0 OPENSSL_VERSION=3.1.2 LIBGIT2=/project/ci
CIBW_ENVIRONMENT_MACOS: LIBGIT2_VERSION=1.7.1 LIBSSH2_VERSION=1.11.0 OPENSSL_VERSION=3.1.2 LIBGIT2=/Users/runner/work/pygit2/pygit2/ci
CIBW_SKIP: "*musl* pp3* cp312*"
CIBW_ENVIRONMENT: LIBGIT2_VERSION=1.7.1 LIBSSH2_VERSION=1.11.0 OPENSSL_VERSION=3.1.3 LIBGIT2=/project/ci
CIBW_ENVIRONMENT_MACOS: LIBGIT2_VERSION=1.7.1 LIBSSH2_VERSION=1.11.0 OPENSSL_VERSION=3.1.3 LIBGIT2=/Users/runner/work/pygit2/pygit2/ci
CIBW_SKIP: "*musl* pp3*"
CIBW_MANYLINUX_AARCH64_IMAGE: "manylinux2014"
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014"
CIBW_REPAIR_WHEEL_COMMAND_LINUX: "LD_LIBRARY_PATH=/project/ci/lib64 auditwheel repair -w {dest_dir} {wheel}"
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
1.13.2 (UNRELEASED)
-------------------------

- Support Python 3.12


1.13.1 (2023-09-24)
-------------------------

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.PHONY: build html

build:
OPENSSL_VERSION=3.0.9 LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.7.1 sh build.sh
OPENSSL_VERSION=3.1.3 LIBSSH2_VERSION=1.11.0 LIBGIT2_VERSION=1.7.1 sh build.sh

html: build
make -C docs html
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pygit2 - libgit2 bindings in Python
######################################################################

Bindings to the libgit2 shared library, implements Git plumbing.
Supports Python 3.8 to 3.11 and PyPy3 7.3+
Supports Python 3.8 to 3.12 and PyPy3 7.3+

.. image:: https://github.com/libgit2/pygit2/actions/workflows/tests.yml/badge.svg
:target: https://github.com/libgit2/pygit2/actions/workflows/tests.yml
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pygit2 - libgit2 bindings in Python
######################################################################

Bindings to the libgit2 shared library, implements Git plumbing.
Supports Python 3.8 to 3.11 and PyPy3 7.3+
Supports Python 3.8 to 3.12 and PyPy3 7.3+

Links
=====================================
Expand Down
4 changes: 2 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ Requirements

Supported versions of Python:

- Python 3.8 to 3.11
- Python 3.8 to 3.12
- PyPy3 7.3+

Python requirements (these are specified in ``setup.py``):

- cffi 1.9.1+
- cffi 1.16.0 or later

Libgit2 **v1.7.1+**; binary wheels already include libgit2, so you only need to
worry about this if you install the source package.
Expand Down
8 changes: 4 additions & 4 deletions pygit2/decl/attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#define GIT_ATTR_CHECK_NO_SYSTEM 4

typedef enum {
GIT_ATTR_UNSPECIFIED_T = 0,
GIT_ATTR_TRUE_T,
GIT_ATTR_FALSE_T,
GIT_ATTR_VALUE_T,
GIT_ATTR_VALUE_UNSPECIFIED = 0, /**< The attribute has been left unspecified */
GIT_ATTR_VALUE_TRUE, /**< The attribute has been set */
GIT_ATTR_VALUE_FALSE, /**< The attribute has been unset */
GIT_ATTR_VALUE_STRING /**< This attribute has a value */
} git_attr_value_t;

int git_attr_get(
Expand Down
9 changes: 4 additions & 5 deletions pygit2/decl/common.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#define GIT_PATH_MAX ...


typedef enum {
GIT_FEATURE_THREADS = 1,
GIT_FEATURE_HTTPS = 2,
GIT_FEATURE_SSH = 4,
GIT_FEATURE_NSEC = 8,
GIT_FEATURE_THREADS = (1 << 0),
GIT_FEATURE_HTTPS = (1 << 1),
GIT_FEATURE_SSH = (1 << 2),
GIT_FEATURE_NSEC = (1 << 3)
} git_feature_t;

int git_libgit2_features(void);
72 changes: 39 additions & 33 deletions pygit2/decl/errors.h
Original file line number Diff line number Diff line change
@@ -1,41 +1,47 @@
typedef enum {
GIT_OK = 0,

GIT_ERROR = -1,
GIT_ENOTFOUND = -3,
GIT_EEXISTS = -4,
GIT_EAMBIGUOUS = -5,
GIT_EBUFS = -6,

GIT_OK = 0, /**< No error */

GIT_ERROR = -1, /**< Generic error */
GIT_ENOTFOUND = -3, /**< Requested object could not be found */
GIT_EEXISTS = -4, /**< Object exists preventing operation */
GIT_EAMBIGUOUS = -5, /**< More than one object matches */
GIT_EBUFS = -6, /**< Output buffer too short to hold data */

/**
* GIT_EUSER is a special error that is never generated by libgit2
* code. You can return it from a callback (e.g to stop an iteration)
* to know that it was generated by the callback and not by libgit2.
*/
GIT_EUSER = -7,

GIT_EBAREREPO = -8,
GIT_EUNBORNBRANCH = -9,
GIT_EUNMERGED = -10,
GIT_ENONFASTFORWARD = -11,
GIT_EINVALIDSPEC = -12,
GIT_ECONFLICT = -13,
GIT_ELOCKED = -14,
GIT_EMODIFIED = -15,
GIT_EAUTH = -16,
GIT_ECERTIFICATE = -17,
GIT_EAPPLIED = -18,
GIT_EPEEL = -19,
GIT_EEOF = -20,
GIT_EINVALID = -21,
GIT_EUNCOMMITTED = -22,
GIT_EDIRECTORY = -23,
GIT_EMERGECONFLICT = -24,

GIT_PASSTHROUGH = -30,
GIT_ITEROVER = -31,
GIT_RETRY = -32,
GIT_EMISMATCH = -33,
GIT_EINDEXDIRTY = -34,
GIT_EAPPLYFAIL = -35,
GIT_EBAREREPO = -8, /**< Operation not allowed on bare repository */
GIT_EUNBORNBRANCH = -9, /**< HEAD refers to branch with no commits */
GIT_EUNMERGED = -10, /**< Merge in progress prevented operation */
GIT_ENONFASTFORWARD = -11, /**< Reference was not fast-forwardable */
GIT_EINVALIDSPEC = -12, /**< Name/ref spec was not in a valid format */
GIT_ECONFLICT = -13, /**< Checkout conflicts prevented operation */
GIT_ELOCKED = -14, /**< Lock file prevented operation */
GIT_EMODIFIED = -15, /**< Reference value does not match expected */
GIT_EAUTH = -16, /**< Authentication error */
GIT_ECERTIFICATE = -17, /**< Server certificate is invalid */
GIT_EAPPLIED = -18, /**< Patch/merge has already been applied */
GIT_EPEEL = -19, /**< The requested peel operation is not possible */
GIT_EEOF = -20, /**< Unexpected EOF */
GIT_EINVALID = -21, /**< Invalid operation or input */
GIT_EUNCOMMITTED = -22, /**< Uncommitted changes in index prevented operation */
GIT_EDIRECTORY = -23, /**< The operation is not valid for a directory */
GIT_EMERGECONFLICT = -24, /**< A merge conflict exists and cannot continue */

GIT_PASSTHROUGH = -30, /**< A user-configured callback refused to act */
GIT_ITEROVER = -31, /**< Signals end of iteration with iterator */
GIT_RETRY = -32, /**< Internal only */
GIT_EMISMATCH = -33, /**< Hashsum mismatch in object */
GIT_EINDEXDIRTY = -34, /**< Unsaved changes in the index would be overwritten */
GIT_EAPPLYFAIL = -35, /**< Patch application failed */
GIT_EOWNER = -36, /**< The object is not owned by the current user */
GIT_TIMEOUT = -37 /**< The operation timed out */
} git_error_code;


typedef struct {
char *message;
int klass;
Expand Down
8 changes: 4 additions & 4 deletions pygit2/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -1407,13 +1407,13 @@ def get_attr(self, path, name, flags=0):

# Now let's see if we can figure out what the value is
attr_kind = C.git_attr_value(cvalue[0])
if attr_kind == C.GIT_ATTR_UNSPECIFIED_T:
if attr_kind == C.GIT_ATTR_VALUE_UNSPECIFIED:
return None
elif attr_kind == C.GIT_ATTR_TRUE_T:
elif attr_kind == C.GIT_ATTR_VALUE_TRUE:
return True
elif attr_kind == C.GIT_ATTR_FALSE_T:
elif attr_kind == C.GIT_ATTR_VALUE_FALSE:
return False
elif attr_kind == C.GIT_ATTR_VALUE_T:
elif attr_kind == C.GIT_ATTR_VALUE_STRING:
return ffi.string(cvalue[0]).decode('utf-8')

assert False, "the attribute value from libgit2 is invalid"
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cffi>=1.9.1
cffi>=1.16.0
setuptools ; python_version >= "3.12"
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def exclude(line):
"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",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Software Development :: Version Control"]
Expand Down Expand Up @@ -152,7 +153,7 @@ def run(self):
ext_modules=ext_modules,
# Requirements
python_requires='>=3.8',
setup_requires=['cffi>=1.9.1'],
setup_requires=['cffi>=1.16.0'],
install_requires=install_requires,
# URLs
url='https://github.com/libgit2/pygit2',
Expand Down

0 comments on commit aab211a

Please sign in to comment.