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

add Python3.9 and Django 2.2 support, drop Python2.7 and Django 1.11support #13

Merged
merged 35 commits into from
Mar 11, 2022

Conversation

imaxyz
Copy link
Contributor

@imaxyz imaxyz commented Mar 4, 2022

目的

  • bpmailerのユニットテストが、Python 3.6, Python 3.9. Django 2.2の環境でpassするようにすること
  • Python 2.7とDjango 1.11のサポートを止めること

作業内容

  • toxがfailしてしまったため、Djangoのテストランナーに渡す単体テストのPathの書き方を修正しました。
  • Travis CIの使用を止めて、Github Actionsでtoxを実行するように変更しました。
    • Travis CIの設定ファイルを削除しました。
    • tox.iniに、Github Actionsの設定を追記しました。
  • ローカル環境で単体テストする際に使う意図でrequirements.txtを新規作成しました。
  • READMEの書式をmarkdownからreStructuredTxtに変更しました。

レビューしてほしいところ

  • .github/workflows/tests.yml の書き方は問題ないか
  • tox.iniの書き方に不足はないか
  • コメントに違和感はないか
  • バージョン1.2をリリースするにあたって、何か他に変更が必要な点はあるか

@imaxyz imaxyz changed the title [WIP] add Python3.9 + Django 2.2 support add Python3.9 + Django 2.2 support Mar 4, 2022
@imaxyz imaxyz marked this pull request as ready for review March 4, 2022 08:34
@imaxyz imaxyz closed this Mar 4, 2022
@imaxyz imaxyz reopened this Mar 4, 2022
@imaxyz imaxyz marked this pull request as draft March 4, 2022 08:41
test_runner = TestRunner()

# set 'bpmailer unit test path' and run the unit test
failures = test_runner.run_tests(['beproud.django.mailer.tests'])
Copy link
Contributor Author

@imaxyz imaxyz Mar 9, 2022

Choose a reason for hiding this comment

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

(Djangoのバージョンが変わったためか?) toxが通らなくなっていたので、Djangoのrun_tests()メソッドのドキュメントを参考に、テストモジュールへのPathを修正しました。

Test labels should be dotted Python paths to test modules, test classes, or test methods.

https://github.com/django/django/blob/e541f2d05b88e58c18b82b622aacc38d670eb5f6/django/test/runner.py#L618

Copy link
Contributor

Choose a reason for hiding this comment

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

原因はsetuptoolsの更新のためのようです。 変更自体はまずはこれでよさそう。

このPRで対応するかは任せますが、 python setup.py test コマンド自体が非推奨になっているのでpytestに置き換えた方がよさそうです。 https://setuptools.pypa.io/en/latest/userguide/commands.html?highlight=test_suite#test-build-package-and-run-a-unittest-suite

image

Copy link
Member

Choose a reason for hiding this comment

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

MUST: レビューのために、この修正の妥当性の説明が欲しいです。

(Djangoのバージョンが変わったためか?)

確信はないけどこうしたら動いた、ということでしょうか。

Copy link
Contributor Author

@imaxyz imaxyz Mar 11, 2022

Choose a reason for hiding this comment

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

現在 bpmailerのtoxがfailする原因について

@kashewnuts

  • 頂いたコメントに関して、py36, py39共に、bpmailerのtox.iniの testenv - deps の項目に、次の行を追加することでtoxから実行する単体テストがpassすることを確認しました。
setuptools<=51.1.2

この改修がsetuptoolsの51.1.2の次のバージョンである51.2.0でマージされたことも確認しました

このことから、今回の作業でbpmailerのtoxがfailしている原因は、setuptoolsが、bpmailerをpy36対応した時の作業の時と比べてバージョンアップしていて、動作が変わっていたことが原因と思いました。

python setup.py test コマンドが非推奨の件

@kashewnuts

#14 でissueにしました。別PRで対応できればと思います。

今回の改修方法の妥当性について

@shimizukawa

(Djangoのバージョンが変わったためか?)

最初上記のようにコメントしたのですが、上述のsetuptoolsの調査結果から、Djnagoのバージョンは関係なさそうです。

setuptoolsの改修で使われているメソッドの差分について調べられたらベストなのですが、まだ調べられていません。

改修方法の妥当性について、確信は無いのですが、bpmailerが使用するバージョンのDjnagoのrun_tests()のコメント

Test labels should be dotted Python paths to test modules, test classes, or test methods.
意訳: ラベルは「テストモジュールか、テストクラスか、テストメソッド」にすべき

と書かれているのに対して、テストモジュールの上位のパッケージ名(mailer)を指定していることから、Djangoが想定するパラメータ仕様に近づける意味で、適切ではと考えました。

# before
test_runner.run_tests(['beproud.django.mailer'])

# after
test_runner.run_tests(['beproud.django.mailer.tests'])

あと、tox.iniのdeps項目に、setuptoolsのバージョンを指定すべきか?を考えました。

現在の改修方法だと、setuptoolsのバージョンが51.2.0未満でも51.2.0以上でもtoxがpassしました。
なので、tox.iniにsetuptoolsのバージョン指定を記述する必要ないと考えました。

Copy link
Member

Choose a reason for hiding this comment

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

OKです。別PRでtest.pyを削除するのであれば、問題ないです。

@imaxyz imaxyz marked this pull request as ready for review March 9, 2022 03:15
@imaxyz imaxyz requested review from ae35bp, mtb-beta, shimizukawa and posbin and removed request for shimizukawa, mtb-beta and ae35bp March 9, 2022 03:18
README.md Outdated
@@ -2,6 +2,6 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

SHOULD: travisの結果を見ているのでGitHub Action版に変更してください。

Copy link
Contributor Author

@imaxyz imaxyz Mar 10, 2022

Choose a reason for hiding this comment

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

  • アイコンをGithub Actionsの結果を表示するように修正しました。
  • アイコンを選択した際に、https://github.com/beproud/bpmailer/actions に遷移させたかったので、rst形式に変更しました。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

補足

Markdownだとsvg画像へリンクする記述方法しか見当たりませんでした。

https://docs.github.com/ja/actions/monitoring-and-troubleshooting-workflows/adding-a-workflow-status-badge

バッチアイコンを選択して、バッチの画像をダウンロードするよりか、より情報が多いWebページに遷移した方が良いと考え、rstに変更してみました

@imaxyz imaxyz changed the title add Python3.9 + Django 2.2 support add Python3.9 + Django 2.2 support, drop Python2.7, Django 1.11support Mar 11, 2022
strategy:
max-parallel: 4
matrix:
python-version: ['3.6', '3.9']

Choose a reason for hiding this comment

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

3.6はすでにEOLです。3.7に修正して良さそう

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kemu3007 このbpmailerを使いたいプロジェクトがまだPython3.6を使っているため、現時点ではPython3.6対応は残したい感じです。

@imaxyz imaxyz changed the title add Python3.9 + Django 2.2 support, drop Python2.7, Django 1.11support add Python3.9 and Django 2.2 support, drop Python2.7 and Django 1.11support Mar 11, 2022
Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

レビューしました


# 並列して実行する各ジョブのPythonバージョン
strategy:
max-parallel: 4
Copy link
Member

Choose a reason for hiding this comment

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

ASK: これ要りますか?(制限しているのを初めて見た)

無指定にして、実行環境で使えるだけ使えばよいのでは。

requirements.txt Outdated
@@ -0,0 +1,5 @@
# toxを使用せず、直接 python tests.py で単体テスト実行する際に pip installするパッケージ一覧です。
Copy link
Member

Choose a reason for hiding this comment

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

SHOULD: ファイル名を requirements-test.txt 等にして、テストでのみ必要という意味を持たせて欲しい。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ファイル名を修正しました。

test_runner = TestRunner()

# set 'bpmailer unit test path' and run the unit test
failures = test_runner.run_tests(['beproud.django.mailer.tests'])
Copy link
Member

Choose a reason for hiding this comment

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

OKです。別PRでtest.pyを削除するのであれば、問題ないです。


[travis:env]
DJANGO =
1.11: django111
Copy link
Member

Choose a reason for hiding this comment

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

MUST: 1.11をドロップしたのであれば、setup.pyも更新してください。

install_requires=['Django>=1.11', 'six'],

以下、ついでに依頼です。
classifiers も更新お願いします。

bpmailer/setup.py

Lines 51 to 59 in e44f6b4

classifiers=[
'Development Status :: 3 - Alpha',
'Environment :: Plugins',
'Framework :: Django',
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules',
],

参考記述

https://github.com/jazzband/django-redshift-backend/blob/6b862eca2e1c6d5f66fe0dd4e1646be573256f59/setup.cfg#L15-L25

Copy link
Contributor Author

Choose a reason for hiding this comment

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

setup.pyの記述内容を修正しました。

@imaxyz imaxyz requested a review from shimizukawa March 11, 2022 06:14
Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

LGTM + 1つ「できれば」依頼

setup.py Outdated
'Topic :: Software Development :: Libraries :: Python Modules',
],
include_package_data=True,
packages=find_packages(),
namespace_packages=['beproud', 'beproud.django'],
install_requires=['Django>=1.11', 'six'],
install_requires=['Django>=2.2', 'six'],
Copy link
Member

Choose a reason for hiding this comment

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

すみません、もう1個思い出しました。
できれば対応お願いします。

Py2 drop するのであれば、 python_requires で3.6以上を指定して下さい。
https://packaging.python.org/en/latest/guides/distributing-packages-using-setuptools/#python-requires


https://github.com/jazzband/django-redshift-backend/blob/master/setup.cfg#L36

Copy link
Contributor Author

Choose a reason for hiding this comment

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

追記しました

Copy link
Contributor

@kashewnuts kashewnuts left a comment

Choose a reason for hiding this comment

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

LGTM with nits. 直近の作業には影響しないレベルだと思います。

# Github Actionsからtoxを実行
- name: Test with tox
run: |
tox -l
Copy link
Contributor

Choose a reason for hiding this comment

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

マトリクス対応したので -l は不要な認識です。削除してください。 https://github.com/beproud/bpmailer/pull/13/files#r824402013
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

削除しました

@@ -0,0 +1,5 @@
# toxを使用せず、直接 python tests.py で単体テスト実行する際に pip installするパッケージ一覧です。
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO: この後Django3.2対応もあると思うので、Django2.2固定のこのファイルは削除することになると思います。なのでこのPRでは一旦よいかもしれませんが、後々は削除したほうが第三者が混乱しなくてよさそうです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

なるほどです。ryです。今回は残しておきます。

setup.py Outdated Show resolved Hide resolved
tox.ini Outdated
@@ -1,29 +1,21 @@
# Requires tox > 1.8

[tox]
envlist = py27-django111, py36-django{111,22}
envlist = py36-django22, py39-django22
Copy link
Contributor

Choose a reason for hiding this comment

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

nits: 書き方を省略できます #13 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

suggestionを見落としていました。

修正しました。

@imaxyz imaxyz merged commit e0afce2 into master Mar 11, 2022
@imaxyz imaxyz deleted the py39-django22 branch March 11, 2022 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants