Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add initial package structure #1

Merged
merged 4 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "monthly"
groups:
github-actions:
patterns:
- "*"
60 changes: 60 additions & 0 deletions .github/workflows/deploy_docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy Documentation

on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:

# Only allow one docs build at a time so that overlapping stale builds will get
# cancelled automatically.
concurrency:
group: deploy_docs
cancel-in-progress: true

jobs:
build-and-deploy:
name: Build & Deploy
runs-on: ubuntu-latest

permissions:
contents: write # so we can write to github pages without a token
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

steps:
- name: Clone repo
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.10"

- uses: tlambert03/setup-qt-libs@v1

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
python -m pip install "napari[all]"
python -m pip install -e ".[docs]"

- name: Build Docs
uses: aganders3/headless-gui@v2
with:
run: make docs

- name: Check file tree contents
run: tree

# At a minimum this job should upload artifacts using actions/upload-pages-artifact
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: docs/_build

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
106 changes: 106 additions & 0 deletions .github/workflows/test_and_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: test and deploy

on:
push:
branches:
- main
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
pull_request:
branches:
- main
workflow_dispatch:

concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
test:
name: ${{ matrix.platform }}, py${{ matrix.python-version }}, napari ${{ matrix.napari }}
runs-on: ${{ matrix.platform }}
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, windows-latest, macos-13]
python-version: ["3.9", "3.10", "3.11"]
napari: ["latest", "repo"]
exclude:
# TODO: Remove when we have a napari release with the plugin manager changes
- napari: "latest"
# TODO: PyQt / PySide wheels missing
- python-version: "3.11"
platform: "windows-latest"

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- uses: tlambert03/setup-qt-libs@v1

# strategy borrowed from vispy for installing opengl libs on windows
- name: Install Windows OpenGL
if: runner.os == 'Windows'
run: |
git clone --depth 1 https://github.com/pyvista/gl-ci-helpers.git
powershell gl-ci-helpers/appveyor/install_opengl.ps1
if (Test-Path -Path "C:\Windows\system32\opengl32.dll" -PathType Leaf) {Exit 0} else {Exit 1}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools tox tox-gh-actions

- name: Test with tox
uses: aganders3/headless-gui@v2
with:
run: python -m tox -vv
env:
PYVISTA_OFF_SCREEN: True # required for opengl on windows
NAPARI: ${{ matrix.napari }}
FORCE_COLOR: 1
# PySide6 only functional with Python 3.10+
TOX_SKIP_ENV: ".*py39-PySide6.*"

- name: Coverage
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

deploy:
# this will run when you have tagged a commit, starting with "v*"
# and requires that you have put your twine API key in your
# github secrets (see readme for details)
needs: [test]
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools build
- name: Build
run: |
git tag
python -m build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
.napari_cache

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask instance folder
instance/

# Sphinx documentation
docs/_build/

# MkDocs documentation
/site/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# OS
.DS_Store

# written by setuptools_scm
*/_version.py

# pycharm stuff
.idea/

# ruff stuff
.ruff_cache/

# spyder stuff
.spyproject/

# Environment variables file
.env

# Sphinx documentation
docs/_build/

# MkDocs documentation
/site/

# PyBuilder
target/

# IPython Notebook
.ipynb_checkpoints

# pyenv
.python-version

# OS
.DS_Store

# written by setuptools_scm
*/_version.py

# vscode
.vscode

# Images
docs/images/

30 changes: 30 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
repos:
- repo: https://github.com/MarcoGorelli/absolufy-imports
rev: v0.3.1
hooks:
- id: absolufy-imports
- repo: https://github.com/hadialqattan/pycln
rev: v2.4.0
hooks:
- id: pycln
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.10.0
hooks:
- id: black
pass_filenames: true
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.2
hooks:
- id: ruff
- repo: https://github.com/seddonym/import-linter
rev: v2.1
hooks:
- id: import-linter
stages: [manual]
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.29.4
hooks:
- id: check-github-workflows

ci:
autoupdate_schedule: monthly
29 changes: 29 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
BSD 3-Clause License

Copyright (c) 2018, Napari
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
21 changes: 21 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Release Procedure

Here you can find some information about how to trigger a new release over PyPI and subsequent `conda-forge` update.

## PyPI

To release on PyPI you will need to create a new tag. To do so you can:

* Create a [new GitHub release](https://github.com/napari/update-checker/releases/new)
* Use over the new release GitHub page the `Choose a tag` dropdown to create a new tag (it should be something like `vX.Y.Z` incrementing the major, minor or patch number as required).
* Once the tag is defined you should be able to click `Generate release notes`.
* Put as release title the tag that was created (`vX.Y.Z`).
* Publish the release, check that the deploy step was run successfully and that the new version is available at [PyPI](https://pypi.org/project/napari-update-checker/#history)

## conda-forge

To update the `conda-forge` package you will need to update the [`napari-update-checker` feedstock](https://github.com/conda-forge/napari-update-checker-feedstock). **If a new version is already available from PyPI**, you can either wait for the automated PR or trigger one manually:

* Create an issue over the feedstock with the title: [`@conda-forge-admin, please update version`](https://conda-forge.org/docs/maintainer/infrastructure/#conda-forge-admin-please-update-version)
* Tweak the generated PR if necessary (dependencies changes for example).
* Merge the generated PR.
Empty file.
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions napari_update_checker/_tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from napari_update_checker.utils import conda_forge_releases, github_tags


def test_github_tags():
data = github_tags()
assert '0.5.0a1' in data


def test_conda_forge_releases():
data = conda_forge_releases()
assert '0.4.19.post1' in data
Loading