Skip to content

Commit

Permalink
Merge pull request #1 from asmeurer/github-actions
Browse files Browse the repository at this point in the history
Add github actions and packaging
  • Loading branch information
asmeurer authored Jan 22, 2024
2 parents ba454fb + 3877f4a commit e57b8f9
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 5 deletions.
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:
- "github-actions"
- "dependencies"
reviewers:
- "asmeurer"
112 changes: 112 additions & 0 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
name: publish distributions
on:
push:
branches:
- main
tags:
- '[0-9]+.[0-9]+'
- '[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- main
release:
types: [published]
workflow_dispatch:
inputs:
publish:
type: choice
description: 'Publish to TestPyPI?'
options:
- false
- true

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build Python distribution
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install python-build and twine
run: |
python -m pip install --upgrade pip setuptools
python -m pip install build twine
python -m pip list
- name: Build a wheel and a sdist
run: |
PYTHONWARNINGS=error,default::DeprecationWarning python -m build .
- name: Verify the distribution
run: twine check --strict dist/*

- name: List contents of sdist
run: python -m tarfile --list dist/array_api_strict-*.tar.gz

- name: List contents of wheel
run: python -m zipfile --list dist/array_api_strict-*.whl

- name: Upload distribution artifact
uses: actions/upload-artifact@v4
with:
name: dist-artifact
path: dist

publish:
name: Publish Python distribution to (Test)PyPI
if: github.event_name != 'pull_request' && github.repository == 'data-apis/array-api-strict'
needs: build
runs-on: ubuntu-latest
# Mandatory for publishing with a trusted publisher
# c.f. https://docs.pypi.org/trusted-publishers/using-a-publisher/
permissions:
id-token: write
contents: write
# Restrict to the environment set for the trusted publisher
environment:
name: publish-package

steps:
- name: Download distribution artifact
uses: actions/download-artifact@v4
with:
name: dist-artifact
path: dist

- name: List all files
run: ls -lh dist

- name: Publish distribution 📦 to Test PyPI
# Publish to TestPyPI on tag events of if manually triggered
# Compare to 'true' string as booleans get turned into strings in the console
if: >-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags'))
|| (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true')
uses: pypa/[email protected]
with:
repository-url: https://test.pypi.org/legacy/
print-hash: true

- name: Create GitHub Release from a Tag
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*

- name: Publish distribution 📦 to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/[email protected]
with:
print-hash: true
32 changes: 32 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Tests
on: [push, pull_request]
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
numpy-version: ['1', 'dev']
exclude:
- python-version: '3.8'
numpy-version: 'dev'
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
if [[ "${{ matrix.numpy-version }}" == "dev" ]]; then
python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy;
else
python -m pip install numpy<2.0;
fi
- name: Run Tests
run: |
pytest
# Make sure it installs
python setup.py install
6 changes: 1 addition & 5 deletions array_api_strict/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@
"""

import warnings

warnings.warn(
"The array_api_strict submodule is still experimental. See NEP 47.", stacklevel=2
)
__version__ = '1.0'

__array_api_version__ = "2022.12"

Expand Down
29 changes: 29 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
long_description = fh.read()

import array_api_strict

setup(
name='array_api_strict',
version=array_api_strict.__version__,
packages=find_packages(include=['array_api_strict*']),
author="Consortium for Python Data API Standards",
description="A strict, minimal implementation of the Python array API standard.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://data-apis.org/array-api-strict/",
license="MIT",
python_requires=">=3.8",
requires=["numpy"],
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: BSD License",
"Operating System :: OS Independent",
],
)

0 comments on commit e57b8f9

Please sign in to comment.