Skip to content

Commit e57b8f9

Browse files
authored
Merge pull request #1 from asmeurer/github-actions
Add github actions and packaging
2 parents ba454fb + 3877f4a commit e57b8f9

File tree

5 files changed

+186
-5
lines changed

5 files changed

+186
-5
lines changed

.github/dependabot.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
updates:
3+
# Maintain dependencies for GitHub Actions
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "weekly"
8+
labels:
9+
- "github-actions"
10+
- "dependencies"
11+
reviewers:
12+
- "asmeurer"

.github/workflows/publish-package.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: publish distributions
2+
on:
3+
push:
4+
branches:
5+
- main
6+
tags:
7+
- '[0-9]+.[0-9]+'
8+
- '[0-9]+.[0-9]+.[0-9]+'
9+
pull_request:
10+
branches:
11+
- main
12+
release:
13+
types: [published]
14+
workflow_dispatch:
15+
inputs:
16+
publish:
17+
type: choice
18+
description: 'Publish to TestPyPI?'
19+
options:
20+
- false
21+
- true
22+
23+
concurrency:
24+
group: ${{ github.workflow }}-${{ github.ref }}
25+
cancel-in-progress: true
26+
27+
jobs:
28+
build:
29+
name: Build Python distribution
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
with:
35+
fetch-depth: 0
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.x'
41+
42+
- name: Install python-build and twine
43+
run: |
44+
python -m pip install --upgrade pip setuptools
45+
python -m pip install build twine
46+
python -m pip list
47+
48+
- name: Build a wheel and a sdist
49+
run: |
50+
PYTHONWARNINGS=error,default::DeprecationWarning python -m build .
51+
52+
- name: Verify the distribution
53+
run: twine check --strict dist/*
54+
55+
- name: List contents of sdist
56+
run: python -m tarfile --list dist/array_api_strict-*.tar.gz
57+
58+
- name: List contents of wheel
59+
run: python -m zipfile --list dist/array_api_strict-*.whl
60+
61+
- name: Upload distribution artifact
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: dist-artifact
65+
path: dist
66+
67+
publish:
68+
name: Publish Python distribution to (Test)PyPI
69+
if: github.event_name != 'pull_request' && github.repository == 'data-apis/array-api-strict'
70+
needs: build
71+
runs-on: ubuntu-latest
72+
# Mandatory for publishing with a trusted publisher
73+
# c.f. https://docs.pypi.org/trusted-publishers/using-a-publisher/
74+
permissions:
75+
id-token: write
76+
contents: write
77+
# Restrict to the environment set for the trusted publisher
78+
environment:
79+
name: publish-package
80+
81+
steps:
82+
- name: Download distribution artifact
83+
uses: actions/download-artifact@v4
84+
with:
85+
name: dist-artifact
86+
path: dist
87+
88+
- name: List all files
89+
run: ls -lh dist
90+
91+
- name: Publish distribution 📦 to Test PyPI
92+
# Publish to TestPyPI on tag events of if manually triggered
93+
# Compare to 'true' string as booleans get turned into strings in the console
94+
if: >-
95+
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags'))
96+
|| (github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true')
97+
uses: pypa/[email protected]
98+
with:
99+
repository-url: https://test.pypi.org/legacy/
100+
print-hash: true
101+
102+
- name: Create GitHub Release from a Tag
103+
uses: softprops/action-gh-release@v1
104+
if: startsWith(github.ref, 'refs/tags/')
105+
with:
106+
files: dist/*
107+
108+
- name: Publish distribution 📦 to PyPI
109+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
110+
uses: pypa/[email protected]
111+
with:
112+
print-hash: true

.github/workflows/tests.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Tests
2+
on: [push, pull_request]
3+
jobs:
4+
tests:
5+
runs-on: ubuntu-latest
6+
strategy:
7+
matrix:
8+
python-version: ['3.8', '3.9', '3.10', '3.11']
9+
numpy-version: ['1', 'dev']
10+
exclude:
11+
- python-version: '3.8'
12+
numpy-version: 'dev'
13+
fail-fast: true
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
- name: Install Dependencies
20+
run: |
21+
python -m pip install --upgrade pip
22+
if [[ "${{ matrix.numpy-version }}" == "dev" ]]; then
23+
python -m pip install --pre --extra-index https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy;
24+
else
25+
python -m pip install numpy<2.0;
26+
fi
27+
- name: Run Tests
28+
run: |
29+
pytest
30+
31+
# Make sure it installs
32+
python setup.py install

array_api_strict/__init__.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,7 @@
115115
116116
"""
117117

118-
import warnings
119-
120-
warnings.warn(
121-
"The array_api_strict submodule is still experimental. See NEP 47.", stacklevel=2
122-
)
118+
__version__ = '1.0'
123119

124120
__array_api_version__ = "2022.12"
125121

setup.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from setuptools import setup, find_packages
2+
3+
with open("README.md", "r") as fh:
4+
long_description = fh.read()
5+
6+
import array_api_strict
7+
8+
setup(
9+
name='array_api_strict',
10+
version=array_api_strict.__version__,
11+
packages=find_packages(include=['array_api_strict*']),
12+
author="Consortium for Python Data API Standards",
13+
description="A strict, minimal implementation of the Python array API standard.",
14+
long_description=long_description,
15+
long_description_content_type="text/markdown",
16+
url="https://data-apis.org/array-api-strict/",
17+
license="MIT",
18+
python_requires=">=3.8",
19+
requires=["numpy"],
20+
classifiers=[
21+
"Programming Language :: Python :: 3",
22+
"Programming Language :: Python :: 3.8",
23+
"Programming Language :: Python :: 3.9",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"License :: OSI Approved :: BSD License",
27+
"Operating System :: OS Independent",
28+
],
29+
)

0 commit comments

Comments
 (0)