Skip to content

Commit

Permalink
updating various ci bits, codecov action may be broken due to change … (
Browse files Browse the repository at this point in the history
#482)

* update ci to use python 3.12 across 
* more robust macos cross compilation to support either x86 or arm on either machine runner
* fix test timezone deprecation warning 
* added pypi cache env var to action to enable new cache
  • Loading branch information
AndrewAnnex committed Jun 19, 2024
1 parent d044027 commit 184b679
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 62 deletions.
21 changes: 0 additions & 21 deletions .cirrus.yml

This file was deleted.

40 changes: 22 additions & 18 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ on:
env:
# increment to rebuild cspice manually
CSPICE_VERSION: 67
CSPICE_CACHE_NUMBER: 1
CSPICE_CACHE_NUMBER: 2
PYPI_CACHE_NUMBER: 0

jobs:
build:
Expand All @@ -34,11 +35,11 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python 🐍 3.11
- name: Set up Python 🐍 3.12
if: steps.cache-libcspice.outputs.cache-hit != 'true'
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Display Python 🐍 version
if: steps.cache-libcspice.outputs.cache-hit != 'true'
run: python -c "import sys; print(sys.version)"
Expand Down Expand Up @@ -95,17 +96,17 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-nix.outputs.pip_cache_dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ env.PYPI_CACHE_NUMBER }}-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-test-pip-
${{ runner.os }}-${{ matrix.python-version }}-${{ env.PYPI_CACHE_NUMBER }}-test-pip-
- name: Cache pip's cache dir windows
if: runner.os == 'Windows'
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache-win.outputs.pip_cache_dir }}
key: ${{ runner.os }}-${{ matrix.python-version }}-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ env.PYPI_CACHE_NUMBER }}-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-test-pip-
${{ runner.os }}-${{ matrix.python-version }}-${{ env.PYPI_CACHE_NUMBER }}-test-pip-
- name: Install dependencies
run: |
python -m pip install -r ci-requirements.txt
Expand All @@ -116,8 +117,9 @@ jobs:
run: |
coverage run --source spiceypy -m pytest --pyargs spiceypy
- name: Upload 🆙 coverage 📈 report to codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
test_offline_shared:
runs-on: ubuntu-latest
Expand All @@ -126,10 +128,10 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python 🐍 3.11
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Display Python 🐍 version
run: python -c "import sys; print(sys.version)"
- name: Install pip
Expand All @@ -143,9 +145,9 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.pip_cache_dir }}
key: ${{ runner.os }}-3.11-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
key: ${{ runner.os }}-3.12-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
restore-keys: |
${{ runner.os }}-3.11-test-pip-
${{ runner.os }}-3.12-test-pip-
- name: Install dependencies
run: |
python -m pip install -U -r ci-requirements.txt
Expand All @@ -163,8 +165,9 @@ jobs:
run: |
coverage run --source spiceypy -m pytest --pyargs spiceypy
- name: Upload 🆙 coverage 📈 report to codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
test_offline_cspice_install:
runs-on: ubuntu-latest
Expand All @@ -173,10 +176,10 @@ jobs:
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Set up Python 🐍 3.11
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Display Python 🐍 version
run: python -c "import sys; print(sys.version)"
- name: Install pip
Expand All @@ -190,9 +193,9 @@ jobs:
uses: actions/cache@v4
with:
path: ${{ steps.pip-cache.outputs.pip_cache_dir }}
key: ${{ runner.os }}-3.11-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
key: ${{ runner.os }}-3.12-test-pip-${{ hashFiles('**/ci-requirements.txt') }}
restore-keys: |
${{ runner.os }}-3.11-test-pip-
${{ runner.os }}-3.12-test-pip-
- name: Install dependencies
run : |
python -m pip install -U -r ci-requirements.txt
Expand All @@ -209,6 +212,7 @@ jobs:
run: |
coverage run --source spiceypy -m pytest --pyargs spiceypy
- name: Upload 🆙 coverage 📈 report to codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
32 changes: 20 additions & 12 deletions .github/workflows/publish-to-test-and-live-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,29 @@ jobs:
steps:
- name: Checkout 🌶️ 🥧
uses: actions/checkout@v4
- name: Set up Python 🐍 3.11
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Display Python 🐍
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r ci-requirements.txt
python -m pip install -r test-requirements.txt
python -m pip install build coverage>=5.1.0 twine>=3.3.0
- name: Build 🛠️ sdist source and Install SpiceyPy 🌶️ 🥧
run: |
python -m build --sdist
pip install dist/*.tar.gz --user
echo "Running Pip install from sdist"
python -m pip install dist/*.tar.gz --user
- name: Test 🧪 with coverage 📈
run: |
coverage run --source spiceypy -m pytest --pyargs spiceypy
- name: Upload 🆙 coverage 📈 report to codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
fail_ci_if_error: false
verbose: true
- name: Check dists
run: |
Expand Down Expand Up @@ -62,11 +65,16 @@ jobs:
- name: Setup 🔬🍦🏗️
if: runner.os == 'Windows'
uses: ilammy/msvc-dev-cmd@v1.13.0
- name: set additional environment variables
if: runner.name == 'macOS' && runner.arch == 'arm64'
- name: set additional environment variables for macOS arm
if: runner.name == 'macOS' && matrix.config.arch == 'arm64'
run: |
echo "CIBW_ARCHS_MACOS=arm64" >> $GITHUB_ENV
echo "ARCHFLAGS='-arch arm64'" >> $GITHUB_ENV
- name: set additional environment variables for macOS x86
if: runner.name == 'macOS' && matrix.config.arch == 'x86_64'
run: |
echo "CIBW_ARCHS_MACOS=x86_64" >> $GITHUB_ENV
echo "ARCHFLAGS='-arch x86_64'" >> $GITHUB_ENV
- name: Set up QEMU for arm64 builds
if: matrix.config.arch == 'aarch64'
uses: docker/setup-qemu-action@v3
Expand All @@ -78,17 +86,17 @@ jobs:
with:
path: ./src/spiceypy/utils/libcspice.so
key: ${{ env.CSPICE_CACHE }}-${{ matrix.config.os }}-${{ matrix.config.arch }}-${{ hashFiles('get_spice.py') }}-${{ hashFiles('setup.cfg') }}
- name: Set up Python 🐍 3.11
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Display Python 🐍 Version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r ci-requirements.txt
python -m pip install cibuildwheel==2.16.4
python -m pip install cibuildwheel==2.19.1
- name: See if libcspice.so is available from cache
if: matrix.config.arch == 'aarch64'
run: |
Expand Down Expand Up @@ -128,10 +136,10 @@ jobs:
pattern: artifact-*
merge-multiple: true
path: dist
- name: Set up Python 🐍 3.11
- name: Set up Python 🐍 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Display Python 🐍
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ as newer versions are released.

- OS: OS X, Linux, Windows, FreeBSD
- CPU: 64bit only!
- Python 3.6, 3.7, 3.8, 3.9, 3.10, 3.11
- Python 3.6, 3.7, 3.8, 3.9, 3.10, 3.11, 3.12
- ARM support for Linux-aarch64 & osx-arm64

* Support for Python 2.7 ended with version 2.3.2 January 2020 *
Expand Down
22 changes: 17 additions & 5 deletions get_spice.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,28 @@
os_supported = host_OS in ("Linux", "Darwin", "FreeBSD", "Windows")
# Get platform is Unix-like OS or not
is_unix = host_OS in ("Linux", "Darwin", "FreeBSD")
is_macos = host_OS == "Darwin"
# Get current working directory
root_dir = str(Path(os.path.realpath(__file__)).parent)
# Make the directory path for cspice
cspice_dir = os.environ.get(CSPICE_SRC_DIR, os.path.join(root_dir, "cspice"))
# and make a global tmp cspice directory
tmp_cspice_root_dir = None
# macos builds can occur on x86 or arm64 machines.
# but we need to support cross compilation either way
# so be a little pedantic here
requested_arch_x86 = os.environ.get("ARCHFLAGS", "") == "-arch x86_64"
requested_arch_arm = os.environ.get("ARCHFLAGS", "") == "-arch arm64"
# if both are false and on macos do something
if is_macos and (not requested_arch_arm and not requested_arch_x86):
# default to building arm on macos
requested_arch_arm = True
build_macos_x86 = is_macos and (('x86' in host_arch) or requested_arch_x86) and not requested_arch_arm
build_macos_arm = is_macos and ((host_arch == 'arm64') or requested_arch_arm) and not requested_arch_x86
# if host arch is x86 it will go to x86 build
# if however archflags was set explicitly to not be arm64 we need cross compile
# if we need to cross compile or compile for arm64
is_macos_arm = host_OS == "Darwin" and (
host_arch == "arm64" or os.environ.get("ARCHFLAGS", "") == "-arch arm64"
)
is_macos_arm = build_macos_arm
# versions
spice_version = "N0067"
spice_num_v = "67"
Expand Down Expand Up @@ -209,7 +221,6 @@ def _distribution_info(self):
machine = "x86_64"

if is_macos_arm:
print("either running on apple arm64 or cross-compiling")
machine = "arm64"

print("SYSTEM: ", system)
Expand Down Expand Up @@ -349,8 +360,9 @@ def build_cspice() -> str:
global cspice_dir, host_OS
if is_unix:
libname = f"libcspice.so"
target = "-target arm64-apple-macos11" if is_macos_arm else ""
target = ""
if host_OS == "Darwin":
target = "-target arm64-apple-macos11" if build_macos_arm else "-target x86_64-apple-macos10.9"
extra_flags = f"-dynamiclib -install_name @rpath/{libname}"
else:
extra_flags = f"-shared -Wl,-soname,{libname}"
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ build-backend = "setuptools.build_meta"
build-frontend = "build"
# build libcspice inside cibuildwheel before running python build steps
before-build = "python {project}/get_spice.py"
# Only build on CPython 3.11
build = "cp311-*"
# Only build on CPython 3.12
build = "cp312-*"
# Skip 32-bit builds, pypy, and musllinux
skip = ["*-win32", "*-manylinux_i686", "*-musllinux_i686", "pypy*", "pp*", "*-musllinux_aarch64", "*-musllinux_x86_64"]
# other options
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Operating System :: MacOS :: MacOS X
Operating System :: POSIX :: Linux
Operating System :: POSIX :: BSD :: FreeBSD
Expand Down
5 changes: 2 additions & 3 deletions src/spiceypy/tests/test_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6751,10 +6751,9 @@ def test_raxisa():


def test_rdtext():
import datetime

from datetime import datetime, timezone
# Create ISO UTC datetime string using current time
utcnow = datetime.datetime.utcnow().isoformat()
utcnow = datetime.now(timezone.utc).isoformat()
spice.reset()
# Create temporary filenames
RDTEXT = os.path.join(cwd, "ex_rdtext.txt")
Expand Down

0 comments on commit 184b679

Please sign in to comment.