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

TypeError: Item in ``from list'' must be str, not NoneType #1344

Closed
konstin opened this issue Jun 21, 2019 · 4 comments · Fixed by #1629
Closed

TypeError: Item in ``from list'' must be str, not NoneType #1344

konstin opened this issue Jun 21, 2019 · 4 comments · Fixed by #1629
Labels
bug:normal affects many people or has quite an impact pr-merged

Comments

@konstin
Copy link

konstin commented Jun 21, 2019

I'm trying to add PEP 517 support to a packaging tool I've written (pyo3-pack) and I when I tried to test sdist support with tox, I got a TypeError inside tox code.

pyproject.toml

[build-system]
requires = ["/path/to/current/dev/build/pyo3_pack-0.6.1-py2.py3-none-manylinux1_x86_64.whl", "toml"]
build-backend = "pyo3_pack"

[tool.pyo3-pack]
bindings = "cffi"

tox.ini

[tox]
envlist = py35,py36,py37
isolated_build = True

[testenv]
deps = pytest cffi
commands = pytest

Running leads to the following output:

$ tox -rvv
using tox.ini: /home/konsti/pyo3-pack/test-crates/cffi-pure/tox.ini (pid 9495)
using tox-3.12.1 from /home/konsti/pyo3-pack/venv/lib/python3.6/site-packages/tox/__init__.py (pid 9495)
.package start: getenv /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package
.package cannot reuse: -r flag
.package create: /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package
/home/konsti/pyo3-pack/venv/bin/python (/home/konsti/pyo3-pack/venv/bin/python) is {'executable': '/home/konsti/pyo3-pack/venv/bin/python', 'name': 'python', 'version_info': [3, 6, 8, 'final', 0], 'version': '3.6.8 (default, Jan 14 2019, 11:02:34) \n[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]]', 'is_64': True, 'sysplatform': 'linux'}
.package uses /home/konsti/pyo3-pack/venv/bin/python
setting PATH=/home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin:/home/konsti/pyo3-pack/venv/bin:/home/konsti/.pyenv/bin:/home/konsti/.pyenv/plugins/pyenv-virtualenv/shims:/home/konsti/.pyenv/shims:/home/konsti/.nvm/versions/node/v10.5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/konsti/.cargo/bin:/home/konsti/.local/bin
[9502] /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox$ /home/konsti/pyo3-pack/venv/bin/python -m virtualenv --no-download --python /home/konsti/pyo3-pack/venv/bin/python .package
Already using interpreter /home/konsti/pyo3-pack/venv/bin/python
Using base prefix '/usr'
New python executable in /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin/python
Installing setuptools, pip, wheel...
done.
.package installdeps: /home/konsti/pyo3-pack/target/wheels/pyo3_pack-0.6.1-py2.py3-none-manylinux1_x86_64.whl, toml
setting PATH=/home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin:/home/konsti/pyo3-pack/venv/bin:/home/konsti/.pyenv/bin:/home/konsti/.pyenv/plugins/pyenv-virtualenv/shims:/home/konsti/.pyenv/shims:/home/konsti/.nvm/versions/node/v10.5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/konsti/.cargo/bin:/home/konsti/.local/bin
[9511] /home/konsti/pyo3-pack/test-crates/cffi-pure$ /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin/python -m pip install /home/konsti/pyo3-pack/target/wheels/pyo3_pack-0.6.1-py2.py3-none-manylinux1_x86_64.whl toml
Processing /home/konsti/pyo3-pack/target/wheels/pyo3_pack-0.6.1-py2.py3-none-manylinux1_x86_64.whl
Collecting toml
  Using cached https://files.pythonhosted.org/packages/a2/12/ced7105d2de62fa7c8fb5fce92cc4ce66b57c95fb875e9318dba7f8c5db0/toml-0.10.0-py2.py3-none-any.whl
Installing collected packages: pyo3-pack, toml
Successfully installed pyo3-pack-0.6.1 toml-0.10.0
.package finish: getenv /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package after 4.66 seconds
.package start: finishvenv 
write config to /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/.tox-config1 as '94aaba361509f3eb875f759baaad9c10 /home/konsti/pyo3-pack/venv/bin/python\n3.12.1 0 0 0\n9a98df95e2f78ca59a589cb2f3e1099f /home/konsti/pyo3-pack/target/wheels/pyo3_pack-0.6.1-py2.py3-none-manylinux1_x86_64.whl\n00000000000000000000000000000000 toml'
.package finish: finishvenv  after 0.03 seconds
.package start: get-build-requires /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package
setting PATH=/home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin:/home/konsti/pyo3-pack/venv/bin:/home/konsti/.pyenv/bin:/home/konsti/.pyenv/plugins/pyenv-virtualenv/shims:/home/konsti/.pyenv/shims:/home/konsti/.nvm/versions/node/v10.5.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/konsti/.cargo/bin:/home/konsti/.local/bin
[9518] /home/konsti/pyo3-pack/test-crates/cffi-pure$ /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin/python /home/konsti/pyo3-pack/venv/lib/python3.6/site-packages/tox/helper/build_requires.py pyo3_pack '' >.tox/.package/log/.package-0.log
ERROR: invocation failed (exit code 1), logfile: /home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/log/.package-0.log
================================================================================= log start =================================================================================
Traceback (most recent call last):
  File "/home/konsti/pyo3-pack/venv/lib/python3.6/site-packages/tox/helper/build_requires.py", line 7, in <module>
    backend = __import__(backend_spec, fromlist=[None])
  File "<frozen importlib._bootstrap>", line 1014, in _handle_fromlist
TypeError: Item in ``from list'' must be str, not NoneType

================================================================================== log end ==================================================================================
ERROR: FAIL could not package project - v = InvocationError("/home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin/python /home/konsti/pyo3-pack/venv/lib/python3.6/site-packages/tox/helper/build_requires.py pyo3_pack ''", 1)

The module that code tries to import is importable (/home/konsti/pyo3-pack/test-crates/cffi-pure/.tox/.package/bin/python -c "import pyo3_pack" passes). If I replace the failing line with backend = __import__(backend_spec, fromlist=[]) or backend = __import__(backend_spec), the error disappears. The current WIP PEP 517 implementation is at pyo3_pack/__init__.py, the failing code was introduce in #1145.

@konstin konstin added the bug:normal affects many people or has quite an impact label Jun 21, 2019
@konstin
Copy link
Author

konstin commented Jul 1, 2019

I created a minimal example at https://github.com/konstin/tox-1344:

git clone https://github.com/konstin/tox-1344
cd tox-1344
python3 -m venv venv
source venv/bin/activate
pip install tox
tox

This prints:

.package create: /home/konsti/tox-1344/.tox/.package
.package installdeps: pyo3-pack==0.7.0-beta.4, toml
ERROR: invocation failed (exit code 1), logfile: /home/konsti/tox-1344/.tox/.package/log/.package-2.log
================================================================================= log start =================================================================================
Traceback (most recent call last):
  File "venv/lib/python3.6/site-packages/tox/helper/build_requires.py", line 7, in <module>
    backend = __import__(backend_spec, fromlist=[None])
  File "<frozen importlib._bootstrap>", line 1014, in _handle_fromlist
TypeError: Item in ``from list'' must be str, not NoneType

================================================================================== log end ==================================================================================
ERROR: FAIL could not package project - v = InvocationError("/home/konsti/tox-1344/.tox/.package/bin/python venv/lib/python3.6/site-packages/tox/helper/build_requires.py pyo3_pack ''", 1)

tox --version: 3.13.2 imported from /home/konsti/tox-1344/venv/lib/python3.6/site-packages/tox/__init__.py

GitHub
Contribute to konstin/tox-1344 development by creating an account on GitHub.

@gaborbernat
Copy link
Member

I think we left out this part from pep 517: It's also legal to leave out the :object part, e.g.

This was referenced Aug 5, 2019
@thedrow
Copy link

thedrow commented Dec 16, 2019

So how can we fix it?

@gaborbernat
Copy link
Member

gaborbernat commented Apr 19, 2020

Feel free to open a PR against master and fix it. My available efforts at the moment are aimed at fixing this as part of #1394, but that probably will take a while (ETA September).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug:normal affects many people or has quite an impact pr-merged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants