setup.pyからpyproject.tomlへ移行し、Python 3.12~3.14とDjango 5.2をサポート#31
setup.pyからpyproject.tomlへ移行し、Python 3.12~3.14とDjango 5.2をサポート#31kashewnuts merged 6 commits intomasterfrom
Conversation
- setup.py/setup.cfgを削除し、pyproject.tomlへ移行 - tox.iniをpyproject.tomlのlegacy_tox_iniへ移植 - Python 3.12, 3.13, 3.14サポート追加 - Django 5.2サポート追加 - Python 3.8, 3.9サポート終了 - Django 3.2, 4.1, 5.1サポート終了 - namespace packageをpkg_resourcesから暗黙的namespace packageに変更 - CI設定をPython/Djangoの新マトリクスに更新 - factory-boyのDeprecationWarning対応(skip_postgeneration_save) - テストのassertEqualsをassertEqualに修正 - ChangeLog.rst, checklist.rstを更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| matrix: | ||
| python-version: ['3.8', '3.9', '3.10', '3.11'] | ||
| django-version: ['3.2', '4.1', '4.2'] | ||
| python-version: ['3.10', '3.11', '3.12', '3.13', '3.14'] |
There was a problem hiding this comment.
MEMO: Django4.2と5.2の対応状況からバージョン情報を更新
| path: ${{ steps.pip-cache.outputs.dir }} | ||
| key: | ||
| ${{ matrix.python-version }}-v1-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/tox.ini') }} | ||
| ${{ matrix.python-version }}-v1-${{ hashFiles('**/pyproject.toml') }} |
There was a problem hiding this comment.
MEMO: pyproject.tomlに統合したので記述更新
|
|
||
| steps: | ||
| - uses: actions/checkout@v2 | ||
| - uses: actions/checkout@v6 |
There was a problem hiding this comment.
MEMO: actionsのバージョンが古くなっていたので諸々更新
|
|
||
| def assertStatus(self, response, status=200): | ||
| self.assertEquals(response.status_code, status) | ||
| self.assertEqual(response.status_code, status) |
There was a problem hiding this comment.
MEMO: Python3.12でのRemove many long-deprecated unittest features: のため諸々テストメソッドを修正
https://docs.python.org/3/whatsnew/3.12.html#id3
| id: pip-cache | ||
| run: | | ||
| echo "::set-output name=dir::$(pip cache dir)" | ||
| echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT |
There was a problem hiding this comment.
MEMO: どちらも steps.pip-cache.outputs.dir に pip のキャッシュディレクトリパスをセットする処理ですが、::set-output コマンドは 2022年10月にセキュリティ上の理由で非推奨になり、その後廃止されました。代わりに $GITHUB_OUTPUTを利用しています。
ref: https://github.blog/changelog/2022-10-10-github-actions-deprecating-save-state-and-set-output-commands/
|
|
||
| * ``ChangeLog.rst`` next version | ||
| * ``bpcommons/beproud/django/commons/__init__.py`` next version | ||
| * ``beproud/django/commons/__init__.py`` next version |
There was a problem hiding this comment.
MEMO: パスの情報が古かったので更新
|
|
||
| 1. check CI status testing result: https://github.com/beproud/bpcommons/actions | ||
| 2. update release version/date in ``ChangeLog.rst`` | ||
| 3. run ``python setup.py release sdist bdist_wheel`` |
There was a problem hiding this comment.
MEMO: setup.pyは削除されたのでpyprojet.tomlバージョンに移行
| @@ -0,0 +1,70 @@ | |||
| [build-system] | |||
There was a problem hiding this comment.
setup.py/tox.iniにあったものをpyprojet.tomlに統合
ref: https://packaging.python.org/ja/latest/guides/writing-pyproject-toml/
| @@ -1,7 +0,0 @@ | |||
| # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | |||
There was a problem hiding this comment.
MEMO: これは beproud.django.commons のようなドット区切りのパッケージを、複数の配布パッケージに分割するための旧式の仕組みです。setup.py の namespace_packages=['beproud', 'beproud.django'] とセットで機能していました。
pyproject.toml への移行にあたり、PEP 420 の暗黙的 namespace package 方式に切り替えました。この方式では:
__init__.pyに宣言コードが不要(空でよい)- setup.py の namespace_packages 指定も不要
- pkg_resources への依存がなくなる
pkg_resources 方式は現在非推奨で、起動時のインポートが遅い問題もあります。空の __init__.py を残しているのは、beproud/django/commons/init.pyを通常パッケージとして正しく動作させるためです。
There was a problem hiding this comment.
IMO: 空の init.py が残っていると、暗黙的名前空間パッケージにならないと思います。また、他 beproud 名前空間ライブラリも同時に修正しないと、インストール順序によっては競合が発生してしまうと思います。
There was a problem hiding this comment.
@ae35bp 8bab1b4 でnamespace packageを暗黙的方式(PEP 420)に変更しました。合わせてbpnotifyも対応が必要なので beproud/bpnotify#18 で対応しています。
| @@ -1,7 +0,0 @@ | |||
| # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | |||
There was a problem hiding this comment.
Pull request overview
This PR migrates the project's packaging configuration from setup.py/setup.cfg to the modern pyproject.toml format, while also updating supported Python and Django versions. The migration aims to modernize the project infrastructure and expand version support.
Changes:
- Migrated packaging configuration from setup.py/setup.cfg to pyproject.toml with embedded tox configuration
- Updated version support to add Python 3.12, 3.13, 3.14 and Django 5.2 while dropping Python 3.8, 3.9 and Django 3.2, 4.1, 5.1
- Converted from pkg_resources namespace packages to implicit PEP 420 namespace packages
- Updated CI/CD configuration with new Python/Django test matrix and newer GitHub Actions versions
- Fixed deprecated assertEquals method calls to assertEqual
- Added skip_postgeneration_save configuration to factory-boy factories with ManyToMany fields
- Updated documentation (README, ChangeLog, checklist) to reflect version changes and new build process
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | New packaging configuration with project metadata, dependencies, and embedded tox configuration for Python 3.10-3.14 and Django 4.2/5.2 |
| setup.py | Removed old setup.py packaging file |
| setup.cfg | Removed old setup.cfg configuration file |
| tox.ini | Removed standalone tox configuration (migrated to pyproject.toml) |
| beproud/init.py | Converted to empty file for implicit namespace package support |
| beproud/django/init.py | Converted to empty file for implicit namespace package support |
| beproud/django/commons/test/simple.py | Fixed deprecated assertEquals calls to use assertEqual |
| tests/test_models_fields.py | Added skip_postgeneration_save to factory for compatibility with newer factory-boy |
| .github/workflows/ci.yml | Updated CI matrix for new Python/Django versions and updated action versions |
| README.rst | Updated supported Python and Django version documentation |
| ChangeLog.rst | Added release notes for version 0.43 changes |
| checklist.rst | Updated release procedure for pyproject.toml-based builds |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "Topic :: Software Development :: Libraries :: Python Modules", | ||
| ] | ||
| dependencies = [ | ||
| "Django>=4.2", "six", |
There was a problem hiding this comment.
The "six" library is a Python 2/3 compatibility library that is largely unnecessary for projects supporting only Python 3.10+. Since this project drops Python 3.8 and 3.9 support and requires Python 3.10+, consider removing the dependency on "six" and updating the code to use native Python 3 features instead (e.g., replace 'six.text_type' with 'str', 'six.string_types' with 'str', 'six.iteritems()' with '.items()', and 'six.with_metaclass()' with direct class inheritance using 'class Name(Base, metaclass=MetaClass)'). This would modernize the codebase and remove an unnecessary dependency.
There was a problem hiding this comment.
指摘のとおりではあるが、現在このbpcommonsを利用してるプロジェクトの依存(ex: python-dateutil)でもsixが残っておりモチベーションが薄いのと、他の変更も多いので対応しない。
- バージョンを__init__.pyから動的取得に変更(single source of truth) - requires-python >= 3.10 を追加 - license = BSD を追加 - zip-safe = false を追加(setup.pyからの移行漏れ) - packages.findにnamespaces/includeを明示 - checklist.rstからpyproject.tomlのバージョン更新手順を削除 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
pip install -e ".[doc]" でSphinxドキュメントビルド環境を構築可能にした。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| doc = ["sphinx"] |
There was a problem hiding this comment.
requirements-docs.txtから移植しました。
There was a problem hiding this comment.
MAY: 別途、readthedocsの方も対応しないといけなそうですね
この変更でRTDのビルドは影響を受けるだろうか、と確認したら、だいぶ前からビルドが失敗していたようです。
https://app.readthedocs.org/projects/bpcommons/
優先度は高くないと思うので、別途対応でよさそうです。
Python 3.12以降で発生するSyntaxWarningを解消。 - IP_ADDRESS_REをraw stringに変更 - docstring内の\sを\\sにエスケープ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
||
| # See: http://www.regular-expressions.info/regexbuddy/ipaccurate.html | ||
| IP_ADDRESS_RE = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' | ||
| IP_ADDRESS_RE = r'(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' |
There was a problem hiding this comment.
Python 3.12以降で発生するSyntaxWarningを解消しました
| @@ -1,7 +0,0 @@ | |||
| # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | |||
There was a problem hiding this comment.
IMO: 空の init.py が残っていると、暗黙的名前空間パッケージにならないと思います。また、他 beproud 名前空間ライブラリも同時に修正しないと、インストール順序によっては競合が発生してしまうと思います。
| @@ -1,7 +0,0 @@ | |||
| # See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages | |||
pyproject.toml
Outdated
|
|
||
| [tool.setuptools.packages.find] | ||
| where = ["."] | ||
| namespaces = false |
There was a problem hiding this comment.
IMO: namespaces = false だと、init.py を残さなければ名前空間パッケージとして認識されなくなるため、暗黙的名前空間パッケージ対応と相反してしまっていると思います
There was a problem hiding this comment.
@ae35bp 8bab1b4 でnamespace packageを暗黙的方式(PEP 420)に変更しました。合わせてbpnotifyも対応が必要なので beproud/bpnotify#18 で対応しています。
pkg_resourcesはsetuptools>=81で削除されたため、 pkgutil.extend_pathのみでnamespace packageを実現する。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bpnotifyとの共存時にファイル競合が構造的に発生しない暗黙的namespace package方式に変更。beproud/__init__.pyとbeproud/django/__init__.pyを 削除し、pyproject.tomlのincludeをbeproud.django.commons*に限定。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
shimizukawa
left a comment
There was a problem hiding this comment.
LGTM!
メンテありがとうございます。
名前空間パッケージについてのコメントが進行中ですが、他のパッケージも合わせる方向で進んでいるようなので、私からはApproveとしておきます。
1点、RTDについてコメントしましたが、このPRとは別で良いと思います。
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| doc = ["sphinx"] |
There was a problem hiding this comment.
MAY: 別途、readthedocsの方も対応しないといけなそうですね
この変更でRTDのビルドは影響を受けるだろうか、と確認したら、だいぶ前からビルドが失敗していたようです。
https://app.readthedocs.org/projects/bpcommons/
優先度は高くないと思うので、別途対応でよさそうです。
何を達成したいのか、なぜその変更をしたか
具体的な変更内容
実装時に確認したこと
python -m build .とtwine check --strict dist/*が実行できることpip install -e ".[doc]"とdocs/jaディレクトリでの make html の両方が動作すること特にレビューしてほしいこと