Skip to content

Commit

Permalink
BLD: update CI and build, remove poetry, test on py 310, 311, 312
Browse files Browse the repository at this point in the history
  • Loading branch information
fangchenli committed Jan 13, 2024
1 parent 15afc43 commit 41d36e4
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 146 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,18 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry pre-commit
poetry install
pip install .[dev]
- name: Run checks
run: |
pre-commit run --all-files --show-diff-on-failure
poetry run pytest tests.py --hypothesis-show-statistics --verbose
pytest tests.py --hypothesis-show-statistics --verbose
143 changes: 32 additions & 111 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,125 +12,46 @@ jobs:
runs-on: macos-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- name: Create artifacts directory
shell: bash
run: mkdir artifacts
- name: Checkout repository
uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
shell: bash
run: pip install poetry

- name: Build wheel
if: matrix.python-version != 3.9
shell: bash
run: poetry build --format "wheel"
- name: Build wheel and sdist
if: matrix.python-version == 3.9
shell: bash
run: poetry build

- name: Resolve wheel name
id: resolve_wheel
shell: bash
run: |
wheel_path="$(echo dist/pasteboard-*.whl)"
echo "::set-output name=path::$wheel_path"
echo "wheel path: $wheel_path"
wheel_name="${wheel_path##*/}"
echo "::set-output name=name::$wheel_name"
echo "wheel name: $wheel_name"
- name: Upload wheel to artifacts
uses: actions/upload-artifact@v2
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: artifacts
path: ${{ steps.resolve_wheel.outputs.path }}

- name: Resolve tar.gz name
id: resolve_targz
if: matrix.python-version == 3.9
shell: bash
run: |
targz_path="$(echo dist/pasteboard-*.tar.gz)"
echo "::set-output name=path::$targz_path"
echo "tar.gz path: $targz_path"
targz_name="${targz_path##*/}"
echo "::set-output name=name::$targz_name"
echo "tar.gz name: $targz_name"
- name: Upload tar.gz to artifacts
if: matrix.python-version == 3.9
uses: actions/upload-artifact@v2
with:
name: artifacts
path: ${{ steps.resolve_targz.outputs.path }}
name: python-package-distributions
path: dist/

publish-release:
name: publish-release
needs: ['build-release']
name: Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/')
needs:
- build-release
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/project/pasteboard/
permissions:
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: pip install poetry
- name: Get release download URL
uses: actions/download-artifact@v2
with:
name: artifacts
path: artifacts

- name: Create dist directory
shell: bash
run: mkdir dist
- name: Copy wheels
shell: bash
run: cp artifacts/*.whl dist/
- name: Copy tar.gz
shell: bash
run: cp artifacts/*.tar.gz dist/
- name: List all artifacts
shell: bash
run: ls -l dist/

- name: Get the branch and tag
id: info
shell: bash
run: |
branch="${GITHUB_REF#refs/heads/}"
echo "$branch"
if [[ "$branch" == "workflow_release" ]]; then
echo "::set-output name=version::TEST-0.0.0"
echo "::set-output name=dry_run::--dry-run"
else
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
echo "::set-output name=dry_run::"
fi
echo "::set-output name=date::$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d')"
- name: Create release
shell: bash
run: |
set -x
hub release create \
--draft \
--message "${{ steps.info.outputs.version }} (${{ steps.info.outputs.date }})" \
$(find ./dist -type f -printf "-a %p ") \
"${{ steps.info.outputs.version }}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish
run: |
poetry config pypi-token.pypi "${{ secrets.PYPI_TOKEN }}"
poetry publish ${{ steps.info.outputs.dry_run }}
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
43 changes: 21 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[tool.poetry]
[build-system]
requires = ["setuptools>=61.0.0", "setuptools-scm>=8.0"]
build-backend = "setuptools.build_meta"

[project]
name = "pasteboard"
version = "0.3.3"
description = "Pasteboard - Python interface for reading from NSPasteboard (macOS clipboard)"
authors = ["Toby Fleming <[email protected]>"]
license = "MPL-2.0"
authors = [
{name = "Toby Fleming", email = "[email protected]"}
]
license = {file = "LICENSE"}
readme = "README.md"
homepage = "https://github.com/tobywf/pasteboard"
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: MacOS X :: Cocoa",
Expand All @@ -14,30 +19,24 @@ classifiers = [
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Objective C",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: Implementation :: CPython",
"Topic :: Desktop Environment",
"Topic :: Software Development :: Libraries",
]
keywords = ["macOS", "clipboard", "pasteboard"]
build = "build.py"
requires-python = ">= 3.8"

[tool.poetry.dependencies]
python = ">=3.6,<4.0"

[tool.poetry.dev-dependencies]
black = "^20.8b1"
pytest = "^6.2.0"
hypothesis = "^6.0.0"
mypy = "^0.800"
# This version is the last to support Python 3.6...
ipython = "7.16.1"
# ...and jedi is not properly pinned
jedi = "0.17.2"
[project.optional-dependencies]
dev = [
"pytest",
"hypothesis",
"black",
"mypy",
"ipython",
"jedi",
"pre-commit",
]

[build-system]
requires = ["poetry_core>=1.0.0", "setuptools"]
build-backend = "poetry.core.masonry.api"
[tool.setuptools_scm]
12 changes: 5 additions & 7 deletions build.py → setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import sys
from distutils.core import Extension

assert sys.platform == "darwin", "pasteboard only works on macOS"
from setuptools import setup, Extension

pasteboard = Extension(
"pasteboard._native",
Expand All @@ -11,6 +8,7 @@
language="objective-c",
)


def build(setup_kwargs):
setup_kwargs.update({"ext_modules": [pasteboard], "zip_safe": False})
setup(
ext_modules=[pasteboard],
zip_safe=False,
)

0 comments on commit 41d36e4

Please sign in to comment.