Skip to content

Update setup.py, import distutils after setuptools#2459

Merged
j9ac9k merged 1 commit intopyqtgraph:masterfrom
LocutusOfBorg:patch-1
Oct 3, 2022
Merged

Update setup.py, import distutils after setuptools#2459
j9ac9k merged 1 commit intopyqtgraph:masterfrom
LocutusOfBorg:patch-1

Conversation

@LocutusOfBorg
Copy link
Copy Markdown
Contributor

This makes the package build again with newer setuptools, fixing this build failure:

make[2]: Leaving directory '/<>/doc'
dh_auto_build
I: pybuild base:240: /usr/bin/python3 setup.py build /<>/setup.py:38: 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.dir_util
/usr/lib/python3/dist-packages/_distutils_hack/init.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the distutils module in sys.modules. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
warnings.warn(
/usr/lib/python3/dist-packages/_distutils_hack/init.py:33: UserWarning: Setuptools is replacing distutils.
warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
File "/<>/setup.py", line 112, in
setup(
File "/usr/lib/python3/dist-packages/setuptools/init.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 172, in setup
ok = dist.parse_command_line()
File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 479, in parse_command_line
args = self._parse_command_opts(parser, args)
File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1107, in _parse_command_opts
nargs = _Distribution._parse_command_opts(self, parser, args)
File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 545, in _parse_command_opts
raise DistutilsClassError(
distutils.errors.DistutilsClassError: command class <class 'main.Build'> must subclass Command
E: pybuild pybuild:379: build: plugin distutils failed with: exit code=1: /usr/bin/python3 setup.py build
dh_auto_build: error: pybuild --build -i python{version} -p 3.10 returned exit code 13
make[1]: *** [debian/rules:17: override_dh_auto_build] Error 25
make[1]: Leaving directory '/<>'
make: *** [debian/rules:6: binary-indep] Error 2

Detail the reasoning behind the code change. If there is an associated issue that this PR will resolve add

Fixes #

Other Tasks

Bump Dependency Versions

Files that need updates

Confirm the following files have been either updated or there has been a determination that no update is needed.

  • README.md
  • setup.py
  • tox.ini
  • .github/workflows/main.yml and associated requirements.txt and conda environemt.yml files
  • pyproject.toml
  • binder/requirements.txt
Pre-Release Checklist

Pre Release Checklist

  • Update version info in __init__.py
  • Update CHANGELOG primarily using contents from automated changelog generation in GitHub release page
  • Have git tag in the format of pyqtgraph-
Post-Release Checklist

Steps To Complete

  • Append .dev0 to __version__ in __init__.py
  • Announce on mail list
  • Announce on Twitter

This makes the package build again with newer setuptools, fixing this build failure:

make[2]: Leaving directory '/<<PKGBUILDDIR>>/doc'
dh_auto_build
I: pybuild base:240: /usr/bin/python3 setup.py build 
/<<PKGBUILDDIR>>/setup.py:38: 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.dir_util
/usr/lib/python3/dist-packages/_distutils_hack/__init__.py:18: UserWarning: Distutils was imported before Setuptools, but importing Setuptools also replaces the `distutils` module in `sys.modules`. This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed in the traditional way (e.g. not an editable install), and/or make sure that setuptools is always imported before distutils.
  warnings.warn(
/usr/lib/python3/dist-packages/_distutils_hack/__init__.py:33: UserWarning: Setuptools is replacing distutils.
  warnings.warn("Setuptools is replacing distutils.")
Traceback (most recent call last):
  File "/<<PKGBUILDDIR>>/setup.py", line 112, in <module>
    setup(
  File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 172, in setup
    ok = dist.parse_command_line()
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 479, in parse_command_line
    args = self._parse_command_opts(parser, args)
  File "/usr/lib/python3/dist-packages/setuptools/dist.py", line 1107, in _parse_command_opts
    nargs = _Distribution._parse_command_opts(self, parser, args)
  File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 545, in _parse_command_opts
    raise DistutilsClassError(
distutils.errors.DistutilsClassError: command class <class '__main__.Build'> must subclass Command
E: pybuild pybuild:379: build: plugin distutils failed with: exit code=1: /usr/bin/python3 setup.py build 
dh_auto_build: error: pybuild --build -i python{version} -p 3.10 returned exit code 13
make[1]: *** [debian/rules:17: override_dh_auto_build] Error 25
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
make: *** [debian/rules:6: binary-indep] Error 2
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 3, 2022

One of these days we're going to cleanup setup.py, but today is not this day. Thanks for the PR @LocutusOfBorg !

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 3, 2022

@LocutusOfBorg I have no problem merging this, but is there a reason you're still using python3 setup.py build and not just pip install . ?

@LocutusOfBorg
Copy link
Copy Markdown
Contributor Author

@j9ac9k I'm the Debian maintainer and packager. We provide it via apt-get install python3-pyqtgraph. With Debian dependencies :)

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 3, 2022

@j9ac9k I'm the Debian maintainer and packager. We provide it via apt-get install python3-pyqtgraph. With Debian dependencies :)

Oh right, we would like that to work for you all 😆

I'm not opposed to adding a CI pipeline to this repo test that the build process works so we don't leave you scrambling when we roll out a breaking change. I would likely need some assistance to make sure I'm actually testing what I think I'm testing.

@j9ac9k j9ac9k merged commit ff3ee63 into pyqtgraph:master Oct 3, 2022
@LocutusOfBorg LocutusOfBorg deleted the patch-1 branch October 3, 2022 19:01
@LocutusOfBorg
Copy link
Copy Markdown
Contributor Author

well, you never broke the Debian workflow, this is the first time, so maybe I can just open an issue here if this happens again :D

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 3, 2022

We've had internal discussions about doing away w/ setup.py entirely and adopting pyproject.toml. This sounds like it would be highly disruptive on your end.

Maybe when we start work on that, one of us can reach out to you to see if we break things on your end?

@LocutusOfBorg
Copy link
Copy Markdown
Contributor Author

sure, whenever you want just ping me on irc or here

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.

2 participants