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

AttributeError: 'Pep517HookCaller' object has no attribute 'build_sys_requires' #14

Closed
uranusjr opened this issue Sep 11, 2018 · 11 comments

Comments

@uranusjr
Copy link
Member

uranusjr commented Sep 11, 2018

To reproduce:

$ git clone https://github.com/takluyver/flit.git
...

$ python -m pep517.check flit
Traceback (most recent call last):
  File "pep517/check.py", line 154, in check
    sdist_ok = check_build_sdist(hooks)
  File "check.py", line 24, in check_build_sdist
    env.pip_install(hooks.build_sys_requires)
AttributeError: 'Pep517HookCaller' object has no attribute 'build_sys_requires'

I believe check_build_wheel also contains this non-existent attribute reference.

@jaraco jaraco changed the title Failed to run “check” AttributeError: 'Pep517HookCaller' object has no attribute 'build_sys_requires' Dec 11, 2018
@jaraco
Copy link
Member

jaraco commented Dec 11, 2018

This issue also happens when attempting to use build-backend = setuptools.build_meta.

@pfmoore
Copy link
Member

pfmoore commented Dec 11, 2018

Looks like a straight bug. I've no idea what build_sys_requires is intended to mean. I don't know hoe the check command is supposed to work. @takluyver can you comment?

@jaraco
Copy link
Member

jaraco commented Dec 11, 2018

I added the following diff and it bypasses the error:

diff --git a/pep517/wrappers.py b/pep517/wrappers.py
index b14b899..62051dc 100644
--- a/pep517/wrappers.py
+++ b/pep517/wrappers.py
@@ -43,6 +43,8 @@ class Pep517HookCaller(object):
     source_dir : The path to the source directory, containing pyproject.toml.
     backend : The build backend spec, as per PEP 517, from pyproject.toml.
     """
+    build_sys_requires = []
+
     def __init__(self, source_dir, build_backend):
         self.source_dir = abspath(source_dir)
         self.build_backend = build_backend

Actually, I'm not confident in that statement...

@pfmoore
Copy link
Member

pfmoore commented Dec 11, 2018

That seems like the wrong approach to me - it's just patching over the real problem here, which is that build_sys_requires isn't part of the interface of Pep517HookCaller.

The lack of actual documentation is the fundamental problem here, compounded by the README and check.py using an attribute that is not actually part of the wrapper code...

As I said elsewhere, anything other than the wrappers.py code has yet to be used in real-life code. So be careful making assumptions about it. I've actually no idea what pep517.check is intended to do...

@jaraco
Copy link
Member

jaraco commented Dec 11, 2018

pep517.check fails to run on itself too.

pep517 master $ .tox/python/bin/python -m pep517.check .
Found pyproject.toml                                                                                                                                                           I-__main__
Loaded pyproject.toml                                                                                                                                                          I-__main__
Temporary build environment: /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-oavl_cmi                                                                 I-pep517.envbuild
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/jaraco/code/public/pypa/pep517/pep517/check.py", line 194, in <module>
    main()
  File "/Users/jaraco/code/public/pypa/pep517/pep517/check.py", line 173, in main
    ok = check(args.source_dir)
  File "/Users/jaraco/code/public/pypa/pep517/pep517/check.py", line 154, in check
    sdist_ok = check_build_sdist(hooks)
  File "/Users/jaraco/code/public/pypa/pep517/pep517/check.py", line 24, in check_build_sdist
    env.pip_install(hooks.build_sys_requires)
AttributeError: 'Pep517HookCaller' object has no attribute 'build_sys_requires'

My understanding was that pep517.check could be used to produce an sdist/wheel for a package checkout... or maybe serve as a springboard for a similar command that would do just that.

@jaraco
Copy link
Member

jaraco commented Dec 11, 2018

After applying that patch, pep517.check almost runs on itself:

pep517 master $ .tox/python/bin/python -m pep517.check .
Found pyproject.toml                                                                                                                                                           I-__main__
Loaded pyproject.toml                                                                                                                                                          I-__main__
Temporary build environment: /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-q8mfd2di                                                                 I-pep517.envbuild
Installed static build dependencies                                                                                                                                            I-__main__
Failure in get_requires_for_build_sdist                                                                                                                                        E-__main__
Traceback (most recent call last):
  File "/Users/jaraco/code/public/pypa/pep517/pep517/check.py", line 31, in check_build_sdist
    reqs = hooks.get_requires_for_build_sdist({})
  File "/Users/jaraco/code/public/pypa/pep517/pep517/wrappers.py", line 114, in get_requires_for_build_sdist
    'config_settings': config_settings
  File "/Users/jaraco/code/public/pypa/pep517/pep517/wrappers.py", line 157, in _call_hook
    raise BackendUnavailable
pep517.wrappers.BackendUnavailable
Temporary build environment: /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-qzr7gy3g                                                                 I-pep517.envbuild
Installed static build dependencies                                                                                                                                            I-__main__
Failure in get_requires_for_build_sdist                                                                                                                                        E-__main__
Traceback (most recent call last):
  File "/Users/jaraco/code/public/pypa/pep517/pep517/check.py", line 86, in check_build_wheel
    reqs = hooks.get_requires_for_build_wheel({})
  File "/Users/jaraco/code/public/pypa/pep517/pep517/wrappers.py", line 68, in get_requires_for_build_wheel
    'config_settings': config_settings
  File "/Users/jaraco/code/public/pypa/pep517/pep517/wrappers.py", line 157, in _call_hook
    raise BackendUnavailable
pep517.wrappers.BackendUnavailable
Sdist checks failed; scroll up to see                                                                                                                                          W-__main__
Wheel checks failed                                                                                                                                                            W-__main__
Checks failed

@jaraco
Copy link
Member

jaraco commented Dec 11, 2018

Installing flit allows the check to run:

pep517 master $ .tox/python/bin/python -m pep517.check .
Found pyproject.toml                                                                                                                                                           I-__main__
Loaded pyproject.toml                                                                                                                                                          I-__main__
Temporary build environment: /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-5vjrdxpp                                                                 I-pep517.envbuild
Installed static build dependencies                                                                                                                                            I-__main__
The file description seems not to be valid rst for PyPI; it will be interpreted as plain text
<string>:18: (WARNING/2) Cannot analyze code. Pygments package not found.

Got build requires: ['pytoml']                                                                                                                                                 I-__main__
Calling pip to install ['pytoml']                                                                                                                                       I-pep517.envbuild
Collecting pytoml
Installing collected packages: pytoml
Successfully installed pytoml
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Installed dynamic build dependencies                                                                                                                                           I-__main__
Trying to build sdist in /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/tmp0cu3t12l                                                                                          I-__main__
The file description seems not to be valid rst for PyPI; it will be interpreted as plain text
<string>:18: (WARNING/2) Cannot analyze code. Pygments package not found.

build_sdist returned 'pep517-0.2.tar.gz'                                                                                                                                       I-__main__
Output file /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/tmp0cu3t12l/pep517-0.2.tar.gz exists                                                                              I-__main__
Output file is a tar file                                                                                                                                                      I-__main__
Temporary build environment: /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pep517-build-env-s9eb306i                                                                 I-pep517.envbuild
Installed static build dependencies                                                                                                                                            I-__main__
The file description seems not to be valid rst for PyPI; it will be interpreted as plain text
<string>:18: (WARNING/2) Cannot analyze code. Pygments package not found.

Got build requires: ['pytoml']                                                                                                                                                 I-__main__
Calling pip to install ['pytoml']                                                                                                                                       I-pep517.envbuild
Collecting pytoml
Installing collected packages: pytoml
Successfully installed pytoml
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Installed dynamic build dependencies                                                                                                                                           I-__main__
Trying to build wheel in /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/tmpaa1fi9rh                                                                                          I-__main__
The file description seems not to be valid rst for PyPI; it will be interpreted as plain text
<string>:18: (WARNING/2) Cannot analyze code. Pygments package not found.

build_wheel returned 'pep517-0.2-py2.py3-none-any.whl'                                                                                                                         I-__main__
Output file /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/tmpaa1fi9rh/pep517-0.2-py2.py3-none-any.whl exists                                                                I-__main__
Output file is a zip file                                                                                                                                                      I-__main__
Checks passed

@pfmoore
Copy link
Member

pfmoore commented Dec 11, 2018

My understanding was that pep517.check could be used to produce an sdist/wheel for a package checkout... or maybe serve as a springboard for a similar command that would do just that.

I'll leave that to @takluyver to comment on. I don't think it is, or should be, but this isn't technically my project, so I'm not really in a position to make that call.

When I've pointed people to this project, it's been solely for the pep517.wrappers API (and pep517.envbuild, if you're willing to help with a new API that's had limited real-world use yet).

@takluyver
Copy link
Member

#23 should fix it. build_sys_requires is the list of build system requirements read from the pyproject.toml file. Previously the Pep517HookCaller read the file and exposed that as an attribute.

I've actually no idea what pep517.check is intended to do...

It checks that a package can be built using the PEP 517 interface. You run python -m pep517.check path/to/directory, it tries to build an sdist and a wheel, and tells you if it succeeded.

It's not intended as a way of getting the distributions - it builds them in a tempdir which is deleted when it finished.

@takluyver
Copy link
Member

(For reference, if you actually want the distributions, the highest level API is pep517.envbuild.build_sdist() and build_wheel(). There's no command line interface for this at present.)

@pfmoore
Copy link
Member

pfmoore commented Dec 12, 2018

@takluyver thanks for spotting the issue - as you say, it was missed when I refactored the hook callers for pip.

Your explanation of pep517.check makes sense to me - I was confused because @jaraco seemed to be using it as a build interface. It's not hard to confuse me :-)

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

No branches or pull requests

4 participants