Skip to content
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
2 changes: 1 addition & 1 deletion .github/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
distutils-pytest
git-props
pytest >=3.0.0
setuptools_scm
systemd-python
31 changes: 31 additions & 0 deletions .github/workflows/publish-to-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Publish
on:
release:
types:
- published
jobs:
PyPI:
name: publish release to PyPI
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
env:
SDIST: auto-patch-${{ github.event.release.tag_name }}.tar.gz
steps:
- name: Fetch assets
uses: cb80/dlassets@latest
with:
tag: ${{ github.event.release.tag_name }}
to: assets
- name: Check assets
run: |
ls -la assets
- name: Copy distfile to dist directory
run: |
mkdir -p dist
cp -p assets/$SDIST dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ Bug fixes and minor changes
+ `#15`_, `#18`_: Send a report also in the case of certain errors
from zypper.
+ `#16`_, `#17`_: Review of the test framework.
+ `#19`_: Review build tool chain.

.. _#14: https://github.com/RKrahl/auto-patch/pull/14
.. _#15: https://github.com/RKrahl/auto-patch/issues/15
.. _#16: https://github.com/RKrahl/auto-patch/issues/16
.. _#17: https://github.com/RKrahl/auto-patch/pull/17
.. _#18: https://github.com/RKrahl/auto-patch/pull/18
.. _#19: https://github.com/RKrahl/auto-patch/pull/19


1.1.0 (2022-10-03)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ distclean: clean
rm -rf dist
rm -rf tests/.pytest_cache


meta:
$(PYTHON) setup.py meta


.PHONY: build test sdist clean distclean meta
24 changes: 15 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,20 @@ Required library packages:

+ `python-systemd`_

Note: it is recommended to install this from the package repository
of your Linux distribution, e.g. on openSUSE and SLE, run something
like `zypper install python3-systemd`. If you need to install it
from PyPI, please note that the package name there is `systemd-python`_.

Optional library packages:

+ `setuptools_scm`_
+ `git-props`_

The version number is managed using this package. All source
distributions add a static text file with the version number and
fall back using that if `setuptools_scm` is not available. So this
package is only needed to build out of the plain development source
tree as cloned from GitHub.
This package is used to extract some metadata such as the version
number out of git, the version control system. All releases embed
that metadata in the distribution. So this package is only needed
to build out of the plain development source tree as cloned from
GitHub, but not to build a release distribution.

+ `pytest`_ >= 3.0

Expand All @@ -58,10 +63,10 @@ Optional library packages:
Copyright and License
---------------------

Copyright 2020–2022 Rolf Krahl
Copyright 2020–2025 Rolf Krahl

Licensed under the `Apache License`_, Version 2.0 (the "License"); you
may not use this file except in compliance with the License.
may not use this package except in compliance with the License.

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -73,7 +78,8 @@ permissions and limitations under the License.
.. _zypper: https://github.com/openSUSE/zypper
.. _setuptools: https://github.com/pypa/setuptools/
.. _python-systemd: https://github.com/systemd/python-systemd
.. _setuptools_scm: https://github.com/pypa/setuptools_scm
.. _systemd-python: https://pypi.org/project/systemd-python/
.. _git-props: https://github.com/RKrahl/git-props
.. _pytest: https://pytest.org/
.. _distutils-pytest: https://github.com/RKrahl/distutils-pytest
.. _Apache License: https://www.apache.org/licenses/LICENSE-2.0
48 changes: 36 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import setuptools
from setuptools import setup
import distutils.command.sdist
import distutils.dist
from distutils import log
from glob import glob
from pathlib import Path
import string
try:
Expand All @@ -18,37 +18,55 @@
except (ImportError, AttributeError):
cmdclass = dict()
try:
import setuptools_scm
version = setuptools_scm.get_version()
import gitprops
release = gitprops.get_last_release()
release = release and str(release)
version = str(gitprops.get_version())
except (ImportError, LookupError):
try:
import _meta
version = _meta.__version__
from _meta import release, version
except ImportError:
log.warn("warning: cannot determine version number")
version = "UNKNOWN"
release = version = "UNKNOWN"

docstring = __doc__


# Enforcing of PEP 625 has been added in setuptools 69.3.0. We don't
# want this, we want to keep control on the name of the sdist
# ourselves. Disable it.
def _fixed_get_fullname(self):
return "%s-%s" % (self.get_name(), self.get_version())

distutils.dist.DistributionMetadata.get_fullname = _fixed_get_fullname


class meta(setuptools.Command):

description = "generate meta files"
user_options = []
meta_template = '''
__version__ = "%(version)s"
release = %(release)r
version = %(version)r
'''

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
version = self.distribution.get_version()
log.info("version: %s", version)
values = {
'version': self.distribution.get_version(),
'doc': docstring
'release': release,
'version': version,
}
with Path("_meta.py").open("wt") as f:
print(self.meta_template % values, file=f)


# Note: Do not use setuptools for making the source distribution,
# rather use the good old distutils instead.
# Rationale: https://rhodesmill.org/brandon/2009/eby-magic/
Expand All @@ -62,8 +80,8 @@ def run(self):
"description": docstring.split("\n")[0],
"long_description": docstring.split("\n", maxsplit=2)[2].strip(),
}
for spec in glob("*.spec"):
with Path(spec).open('rt') as inf:
for spec in Path().glob("*.spec"):
with spec.open('rt') as inf:
with Path(self.dist_dir, spec).open('wt') as outf:
outf.write(string.Template(inf.read()).substitute(subst))

Expand All @@ -76,6 +94,7 @@ def run(self):
version = version,
description = docstring.split("\n")[0],
long_description = readme,
long_description_content_type = "text/x-rst",
url = "https://github.com/RKrahl/auto-patch",
author = "Rolf Krahl",
author_email = "rolf@rotkraut.de",
Expand All @@ -94,10 +113,15 @@ def run(self):
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: System :: Systems Administration",
],
project_urls = dict(
Source="https://github.com/RKrahl/auto-patch",
Download=("https://github.com/RKrahl/auto-patch/releases/%s/" % release),
),
python_requires = ">=3.6",
install_requires = ["systemd"],
install_requires = ["setuptools", "systemd-python"],
packages = [],
py_modules = [],
scripts = ["scripts/auto-patch.py"],
Expand Down