Skip to content

Commit

Permalink
Changes for python 3.12 (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdce8p committed Oct 7, 2023
1 parent d2537cd commit 3e5bd8c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build-and-test.yml
Expand Up @@ -12,13 +12,13 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v2.3.0
uses: pypa/cibuildwheel@v2.16.2
env:
CIBW_SKIP: pp*
CIBW_TEST_COMMAND: python -m unittest discover ephem
Expand All @@ -29,10 +29,10 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
os: [ubuntu-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Build wheels
uses: pypa/cibuildwheel@v1.12.0
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/github-deploy.yml
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macos-10.15]
os: [ubuntu-latest, windows-latest, macos-latest]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'
Expand All @@ -30,7 +30,7 @@ jobs:
platforms: all

- name: Build wheels
uses: pypa/cibuildwheel@v2.12.1
uses: pypa/cibuildwheel@v2.16.2
env:
#CIBW_ARCHS_LINUX: auto aarch64 ppc64le s390x
CIBW_ARCHS_LINUX: auto aarch64 s390x
Expand All @@ -46,25 +46,25 @@ jobs:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.8'

- name: Build sdist
run: python setup.py sdist

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
Expand Down
4 changes: 2 additions & 2 deletions ephem/doc/date.rst
Expand Up @@ -114,7 +114,7 @@ Datetime objects
You can also ask a PyEphem date to convert itself the other direction
by calling its ``datetime()`` method.

>>> from datetime import date, datetime
>>> from datetime import date, datetime, timezone
>>> print(ephem.Date(datetime(2005, 4, 18, 22, 15)))
2005/4/18 22:15:00

Expand All @@ -138,7 +138,7 @@ Datetime objects
>>> d = datetime.utcnow()
>>> print(ephem.Date(d))
2015/12/14 15:42:14
>>> d = datetime.utcfromtimestamp(1450107734)
>>> d = datetime.fromtimestamp(1450107734, tz=timezone.utc)
>>> print(ephem.Date(d))
2015/12/14 15:42:14

Expand Down
7 changes: 6 additions & 1 deletion extensions/_libastro.c
Expand Up @@ -3,6 +3,8 @@
#define PY_SSIZE_T_CLEAN
#include "Python.h"

#define PyUnicode_GetSize(o) PyUnicode_GET_SIZE(o)

#if PY_MAJOR_VERSION == 2
#define PyLong_AsLong PyInt_AsLong
#define PyLong_FromLong PyInt_FromLong
Expand All @@ -23,6 +25,9 @@
#define OB_REFCNT ob_base.ob_refcnt
#if PY_MINOR_VERSION == 0 || PY_MINOR_VERSION == 1 || PY_MINOR_VERSION == 2
#define PyUnicode_AsUTF8 _PyUnicode_AsString
# elif PY_MINOR_VERSION >= 3
#undef PyUnicode_GetSize
#define PyUnicode_GetSize PyUnicode_GET_LENGTH
#endif
#endif

Expand Down Expand Up @@ -180,7 +185,7 @@ static int scansexa(PyObject *o, double *dp) {
Py_DECREF(list);
return -1;
}
Py_ssize_t item_length = PyUnicode_GET_SIZE(item);
Py_ssize_t item_length = PyUnicode_GetSize(item);
if (item_length == 0) {
continue; /* accept empty string for 0 */
}
Expand Down

0 comments on commit 3e5bd8c

Please sign in to comment.