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

Modernize project #181

Merged
merged 11 commits into from
Feb 23, 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
27 changes: 27 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Publish Python distribution to PyPI

on: push

jobs:
publish-to-pypi:
name: Publish Python distribution to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/grocker
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12"
- name: Install pypa/build
run: pip install build
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
22 changes: 6 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
name: Tests

on:
push:
branches:
- main
pull_request:
schedule:
- cron: '0 0 * * 0' # weekly
on: push

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -16,30 +10,26 @@ jobs:
build:
runs-on: ubuntu-latest

name: Python ${{ matrix.python-version }} / ${{ matrix.django-version }}
name: Python ${{ matrix.python-version }}
strategy:
matrix:
python-version:
- "3.7"
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}
- name: Install dependencies
run: |
python -m pip install tox tox-gh-actions
Expand Down
7 changes: 6 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ ChangeLog
8.1 (unreleased)
----------------

- Nothing changed yet.
- Add support for Python 3.12
- Add support for Python 3.11
- Drop support for Python 3.7
- Drop support for jessie & stretch & buster/3.7 & buster 3.8 runtime.
- Add support for bookworm/3.10 runtime.
- Add support for bookworm/3.12 runtime.


8.0 (2022-03-16)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ quality:
python setup.py check --strict --metadata
python setup.py --quiet sdist && twine check dist/*
check-manifest
flake8 src tests setup.py
flake8 src tests

Quality: # not used in tests
vulture --exclude=build/ src tests setup.py
Expand Down
4 changes: 1 addition & 3 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ check-manifest
flake8
flake8-bandit>=1.0.2
flake8-bugbear
flake8-builtins-unleashed
flake8-commas
flake8-docstrings
flake8-isort
Expand All @@ -24,5 +23,4 @@ tox
vulture

# Release
zest.releaser[recommended]
polydev.github
build
7 changes: 3 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ classifiers =
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Natural Language :: English
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Topic :: Software Development :: Build Tools
Topic :: System :: Software Distribution

Expand All @@ -28,12 +29,10 @@ include_package_data = True
packages = find:
package_dir =
= src
python_requires = >=3.7
python_requires = >=3.8
install_requires =
click
docker>=3.0.0
importlib_metadata; python_version<"3.8"
Copy link
Collaborator

Choose a reason for hiding this comment

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

The following line can also be removed?

importlib_resources; python_version<"3.9"
Jinja2
pip>=10
pyyaml>=3.11
Expand Down
20 changes: 1 addition & 19 deletions src/grocker/__init__.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,6 @@
# Copyright (c) Polyconseil SAS. All rights reserved.

import sys
import warnings

try:
from importlib import metadata
except ImportError:
# Python<3.8: use importlib-metadata package
import importlib_metadata as metadata # type: ignore
from importlib import metadata

__version__ = metadata.version('grocker')
__copyright__ = '2015, Polyconseil'


class GrockerDeprecationWarning(Warning):
pass


if tuple(sys.version_info[:2]) in ((3, 5)):
warnings.warn(
"Support for 3.5 will be dropped in next major version",
category=GrockerDeprecationWarning,
)
2 changes: 1 addition & 1 deletion src/grocker/builders/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def get_manifest_digest(name):
return None # Docker HUB API is not documented

registry, repository = registry_repository.split('/', 1)
response = requests.head(f'https://{registry}/v2/{repository}/manifests/{tag}')
response = requests.head(f'https://{registry}/v2/{repository}/manifests/{tag}', timeout=5)
response.raise_for_status()
return response.headers['Docker-Content-Digest']

Expand Down
86 changes: 8 additions & 78 deletions src/grocker/resources/grocker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,107 +6,37 @@
# - runtime_dependency: [build_dependency_1, build_dependency_2]

runtimes: # grocker internal configuration
"jessie/2.7":
deprecated: yes
image: debian:jessie # base image to use to build root image
runtime: python2.7 # python executable to use
dependencies: # dependencies needed for specified runtime
run:
- python
- libpython2.7
- python-virtualenv
build:
- build-essential
- python-dev

"jessie/3.4":
deprecated: yes
image: debian:jessie
runtime: python3.4
dependencies:
run:
- python3
- libpython3.4
- python3-venv
build:
- build-essential
- python3-dev

"alpine/3.6":
deprecated: yes
image: alpine:latest
runtime: python3
dependencies:
run:
- python3
build:
- alpine-sdk
- python3-dev

"stretch/3.5":
deprecated: yes
image: debian:stretch
runtime: python3.5
dependencies:
run:
- python3
- libpython3.5
- python3-venv
build:
- build-essential
- python3-dev

"stretch/3.6":
deprecated: yes
# XXX: this is a rolling-release tag, so the root image needs to be updated to
# grab the latest upstream image.
image: python:3.6-slim-stretch
runtime: python3
dependencies:
build:
- build-essential

"stretch/3.7":
# XXX: this is a rolling-release tag, so the root image needs to be updated to
# grab the latest upstream image.
deprecated: yes
image: python:3.7-slim-stretch
runtime: python3
dependencies:
build:
- build-essential

"buster/3.7":
"buster/3.9":
# XXX: this is a rolling-release tag, so the root image needs to be updated to
# grab the latest upstream image.
image: python:3.7-slim-buster
image: python:3.9-slim-buster
runtime: python3
dependencies:
build:
- build-essential

"buster/3.8":
"buster/3.10":
# XXX: this is a rolling-release tag, so the root image needs to be updated to
# grab the latest upstream image.
image: python:3.8-slim-buster
image: python:3.10-slim-buster
runtime: python3
dependencies:
build:
- build-essential

"buster/3.9":
"bookworm/3.10":
# XXX: this is a rolling-release tag, so the root image needs to be updated to
# grab the latest upstream image.
image: python:3.9-slim-buster
image: python:3.10-slim-bookworm
runtime: python3
dependencies:
build:
- build-essential

"buster/3.10":
"bookworm/3.12":
# XXX: this is a rolling-release tag, so the root image needs to be updated to
# grab the latest upstream image.
image: python:3.10-slim-buster
image: python:3.12-slim-bookworm
runtime: python3
dependencies:
build:
Expand Down
14 changes: 6 additions & 8 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ def test_from_path(self):
subprocess.check_call( # noqa: S603
[
sys.executable,
'setup.py',
'bdist_wheel',
'--universal',
'-m',
'build',
],
cwd=test_project_path,
)
Expand All @@ -140,9 +139,8 @@ def test_from_path_with_extra(self):
subprocess.check_call( # noqa: S603
[
sys.executable,
'setup.py',
'bdist_wheel',
'--universal',
'-m',
'build',
],
cwd=test_project_path,
)
Expand Down Expand Up @@ -221,7 +219,7 @@ def test_entrypoints(self):


class DebianBuildTestCase(AbstractBuildTestCase, unittest.TestCase):
runtime = 'buster/3.10'
runtime = 'bookworm/3.12'
dependencies = {
'build': ['libjpeg62-turbo-dev'],
'run': ['libjpeg62-turbo'],
Expand All @@ -234,7 +232,7 @@ def test_repositories(self):
'entrypoint_name': 'python',
'repositories': {
'nginx': {
'uri': 'deb http://nginx.org/packages/debian/ jessie nginx',
'uri': 'deb http://nginx.org/packages/debian/ bookworm nginx',
'key': """
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v2.0.22 (GNU/Linux)
Expand Down
13 changes: 6 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
[tox]
envlist = py37, py38, py39, py310, docs, quality
envlist = py38, py39, py310, py311, py312, docs, quality
skip_missing_interpreters = True

[testenv:docs]
deps = -rrequirements-dev.txt
commands = make docs

[testenv:quality]
deps = -rrequirements-dev.txt
commands = make quality

[testenv]
deps = pytest
whitelist_externals = make
deps = -rrequirements-dev.txt
allowlist_externals = make
commands = make tests

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310, docs, quality
3.10: py310
3.11: py311
3.12: py312, docs, quality
Loading