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

Fix #6163: Default to setuptools.build_meta:__legacy__ #6212

Conversation

ncoghlan
Copy link
Member

@ncoghlan ncoghlan commented Jan 28, 2019

The main setuptools PEP 517 backend is intended for
explicit usage in pyproject.toml, when the project
authors can ensure that their setup.py runs without
that directory being implicitly on sys.path.

For implicit usage, setuptools now offers a separate
legacy backend that more closely mimics direct
execution of the setup.py script.

@ncoghlan
Copy link
Member Author

ncoghlan commented Jan 28, 2019

Note that the CI is expected to fail, as successfully testing this currently requires a manual build step as described in #6210 (comment)

However, I wanted to give folks reassurance that the horrible hack in #6210 really is temporary, and just a way to take a bit of the urgency off the setuptools folks, since this approach involves a public API change for them, and hence shouldn't be rushed.

@ncoghlan ncoghlan changed the title Issue #6163: Default to setuptools.build_meta_legacy backend WIP Issue #6163: Default to setuptools.build_meta_legacy backend Jan 28, 2019
@ncoghlan
Copy link
Member Author

Note that this approach poses a problem for projects with a non-wildcard setuptools dependency in their build requirements:

[ncoghlan@localhost pip]$ python3 src/pip install --user PyInstaller==3.4
Collecting PyInstaller==3.4
  Downloading https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 5.8MB/s 
  Installing build dependencies ... done
Some build dependencies for PyInstaller==3.4 from https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz#sha256=a5a6e04a66abfcf8761e89a2ebad937919c6be33a7b8963e1a961b55cb35986b conflict with PEP 517/518 supported requirements: setuptools==40.7.0 is incompatible with setuptools>=40.7.0.post20190128.

@ncoghlan
Copy link
Member Author

The above error was just an artifact of my failing to pass in the local directory with the pre-built wheel file in it. However, solving that still wasn't enough to get a successful build:

[ncoghlan@localhost pip]$ python3 src/pip install --no-cache --user -f /tmp/setuptools_build_meta_legacy/ PyInstaller==3.4
Looking in links: /tmp/setuptools_build_meta_legacy/
Collecting PyInstaller==3.4
  Downloading https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 11.7MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: macholib>=1.8 in /home/ncoghlan/.local/lib/python3.7/site-packages (from PyInstaller==3.4) (1.11)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from PyInstaller==3.4) (39.0.1)
Requirement already satisfied: altgraph in /home/ncoghlan/.local/lib/python3.7/site-packages (from PyInstaller==3.4) (0.16.1)
Requirement already satisfied: pefile>=2017.8.1 in /home/ncoghlan/.local/lib/python3.7/site-packages (from PyInstaller==3.4) (2018.8.8)
Requirement already satisfied: future in /home/ncoghlan/.local/lib/python3.7/site-packages (from pefile>=2017.8.1->PyInstaller==3.4) (0.17.1)
Exception:
Traceback (most recent call last):
  File "src/pip/_internal/cli/base_command.py", line 176, in main
    status = self.run(options, args)
  File "src/pip/_internal/commands/install.py", line 346, in run
    session=session, autobuilding=True
  File "src/pip/_internal/wheel.py", line 904, in build
    assert have_directory_for_build
AssertionError

@ncoghlan
Copy link
Member Author

Ah, that assertion error looks like an unrelated bad interaction with the --no-cache option (I tested #6210 first, so I hadn't needed --no-cache there, I only added it in when testing this one).

Testing with cache-dir instead gives a successful install as we'd expect:

[ncoghlan@localhost pip]$ python3 src/pip install --cache-dir /tmp/pip_cache_dir --user -f /tmp/setuptools_build_meta_legacy/ PyInstaller==3.4
Looking in links: /tmp/setuptools_build_meta_legacy/
Collecting PyInstaller==3.4
  Downloading https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz (3.5MB)
    100% |████████████████████████████████| 3.5MB 8.2MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: macholib>=1.8 in /home/ncoghlan/.local/lib/python3.7/site-packages (from PyInstaller==3.4) (1.11)
Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from PyInstaller==3.4) (39.0.1)
Requirement already satisfied: altgraph in /home/ncoghlan/.local/lib/python3.7/site-packages (from PyInstaller==3.4) (0.16.1)
Requirement already satisfied: pefile>=2017.8.1 in /home/ncoghlan/.local/lib/python3.7/site-packages (from PyInstaller==3.4) (2018.8.8)
Requirement already satisfied: future in /home/ncoghlan/.local/lib/python3.7/site-packages (from pefile>=2017.8.1->PyInstaller==3.4) (0.17.1)
Building wheels for collected packages: PyInstaller
  Building wheel for PyInstaller (PEP 517) ... done
  Stored in directory: /tmp/pip_cache_dir/wheels/09/ee/0a/94ef5d39074625f49e2e9cf97ac30cb7a87e1a7458ed195b8d
Successfully built PyInstaller
Installing collected packages: PyInstaller
Successfully installed PyInstaller-3.4

@ncoghlan
Copy link
Member Author

Turns out there's already an issue filed for the AssertionError I ran into above: #6197

@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 1, 2019

Closing in favour of #6229 as a near-term resolution of #6163 (see #6163 (comment) for more details)

We'll presumably revisit this in a future release, but that can be a new issue and new PR (with the tests rolled in to #6229, there really won't be a lot of changes needed to update to a new setuptools backend later)

@ncoghlan ncoghlan closed this Feb 1, 2019
@ncoghlan ncoghlan changed the title WIP Issue #6163: Default to setuptools.build_meta_legacy backend WIP Issue TBD: Default to setuptools.build_meta_legacy backend Feb 1, 2019
@ncoghlan ncoghlan reopened this Feb 1, 2019
@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 1, 2019

Reopened, but removed the reference to #6163 from the title.

Assuming #6229 is accepted as the near term resolution of #6163, there'll need to be a follow-up issue to replace the workaround with the proper long term fix that doesn't require any xfail markers in the test suite.

@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 2, 2019

Just noting that once switching to the updated PEP 517 implementation, the setuptools version used is mentioned in docs/pip.rst

@pradyunsg pradyunsg changed the title WIP Issue TBD: Default to setuptools.build_meta_legacy backend [WIP] Default to setuptools.build_meta_legacy backend Feb 3, 2019
@pradyunsg pradyunsg changed the title [WIP] Default to setuptools.build_meta_legacy backend WIP Issue TBD: Default to setuptools.build_meta_legacy backend Feb 3, 2019
@ncoghlan ncoghlan changed the title WIP Issue TBD: Default to setuptools.build_meta_legacy backend WIP Issue #6163: Default to setuptools setup.py compatibility backend Feb 5, 2019
@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 5, 2019

It's looking like this is going to be the actual resolution for #6163 in pip 19.0.2, so updating based on some assumptions about the next setuptools release and added the issue reference back to the PR title.

However, it will remain WIP until setuptools is published and we know exactly what the new version number and backend name actually are.

@pradyunsg pradyunsg added this to the 19.0 milestone Feb 6, 2019
@uranusjr
Copy link
Member

uranusjr commented Feb 6, 2019

The new version has been released as 40.8.0 🎉

$ ./pip-6212/bin/python -m pip install git+https://github.com/ncoghlan/pip.git@issue-6163-use-setuptools-build-meta-legacy-backend
Collecting git+https://github.com/ncoghlan/pip.git@issue-6163-use-setuptools-build-meta-legacy-backend
  Cloning https://github.com/ncoghlan/pip.git (to revision issue-6163-use-setuptools-build-meta-legacy-backend) to /private/var/folders/52/hsf94kc92lxbgn7gx3vy2qsr0000gn/T/pip-req-build-osolyj99
Branch 'issue-6163-use-setuptools-build-meta-legacy-backend' set up to track remote branch 'issue-6163-use-setuptools-build-meta-legacy-backend' from 'origin'.
Switched to a new branch 'issue-6163-use-setuptools-build-meta-legacy-backend'
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: pip
  Building wheel for pip (PEP 517) ... done
  Stored in directory: /private/var/folders/52/hsf94kc92lxbgn7gx3vy2qsr0000gn/T/pip-ephem-wheel-cache-hrif2deg/wheels/a5/ca/56/003c9018bedcc3b24f5e337d9f0a885835d232a79fe0cb11ff
Successfully built pip
Installing collected packages: pip
  Found existing installation: pip 19.0.1
    Uninstalling pip-19.0.1:
      Successfully uninstalled pip-19.0.1
Successfully installed pip-19.1.dev0

$ ./pip-6212/bin/python -m pip install pyinstaller
Collecting pyinstaller
  Downloading https://files.pythonhosted.org/packages/03/32/0e0de593f129bf1d1e77eed562496d154ef4460fd5cecfd78612ef39a0cc/PyInstaller-3.4.tar.gz (3.5MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting pefile>=2017.8.1 (from pyinstaller)
  Downloading https://files.pythonhosted.org/packages/ed/cc/157f20038a80b6a9988abc06c11a4959be8305a0d33b6d21a134127092d4/pefile-2018.8.8.tar.gz (62kB)
Collecting altgraph (from pyinstaller)
  Downloading https://files.pythonhosted.org/packages/0a/cc/646187eac4b797069e2e6b736f14cdef85dbe405c9bfc7803ef36e4f62ef/altgraph-0.16.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./pip-6212/lib/python3.7/site-packages (from pyinstaller) (40.8.0)
Collecting macholib>=1.8 (from pyinstaller)
  Downloading https://files.pythonhosted.org/packages/41/f1/6d23e1c79d68e41eb592338d90a33af813f98f2b04458aaf0b86908da2d8/macholib-1.11-py2.py3-none-any.whl
Collecting future (from pefile>=2017.8.1->pyinstaller)
  Downloading https://files.pythonhosted.org/packages/90/52/e20466b85000a181e1e144fd8305caf2cf475e2f9674e797b222f8105f5f/future-0.17.1.tar.gz (829kB)
Building wheels for collected packages: pyinstaller
  Building wheel for pyinstaller (PEP 517) ... done
  Stored in directory: /Users/uranusjr/Library/Caches/pip/wheels/09/ee/0a/94ef5d39074625f49e2e9cf97ac30cb7a87e1a7458ed195b8d
Successfully built pyinstaller
Building wheels for collected packages: pefile, future
  Building wheel for pefile (setup.py) ... done
  Stored in directory: /Users/uranusjr/Library/Caches/pip/wheels/d9/c6/56/a372ee1059440413d55d13f78adfd16c8719553a5b4efdd0c1
  Building wheel for future (setup.py) ... done
  Stored in directory: /Users/uranusjr/Library/Caches/pip/wheels/0c/61/d2/d6b7317325828fbb39ee6ad559dbe4664d0896da4721bf379e
Successfully built pefile future
Installing collected packages: future, pefile, altgraph, macholib, pyinstaller
Successfully installed altgraph-0.16.1 future-0.17.1 macholib-1.11 pefile-2018.8.8 pyinstaller-3.4

Copy link
Member

@pradyunsg pradyunsg left a comment

Choose a reason for hiding this comment

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

These changes all look good to me @ncoghlan!

If it isn't too much pain, could you rewrite the commit history of this PR? If it is more work than you'd like, I'll be happy to do so myself.

src/pip/_internal/pyproject.py Outdated Show resolved Hide resolved
@ncoghlan ncoghlan force-pushed the issue-6163-use-setuptools-build-meta-legacy-backend branch from e9043b2 to 500c87a Compare February 6, 2019 10:47
@ncoghlan ncoghlan changed the title WIP Issue #6163: Default to setuptools setup.py compatibility backend Fix #6163: Default to setuptools.build_meta:__legacy__ Feb 6, 2019
@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 6, 2019

Squashed everything into one commit and removed the out of date comment. Hopefully CI will agree this is now good to go :)

@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 6, 2019

Missed a couple of test cases that referenced the exact implicit setuptools version. I also have a couple of markup and docstring fixes to add.

The main setuptools PEP 517 backend is intended for
explicit usage in `pyproject.toml`, when the project
authors can ensure that their `setup.py` runs without
that directory being implicitly on `sys.path`.

For implicit usage, setuptools now offers a separate
legacy backend that more closely mimics direct
execution of the `setup.py` script.
@ncoghlan ncoghlan force-pushed the issue-6163-use-setuptools-build-meta-legacy-backend branch from 500c87a to 682cff7 Compare February 6, 2019 10:58
@ncoghlan
Copy link
Member Author

ncoghlan commented Feb 6, 2019

@pradyunsg @pfmoore Latest push looks good to go to me - if you spot anything that needs tweaking before merging, please don't feel obliged to wait for me to comment before fixing it (I'm about to head to bed and won't be back online until tomorrow evening my time).

@pradyunsg
Copy link
Member

Great! Thanks @ncoghlan! :)

@lock
Copy link

lock bot commented May 29, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: PEP 517 impact Affected by PEP 517 processing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants