Skip to content

Test with setuptools 79 and 80. - #708

Merged
mauritsvanrees merged 10 commits into
masterfrom
setuptools-80
Jun 11, 2025
Merged

mauritsvanrees merged 10 commits into
masterfrom
setuptools-80

Conversation

@mauritsvanrees

Copy link
Copy Markdown
Member

@mauritsvanrees

Copy link
Copy Markdown
Member Author

Indeed it fails on setuptools 80 as we are calling setup.py develop. This has been deprecated for long, and now might still work, but differently. See pypa/setuptools#4955 for the main change.

We could try replacing that with pip install -e.

I am unlikely to work on this the next few days.

@mauritsvanrees

Copy link
Copy Markdown
Member Author

Ah, wait, it fails because we call develop with -mN. From python setup.py devel --help, on setuptools 79:

Options for 'develop' command:
...
  --multi-version (-m)       make apps have to require() a version
...
  --no-deps (-N)             don't install dependencies
...
[skipped 20 or so other options]

And calling it still works, just tried on a random project outside of buildout:

% bin/python setup.py develop -mN
...
Creating /Users/maurits/community/plone-coredev/6.0/src/Plone/lib/python3.13/site-packages/Plone.egg-link (link to .)

Installed /Users/maurits/community/plone-coredev/6.0/src/Plone
Because this distribution was installed --multi-version, before you can
import modules from this package in an application, you will need to
'import pkg_resources' and then use a 'require()' call similar to one of
these examples, in order to select the desired version:

    pkg_resources.require("Plone")  # latest installed version
    pkg_resources.require("Plone==6.0.16.dev0")  # this exact version
    pkg_resources.require("Plone>=6.0.16.dev0")  # this version or higher

With setuptools 80, the help is much smaller:

Options for 'develop' command:
  --install-dir (-d)  install package to DIR
  --no-deps (-N)      don't install dependencies
  --user              install in user site-package
                      '/Users/maurits/.local/lib/python3.13/site-packages'
  --prefix            installation prefix
  --index-url (-i)    base URL of Python Package Index

I removed the -m option from our call, but then it just fails a few lines further, because we get a different kind of result from the installation:

Traceback (most recent call last):
  File "/Users/maurits/community/buildout/src/zc/buildout/buildout.py", line 2329, in main
    getattr(buildout, command)(args)
  File "/Users/maurits/community/buildout/src/zc/buildout/buildout.py", line 731, in install
    installed_develop_eggs = self._develop()
  File "/Users/maurits/community/buildout/src/zc/buildout/buildout.py", line 974, in _develop
    zc.buildout.easy_install.develop(setup, dest)
  File "/Users/maurits/community/buildout/src/zc/buildout/easy_install.py", line 1166, in develop
    return _copyeggs(tmp3, dest, '.egg-link', undo)
  File "/Users/maurits/community/buildout/src/zc/buildout/easy_install.py", line 1055, in _copyeggs
    assert len(result) == 1, str(result)
AssertionError: []

So _copyeggs may need changes as well then. But probably only on setuptools 80+.

@mauritsvanrees

Copy link
Copy Markdown
Member Author

Locally, with export SETUPTOOLS_VERSION=79.0.1; make, it seems to work when I remove the -m option, but I do get lots of extra output:

Develop: '/Users/maurits/community/buildout/zc.recipe.egg_'
...
TEST FAILED: /Users/maurits/community/buildout/develop-eggs/tmpxj6fmpd6build does NOT support .pth files
bad install directory or PYTHONPATH

You are attempting to install a package to a directory that is not
on PYTHONPATH and which Python does not read ".pth" files from.  The
installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Users/maurits/community/buildout/develop-eggs/tmpxj6fmpd6build

and your PYTHONPATH environment variable currently contains:

    ''

Here are some of your options for correcting the problem:

* You can choose a different installation directory, i.e., one that is
  on PYTHONPATH or supports .pth files

* You can add the installation directory to the PYTHONPATH environment
  variable.  (It must then also be on PYTHONPATH whenever you run
  Python and want to use the package(s) you are installing.)

* You can set up the installation directory to support ".pth" files by
  using one of the approaches described here:

  https://setuptools.pypa.io/en/latest/deprecated/easy_install.html#custom-installation-locations


Please make the appropriate changes for your system and try again.

This comes from setuptools here and here.

Anyway, we are getting into territory of easy_install.py (and package_index.py) that will at some point be removed from setuptools, which would need even more changes in Buildout.

Okay, enough for now. :-)

Locally I already saw problems due to recent changes.
https://setuptools.pypa.io/en/latest/history.html

At first I tested with 80.0.0, now with 80.2.0.
Later versions will still fail, because `package_index.py` was removed.  That should be fixed separately.
This option does not exist on setuptools 80+.
But this needs more changes.
The warnings that setuptools prints, are interfering with fixing bugs.
See reasoning in comment in the code.
That setuptools version uses pip, which does things rather differently.
These lines are easier to test for, as we control them.
Otherwise there are differences depending on the setuptools version.
distutils scripts are no longer detected here.
Our changes seem to work on setuptools 79 and lower as well, but they are only mandatory on 80 and higher.
@mauritsvanrees

Copy link
Copy Markdown
Member Author

It works! The build is green (and hopefully stays green now that I did a final rebase, edited some comments, and moved to testing setuptools 80.2.0 instead of 80.0.0). And it works locally when I try it on the Plone coredev Buildout with setuptools 80.0.0.

This PR fixes editable installs on setuptools 80.0.0 until and including 80.2.0. Later versions have different problems, to be solved separately.

The main fix is that with setuptools 80 we now need to "manually" create an .egg-link file. That new code is in _create_egg_link. I can imagine that there are corner cases where our new code does not work, but there is only so much we can do; see comments in that function.

On setuptools 79 and lower, Buildout basically does the same thing as it did before.

"distutils scripts" are not detected anymore with setuptools 80, but I don't even know what these are, so this is probably not a problem. See comments in the code.

@mauritsvanrees

Copy link
Copy Markdown
Member Author

@icemac @dataflake @gotcha This is ready.
Please test this PR on setuptools 80.2.0 or lower.

Or try my follow-up PR #712 which builds on this one plus it fixes the problems caused by the removal of setuptools/package_index.py. That one works with the latest setuptools version as well (80.9.0).

@dataflake dataflake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have tested under Python 3.13 and Python 3.10 universal2 with the same buildout configurations from #711 and it worked.

@mauritsvanrees
mauritsvanrees merged commit 2b7a468 into master Jun 11, 2025
@mauritsvanrees
mauritsvanrees deleted the setuptools-80 branch June 11, 2025 08:18
@mauritsvanrees

Copy link
Copy Markdown
Member Author

I have released zc.buildout 4.1.11 with this.

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