Skip to content

Commit

Permalink
Merge pull request #16 from ssciwr/update_build_system
Browse files Browse the repository at this point in the history
Use hatchling instead of setuptools
  • Loading branch information
lkeegan authored Jul 4, 2024
2 parents df4246e + 552466b commit b9f45b8
Show file tree
Hide file tree
Showing 13 changed files with 22 additions and 55 deletions.
4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# setuptools_scm requires a non-shallow clone of the repository
fetch-depth: 0

# qt requires some system libraries on linux that are not installed by default
- name: Install system libs required by Qt on linux
uses: tlambert03/setup-qt-libs@v1

Expand Down
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
repos:
# Run Black - the uncompromising Python code formatter
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 24.4.2
hooks:
- id: black-jupyter

# Add some general purpose useful hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
# Make sure that contained YAML files are well-formed
- id: check-yaml
Expand All @@ -23,13 +23,13 @@ repos:
# Make sure that Jupyter notebooks under version control
# have their outputs stripped before committing
- repo: https://github.com/kynan/nbstripout
rev: 0.6.1
rev: 0.7.1
hooks:
- id: nbstripout
files: ".ipynb"

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991
rev: v1.10.1
hooks:
- id: mypy
additional_dependencies: [numpy, PyQt5-stubs]
Expand Down
2 changes: 0 additions & 2 deletions effective_software_testing/__init__.py

This file was deleted.

26 changes: 13 additions & 13 deletions notebooks/prototyping.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"cells": [
{
"cell_type": "markdown",
"id": "819be38a-921a-485a-8e1f-58daeadc14ac",
"id": "0",
"metadata": {},
"source": [
"# Using pytest in a notebook"
]
},
{
"cell_type": "markdown",
"id": "55984bca-1e25-45f9-8c31-ce080b2cdcfb",
"id": "1",
"metadata": {},
"source": [
"Here is a function we are prototyping in this notebook:"
Expand All @@ -19,7 +19,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "89c489c7-9c94-43ee-9696-a4e56681fd8f",
"id": "2",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -31,7 +31,7 @@
},
{
"cell_type": "markdown",
"id": "0a631bf8",
"id": "3",
"metadata": {},
"source": [
"We would probably check it does what we want by calling it with a couple of examples, e.g.:"
Expand All @@ -40,7 +40,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "e2913ab6-3ae7-40ae-84ef-258bc757676c",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -50,7 +50,7 @@
},
{
"cell_type": "markdown",
"id": "eb8e87dc-5e78-4b1c-b880-a948658b13d9",
"id": "5",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -59,7 +59,7 @@
},
{
"cell_type": "markdown",
"id": "f4130905",
"id": "6",
"metadata": {},
"source": [
"First we import ipytest (`pip install ipytest` if not installed) and configure it (this only needs to be done once in a notebook):"
Expand All @@ -68,7 +68,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "637f74fc",
"id": "7",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -79,7 +79,7 @@
},
{
"cell_type": "markdown",
"id": "cca7db93",
"id": "8",
"metadata": {},
"source": [
"Then in any cell where we define a pytest test (i.e. any function whose name begins with test that contains assertions), we can add the magic `%%ipytest` to execute it using pytest:"
Expand All @@ -88,7 +88,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "38f842ea",
"id": "9",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -101,7 +101,7 @@
},
{
"cell_type": "markdown",
"id": "d320c72c",
"id": "10",
"metadata": {},
"source": [
"Now we get a nice pytest traceback in our notebook when a test fails:"
Expand All @@ -110,7 +110,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d479569f",
"id": "11",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -123,7 +123,7 @@
},
{
"cell_type": "markdown",
"id": "bc3b23b2",
"id": "12",
"metadata": {},
"source": [
"And if one day we transfer this function to a python module or package we can then easily copy over our pytest tests as well!"
Expand Down
36 changes: 4 additions & 32 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
# This section describes the requirements of the build/installation
# process itself. Being able to do this was the original reason to
# introduce pyproject.toml
[build-system]
requires = [
"setuptools >=61",
"setuptools_scm >=7",
]
build-backend = "setuptools.build_meta"
requires = ["hatchling"]
build-backend = "hatchling.build"

# This section provides general project metadata that is used across
# a variety of build tools. Notably, the version specified here is the
# single source of truth for effective_software_testing's version
[project]
name = "effective_software_testing"
description = "Example code from the SSC compact course Effective Software Testing"
Expand Down Expand Up @@ -47,24 +38,5 @@ tests = [
[project.scripts]
tic-tac-toe = "effective_software_testing.__main__:main"

# The following section contains setuptools-specific configuration
# options. For a full reference of available options, check the overview
# at https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
[tool.setuptools]
packages = [
"effective_software_testing",
]

# Configure setuptools_scm, which extracts the version number from
# the version control system. For more information see its documentation:
# https://github.com/pypa/setuptools_scm
[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "node-and-date"
write_to = "effective_software_testing/_version.py"

# The following is the configuration for the pytest test suite
[tool.pytest.ini_options]
testpaths = [
"tests"
]
[tool.hatch]
version.path = "src/effective_software_testing/__init__.py"
Empty file removed setup.cfg
Empty file.
1 change: 1 addition & 0 deletions src/effective_software_testing/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "1.0.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b9f45b8

Please sign in to comment.