avibrazil / autorsync

Command to automate execution of various rsyncs based on profiles defined on a YAML configuration file
GNU General Public License v3.0
0 stars 0 forks source link

distutils package is deprecated #1

Open hegjon opened 1 year ago

hegjon commented 1 year ago

From build log when building RPM package

/builddir/build/BUILD/auto_remote_sync-1.0.5/setup.py:3: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
  import distutils
hegjon commented 1 year ago

It might be that the RPM build macros are the issue

gotmax23 commented 1 year ago

It might be that the RPM build macros are the issue

They are not. The setup.py imports distutils, which is deprecated and will be removed in Python 3.12. This should use setuptools.setup() instead.

Other suggestions:

hegjon commented 1 year ago

The setup.py imports the package itself to extract version. That is not the correct way to extract version from the package and is bad practice that has multiple potential pitfalls

One of the pitfalls is that the RPM tool that want to read the dependencies, will fail if the dependency is not installed:

+ /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --generate-extras --python3_pkgversion 3 --wheeldir /builddir/build/BUILD/auto_remote_sync-1.0.5/pyproject-wheeldir
Handling setuptools >= 40.8 from default build backend
Requirement satisfied: setuptools >= 40.8
   (installed: setuptools 59.6.0)
Handling wheel from default build backend
Requirement satisfied: wheel
   (installed: wheel 0.37.1)
Traceback (most recent call last):
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 501, in main
    generate_requires(
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 415, in generate_requires
    generate_build_requirements(backend, requirements)
  File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 265, in generate_build_requirements
    new_reqs = get_requires()
  File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel
    return self._get_build_requires(
  File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires
    self.run_setup()
  File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 267, in run_setup
    super(_BuildMetaLegacyBackend,
  File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup
    exec(compile(code, __file__, 'exec'), locals())
  File "setup.py", line 5, in <module>
    from autorsync import __version__
  File "/builddir/build/BUILD/auto_remote_sync-1.0.5/autorsync/__init__.py", line 9, in <module>
    import yaml
ModuleNotFoundError: No module named 'yaml'
error: Bad exit status from /var/tmp/rpm-tmp.wHpst0 (%generate_buildrequires)
    Bad exit status from /var/tmp/rpm-tmp.wHpst0 (%generate_buildrequires)

See https://bugzilla.redhat.com/show_bug.cgi?id=2151315#c6 for details

avibrazil commented 1 year ago

Do you know the correct way to extract version? I can fix it.

Thank you in advance AVI ALKALAY @avibrazil +55(11)99659-9059 <+5511996599059> digital business card https://avi.alkalay.net/card/

On Wed, Dec 7, 2022 at 7:39 PM Jonny Heggheim @.***> wrote:

The setup.py imports the package itself to extract version. That is not the correct way to extract version from the package and is bad practice that has multiple potential pitfalls

One of the pitfalls is that the RPM tool that want to read the dependencies, will fail if the dependency is not installed:

  • /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --generate-extras --python3_pkgversion 3 --wheeldir /builddir/build/BUILD/auto_remote_sync-1.0.5/pyproject-wheeldir Handling setuptools >= 40.8 from default build backend Requirement satisfied: setuptools >= 40.8 (installed: setuptools 59.6.0) Handling wheel from default build backend Requirement satisfied: wheel (installed: wheel 0.37.1) Traceback (most recent call last): File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 501, in main generate_requires( File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 415, in generate_requires generate_build_requirements(backend, requirements) File "/usr/lib/rpm/redhat/pyproject_buildrequires.py", line 265, in generate_build_requirements new_reqs = get_requires() File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 162, in get_requires_for_build_wheel return self._get_build_requires( File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 143, in _get_build_requires self.run_setup() File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 267, in run_setup super(_BuildMetaLegacyBackend, File "/usr/lib/python3.10/site-packages/setuptools/build_meta.py", line 158, in run_setup exec(compile(code, file, 'exec'), locals()) File "setup.py", line 5, in from autorsync import version File "/builddir/build/BUILD/auto_remote_sync-1.0.5/autorsync/init.py", line 9, in import yaml ModuleNotFoundError: No module named 'yaml' error: Bad exit status from /var/tmp/rpm-tmp.wHpst0 (%generate_buildrequires) Bad exit status from /var/tmp/rpm-tmp.wHpst0 (%generate_buildrequires)

See https://bugzilla.redhat.com/show_bug.cgi?id=2151315#c6 for details

— Reply to this email directly, view it on GitHub https://github.com/avibrazil/autorsync/issues/1#issuecomment-1341686279, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2SUUQEE66AERBULTRDZ33WMEGZ3ANCNFSM6AAAAAASVY54LQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>