Skip to content
Open
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
2 changes: 0 additions & 2 deletions .githooks/pre-commit/pre-commit

This file was deleted.

17 changes: 17 additions & 0 deletions .github/dependabot.yml
Comment thread
juhoinkinen marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

# This configures updates via dependabot only for github actions.

version: 2
updates:
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: "monthly"
Comment thread
dalito marked this conversation as resolved.
cooldown:
default-days: 5
groups:
github-actions:
patterns:
- "*"
57 changes: 57 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Python package

on:
push:
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
PIP_DISABLE_PIP_VERSION_CHECK: "1"
PIP_PROGRESS_BAR: "off"

permissions: {}

jobs:
tests:
name: Python ${{ matrix.python-version }}
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
matrix:
python-version:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
steps:
- uses: actions/checkout@v6.0.1
with:
persist-credentials: false

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

- name: Install package
run: |
python -m pip install --upgrade pip
python -m pip install .[dev]

- name: Run tests
run: |
python -m pytest

- name: Build Sphinx documentation
run: |
sphinx-build -b html --nitpicky --fail-on-warning --keep-going docs docs/_build/html
67 changes: 67 additions & 0 deletions .github/workflows/pypi-publish.yml
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the different jobs for building and publishing necessary? Running these steps in one job would remove the need for upload-artifact and download-artifact steps.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main reason is security / isolation. The OpenID connect token is only available in pubishing this way. This is now best practice and also suggested in Python packaging guides.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, to me it feels a bit insecure to also download the distribution to publish from another job, but that is suggested also here https://docs.pypi.org/trusted-publishers/security-model/:

  • Limit the scope of your publishing job: your publishing job should (ideally) have only two steps:

    a. Retrieve the publishable distribution files from a separate build job;

    b. Publish the distributions using pypa/gh-action-pypi-publish@release/v1.

By using a separate build job, you keep the number of steps that can access the OIDC token to a bare minimum. This prevents both accidental and malicious disclosure.

For a reference see also this: pypa/gh-action-pypi-publish#324 (comment)

Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Publish Python Package
# Publishes tO PyPI for releases created in GitHub UI
# Note: For draft status, publishing is not triggered.
# Builds a packages for new tags "v1.2.3" or "v1.2.3.something" on master

on:
push:
tags:
# GitHub glob matching is limited [1]. So we can't define a pattern matching
# pep 440 version definition [N!]N(.N)*[{a|b|rc}N][.postN][.devN]
- 'v[0-9]+.[0-9]+.[0-9]+.?*'
release:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to have this workflow trigger on releases too? Previously there was only the trigger on tags.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is triggered on both. Typically I publish to test-pypi on the tag and to pypi by creating a gh release. Note, that below is still the filter to only publish to PyPI for a GitHub-release. if: github.event_name == 'release'

Tell me what you prefer (or change it - committing to the PR is allowed for maintainers).

types: [published]

permissions: {}

jobs:
build:
name: Build Python 🐍 distributions 📦 for publishing
# Don't try to publish from forks
if: github.repository == 'NatLibFi/Skosify'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.1
with:
persist-credentials: false

- name: Set up Python
uses: actions/setup-python@v6.1.0
with:
python-version: 3.13

- name: Install hatch
run: pipx install hatch

- name: Build source and wheel archives
run: hatch build

- name: Store built distribution
uses: actions/upload-artifact@v6.0.0
with:
name: distribution-files
path: dist/

pypi-publish:
name: Build and publish Python 🐍 package 📦 to PyPI and TestPyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi-release
url: https://pypi.org/p/skosify
permissions:
id-token: write # this permission is mandatory for trusted publishing
steps:
- name: Download built distribution
uses: actions/download-artifact@v7.0.0
with:
name: distribution-files
path: dist

- name: Publish package 📦 to PyPI
if: github.event_name == 'release'
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
verbose: true

# [1] https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
43 changes: 0 additions & 43 deletions .github/workflows/python-package.yml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ coverage.xml
# Sphinx documentation
docs/_build/

# Autogenerated version file
skosify/_version.py
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
.PHONY: test docs build

test:
python setup.py test
pytest

doc:
rm -rf docs/_build
$(MAKE) -C docs html

build:
python setup.py bdist_wheel
hatch build
55 changes: 52 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. image:: https://badge.fury.io/py/skosify.svg
:target: https://badge.fury.io/py/skosify.svg
.. image:: https://travis-ci.org/NatLibFi/Skosify.svg?branch=master
:target: https://travis-ci.org/NatLibFi/Skosify
.. image:: https://github.com/NatLibFi/Skosify/workflows/CI/badge.svg
:target: https://github.com/NatLibFi/Skosify/actions
.. image:: https://readthedocs.org/projects/skosify/badge/?version=latest
:target: http://skosify.rtfd.io/
.. image:: https://codecov.io/gh/NatLibFi/Skosify/branch/master/graph/badge.svg
Expand All @@ -18,12 +18,60 @@ the SKOS specification and related best practices.
Installation
============

Skosify requires Python 3.6+.
Skosify requires Python 3.9+.

If you only want to use the command line interface it is suggested to install
with `uv tool <https://docs.astral.sh/uv/concepts/tools/>`_
or `pipx <https://pypa.github.io/pipx/>`_.
Both simplify installing and managing python command line applications.

.. code-block:: console

uv tool install skosify


or

.. code-block:: console

pipx install skosify


Of course you also use pip to install as for any other Python package.

.. code-block:: console

pip install --upgrade skosify


To help testing locally with multiple Python versions, a
`tox <https://tox.wiki/>`_ configuration file is provided (tox.ini).

.. code-block:: console

uv tool install tox

Execute `tox` in the root of the repo to run the full set of tests.
Optionally just run specific environments, for example only Python 3.12:

.. code-block:: console

tox -e py312

The package can be built locally with any PEP517-conform build tool, for example
`build <https://pypi.org/project/build/>`_,
`uv build <https://docs.astral.sh/uv/concepts/build-backend/>`_
or `hatch <https://pypi.org/project/hatch/>`_.
Of course, you need to have the build tool installed.
For example, to use hatch as in gh-actions, run:

.. code-block:: console

uvx hatch build

This command uses `uvx <https://docs.astral.sh/uv/guides/tools/>`_
to run hatch with out installing it permanently.

Usage
=====

Expand Down Expand Up @@ -79,6 +127,7 @@ Author and Contributors
- Jakob Voß
- Dan Michael O. Heggø
- Alex Kourijoki
- David Linke

See also
========
Expand Down
4 changes: 2 additions & 2 deletions docs/background.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ Publications
- Osma Suominen and Christian Mader: Assessing and Improving the
Quality of SKOS Vocabularies. Journal on Data Semantics, vol. 3, no.
1, pp. 47-73, June, 2014
(`PDF <https://seco.cs.aalto.fi/publications/2014/suominen-mader-skosquality.pdf>`_)
(`PDF <https://seco.cs.aalto.fi/publications/2014/suominen-mader-skosquality.pdf>`__)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoids sphinx WARNING: Duplicate explicit target name: "pdf". [docutils]


- Osma Suominen and Eero Hyvönen: Improving the Quality of SKOS
Vocabularies with Skosify. Proceedings of the 18th International
Conference on Knowledge Engineering and Knowledge Management (EKAW
2012), Springer-Verlag, Galway, Ireland, October, 2012
(`PDF <https://seco.cs.aalto.fi/publications/2012/suominen-hyvonen-skosify-2012.pdf>`_)
(`PDF <https://seco.cs.aalto.fi/publications/2012/suominen-hyvonen-skosify-2012.pdf>`__)
54 changes: 40 additions & 14 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
# -*- coding: utf-8 -*-
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

from importlib.metadata import version as pkg_version

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.

import os
import sys
sys.path.insert(0, os.path.abspath('../'))

needs_sphinx = '1.1'
# -- Project information -----------------------------------------------------

extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinx.ext.viewcode']
# General information about the project.
project = u'Skosify'
title = u'Skosify Documentation'
copyright = u'2017, Osma Suominen & Jakob Voß'
author = u'Osma Suominen & Jakob Voß'
# full version, including alpha/beta/rc tags
release = pkg_version("skosify")
# Short version
version = ".".join(release.split(".")[:3])

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.intersphinx',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand All @@ -20,20 +51,12 @@
# The master toctree document.
master_doc = 'index'

# General information about the project.
project = u'Skosify'
title = u'Skosify Documentation'
copyright = u'2017, Osma Suominen & Jakob Voß'
author = u'Osma Suominen & Jakob Voß'
version = '2.0.1' # Use bumpversion to update
release = version

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand All @@ -46,6 +69,8 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False

# In --nitpick mode, ignore missing references to rdflib types
nitpick_ignore = [('py:class', 'Graph')]

# -- Options for HTML output ----------------------------------------------

Expand Down Expand Up @@ -79,7 +104,6 @@
(master_doc, 'Skosify.tex', title, author, 'manual'),
]


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
Expand All @@ -89,4 +113,6 @@
]

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
}
Loading