Skip to content

Commit

Permalink
Updated packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
tonioo committed Dec 2, 2024
1 parent f8b328f commit 6f08361
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 71 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
strategy:
matrix:
database: ['postgres', 'mysql']
python-version: [3.8, 3.9, '3.10', '3.11']
python-version: [3.9, '3.10', '3.11', '3.12']
fail-fast: false

steps:
Expand All @@ -74,9 +74,9 @@ jobs:
cd ..
git clone https://github.com/modoboa/modoboa.git
cd modoboa
python setup.py develop
pip install -e .
cd ../modoboa-radicale
python setup.py develop
pip install -e .
echo "Testing redis connection"
redis-cli -h $REDIS_HOST -p $REDIS_PORT ping
env:
Expand All @@ -92,7 +92,7 @@ jobs:
run: |
echo "DB=mysql" >> $GITHUB_ENV
- name: Test with pytest
if: ${{ matrix.python-version != '3.11' || matrix.database != 'postgres' }}
if: ${{ matrix.python-version != '3.12' || matrix.database != 'postgres' }}
run: |
cd test_project
python3 manage.py test modoboa_radicale
Expand All @@ -107,7 +107,7 @@ jobs:
REDIS_PORT: ${{ job.services.redis.ports[6379] }}

- name: Test with pytest and coverage
if: ${{ matrix.python-version == '3.11' && matrix.database == 'postgres' }}
if: ${{ matrix.python-version == '3.12' && matrix.database == 'postgres' }}
run: |
cd test_project
coverage run --source ../modoboa_radicale manage.py test modoboa_radicale
Expand All @@ -123,7 +123,7 @@ jobs:
REDIS_HOST: localhost
REDIS_PORT: ${{ job.services.redis.ports[6379] }}
- name: Upload coverage result
if: ${{ matrix.python-version == '3.11' && matrix.database == 'postgres' }}
if: ${{ matrix.python-version == '3.12' && matrix.database == 'postgres' }}
uses: actions/upload-artifact@v4
with:
name: coverage-results
Expand Down Expand Up @@ -157,10 +157,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'
- name: Build frontend
shell: bash -l {0}
run: |
Expand All @@ -172,16 +172,16 @@ jobs:
- name: Build packages
run: |
sudo apt-get install librrd-dev rrdtool libssl-dev gettext
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade pip build
pip install -r requirements.txt
cd ..
git clone https://github.com/modoboa/modoboa.git
cd modoboa
python setup.py develop
pip install -e .
cd ../modoboa-radicale/modoboa_radicale
django-admin compilemessages
cd ..
python setup.py sdist bdist_wheel
python -m build
- name: Publish to Test PyPI
if: endsWith(github.event.ref, '/master')
uses: pypa/gh-action-pypi-publish@release/v1
Expand Down
16 changes: 16 additions & 0 deletions modoboa_radicale/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import os


def local_scheme(version):
return ""


def get_version():
from setuptools_scm import get_version as default_version

github_version = os.environ.get("GITHUB_REF_NAME", None)
github_type = os.environ.get("GITHUB_REF_TYPE", None)
if github_version is not None and github_type == "tag":
print(f"GITHUB_REF_NAME found, using version: {github_version}")
return github_version
return default_version(local_scheme=local_scheme)
46 changes: 46 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[build-system]
requires = ["setuptools>=61.0", "setuptools_scm[toml]>=6.4"]
build-backend = "setuptools.build_meta"

[project]
name = "modoboa-radicale"
dynamic = [
"version",
"dependencies",
"optional-dependencies"
]
authors = [
{ name="Antoine Nguyen", email="[email protected]" },
]
description = "The Radicale frontend of Modoboa"
readme = "README.rst"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django :: 4.2",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: ISC License (ISCL)",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Communications :: Email",
"Topic :: Internet :: WWW/HTTP",
]
keywords = ["modoboa", "email", "radicale", "calendar", "caldav"]
license = {file = "LICENSE"}

[project.urls]
Homepage = "https://modoboa.org/"
Documentation = "https://modoboa.readthedocs.io/en/latest/"
Repository = "https://github.com/modoboa/modoboa-radicale"
Changelog = "https://github.com/modoboa/modoboa-radicale/blob/master/CHANGELOG.md"
Issues = "https://github.com/modoboa/modoboa-radicale/issues"

[tool.setuptools.dynamic]
version = {attr = "modoboa_radicale.version.get_version"}
dependencies = {file = ["requirements.txt"]}
optional-dependencies.test = { file = ["test-requirements.txt"] }
57 changes: 1 addition & 56 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,10 @@
https://packaging.python.org/en/latest/distributing.html
"""

import io
from os import path

try:
from pip.req import parse_requirements
except ImportError:
# pip >= 10
from pip._internal.req import parse_requirements

from setuptools import setup, find_packages


def get_requirements(requirements_file):
"""Use pip to parse requirements file."""
requirements = []
dependencies = []
if path.isfile(requirements_file):
for req in parse_requirements(requirements_file, session="hack"):
try:
# check markers, such as
#
# rope_py3k ; python_version >= '3.0'
#
if req.match_markers():
requirements.append(str(req.req))
if req.link:
dependencies.append(str(req.link))
except AttributeError:
requirements.append(req.requirement)
return requirements, dependencies


def local_scheme(version):
"""
Skip the local version (eg. +xyz of 0.6.1.dev4+gdf99fe2)
Expand All @@ -50,41 +22,14 @@ def local_scheme(version):

if __name__ == "__main__":
HERE = path.abspath(path.dirname(__file__))
INSTALL_REQUIRES, DEPENDENCY_LINKS = (
get_requirements(path.join(HERE, "requirements.txt")))

with io.open(path.join(HERE, "README.rst"), encoding="utf-8") as readme:
with open(path.join(HERE, "README.rst"), encoding="utf-8") as readme:
LONG_DESCRIPTION = readme.read()

setup(
name="modoboa-radicale",
description="The Radicale frontend of Modoboa",
long_description=LONG_DESCRIPTION,
license="MIT",
url="http://modoboa.org/",
author="Antoine Nguyen",
author_email="[email protected]",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django :: 2.2",
"Intended Audience :: System Administrators",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Communications :: Email",
"Topic :: Internet :: WWW/HTTP",
],
keywords="modoboa email radicale calendar caldav",
packages=find_packages(exclude=["docs", "test_project"]),
include_package_data=True,
zip_safe=False,
install_requires=INSTALL_REQUIRES,
dependency_links=DEPENDENCY_LINKS,
use_scm_version={"local_scheme": local_scheme},
setup_requires=["setuptools_scm"],
)
7 changes: 3 additions & 4 deletions test_project/test_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
https://docs.djangoproject.com/en/1.11/ref/settings/
"""

from __future__ import unicode_literals

from logging.handlers import SysLogHandler
import os

Expand Down Expand Up @@ -56,6 +54,8 @@
'reversion',
'ckeditor',
'ckeditor_uploader',
'oauth2_provider',
'corsheaders',
'rest_framework',
'rest_framework.authtoken',
'django_otp',
Expand Down Expand Up @@ -92,11 +92,10 @@
MIDDLEWARE = (
'x_forwarded_for.middleware.XForwardedForMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'corsheaders.middleware.CorsMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django_otp.middleware.OTPMiddleware',
'modoboa.core.middleware.TwoFAMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
Expand Down

0 comments on commit 6f08361

Please sign in to comment.