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

Occasional BadZipFile error when running cargo test #706

Closed
messense opened this issue Nov 26, 2021 · 13 comments
Closed

Occasional BadZipFile error when running cargo test #706

messense opened this issue Nov 26, 2021 · 13 comments
Labels
bug Something isn't working

Comments

@messense
Copy link
Member

I did try cargo build, which was successful, and then cargo test. The first time it seems I was missing virtualenv, so I installed that. Now it mostly works but I have two test failures:

> cargo test
    Finished test [unoptimized + debuginfo] target(s) in 0.11s
     Running unittests (target/debug/deps/maturin-a923ac55f435cad2)

running 24 tests
test build_options::test::test_extract_cargo_metadata_args ... ok
test auditwheel::policy::test::test_policy_musllinux_fixup_libc_so_name ... ok
test auditwheel::policy::test::test_policy_musllinux_tag ... ok
test build_options::test::test_get_min_python_minor ... ok
test auditwheel::policy::test::test_policy_manylinux_tag ... ok
test auditwheel::policy::test::test_load_policy ... ok
test metadata::test::test_path_to_content_type ... ok
test python_interpreter::test::test_calculate_macosx_platform_tag ... ok
test cargo_toml::test::test_old_classifier_works ... ok
test cargo_toml::test::test_metadata_from_cargo_toml ... ok
test build_options::test::test_old_extra_feature_args ... ok
test cargo_toml::test::test_metadata_from_cargo_toml_without_authors ... ok
test metadata::test::test_merge_metadata_from_pyproject_toml_with_customized_python_source_dir ... ok
test pyproject_toml::tests::test_warn_missing_maturin_version ... ok
test build_options::test::test_find_bridge_bin ... ok
test build_options::test::test_find_bridge_cffi ... ok
test metadata::test::test_merge_metadata_from_pyproject_toml ... ok
test metadata::test::test_metadata_from_cargo_toml_name_override ... ok
test metadata::test::test_metadata_from_cargo_toml ... ok
test build_options::test::test_find_bridge_pyo3_abi3 ... ok
test metadata::test::test_metadata_from_cargo_toml_rst ... ok
test build_options::test::test_find_bridge_pyo3 ... ok
test build_options::test::test_argument_splitting ... ok
test build_options::test::test_find_bridge_pyo3_feature ... ok

test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.69s

     Running unittests (target/debug/deps/maturin-2869307880cf2fdd)

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

     Running tests/run.rs (target/debug/deps/run-cdac879093ea19b3)

running 20 tests
test locked_doesnt_build_without_cargo_lock ... ok
test abi3_without_version ... ok
test workspace_cargo_lock ... ok
test integration_hello_world ... ok
test integration_pyo3_pure ... FAILED
test integration_pyo3_mixed_py_subdir ... ok
test integration_pyo3_mixed_submodule ... ok
test integration_pyo3_mixed ... ok
test editable_pyo3_pure ... ok
test develop_pyo3_pure ... FAILED
Requirement already satisfied: cffi in ./test-crates/venvs/cffi-pure-develop/lib/python3.9/site-packages (1.15.0)
Requirement already satisfied: pycparser in ./test-crates/venvs/cffi-pure-develop/lib/python3.9/site-packages (from cffi) (2.21)
Requirement already satisfied: cffi in ./test-crates/venvs/cffi-mixed-develop/lib/python3.9/site-packages (1.15.0)
Requirement already satisfied: pycparser in ./test-crates/venvs/cffi-mixed-develop/lib/python3.9/site-packages (from cffi) (2.21)
Collecting boltons
  Using cached boltons-21.0.0-py2.py3-none-any.whl (193 kB)
Installing collected packages: boltons
Successfully installed boltons-21.0.0
test integration_cffi_mixed ... ok
test develop_hello_world ... ok
test integration_cffi_pure ... ok
test develop_cffi_pure ... ok
test develop_cffi_mixed ... ok
test editable_pyo3_mixed_py_subdir ... ok
test editable_pyo3_mixed ... ok
test develop_pyo3_mixed_submodule ... ok
test develop_pyo3_mixed has been running for over 60 seconds
test develop_pyo3_mixed_py_subdir has been running for over 60 seconds
test develop_pyo3_mixed_py_subdir ... ok
test develop_pyo3_mixed ... ok

failures:

---- integration_pyo3_pure stdout ----
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.6
🐍 Not using a specific python interpreter (With abi3, an interpreter is only required on windows)
📡 Using build options bindings from pyproject.toml
📖 Found type stub file at pyo3_pure.pyi
📦 Built wheel for abi3 Python ≥ 3.6 to /tmp/maturin/test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2-cp36-abi3-netbsd_9_99_92_amd64.whl
pip install in /tmp/maturin/test-crates/venvs/pyo3-pure-3.9 failed running ["-m", "pip", "--disable-pip-version-check", "install", "--force-reinstall", "/tmp/maturin/test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2-cp36-abi3-netbsd_9_99_92_amd64.whl"]: exit status: 2
--- Stdout:
Processing ./test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2-cp36-abi3-netbsd_9_99_92_amd64.whl
--- Stderr:
ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 338, in run
    requirement_set = resolver.resolve(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 73, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in collect_root_requirements
    req = self._make_requirement_from_install_req(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 430, in _make_requirement_from_install_req
    cand = self._make_candidate_from_link(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 201, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 281, in __init__
    super().__init__(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
    dist = self._prepare_distribution()
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 546, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 59, in _get_prepared_distribution
    return abstract_dist.get_metadata_distribution()
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/distributions/wheel.py", line 26, in get_metadata_distribution
    return get_wheel_distribution(wheel, canonicalize_name(self.req.name))
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/metadata/__init__.py", line 51, in get_wheel_distribution
    return Distribution.from_wheel(wheel, canonical_name)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py", line 37, in from_wheel
    with wheel.as_zipfile() as zf:
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/metadata/base.py", line 321, in as_zipfile
    return zipfile.ZipFile(self.location, allowZip64=True)
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1257, in __init__
    self._RealGetContents()
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1324, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
---

thread 'integration_pyo3_pure' panicked at 'pip install in /tmp/maturin/test-crates/venvs/pyo3-pure-3.9 failed running ["-m", "pip", "--disable-pip-version-check", "install", "--force-reinstall", "/tmp/maturin/test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2-cp36-abi3-netbsd_9_99_92_amd64.whl"]: exit status: 2
--- Stdout:
Processing ./test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2-cp36-abi3-netbsd_9_99_92_amd64.whl
--- Stderr:
ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 338, in run
    requirement_set = resolver.resolve(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 73, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in collect_root_requirements
    req = self._make_requirement_from_install_req(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 430, in _make_requirement_from_install_req
    cand = self._make_candidate_from_link(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 201, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 281, in __init__
    super().__init__(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
    dist = self._prepare_distribution()
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 546, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 59, in _get_prepared_distribution
    return abstract_dist.get_metadata_distribution()
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/distributions/wheel.py", line 26, in get_metadata_distribution
    return get_wheel_distribution(wheel, canonicalize_name(self.req.name))
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/metadata/__init__.py", line 51, in get_wheel_distribution
    return Distribution.from_wheel(wheel, canonical_name)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py", line 37, in from_wheel
    with wheel.as_zipfile() as zf:
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-3.9/lib/python3.9/site-packages/pip/_internal/metadata/base.py", line 321, in as_zipfile
    return zipfile.ZipFile(self.location, allowZip64=True)
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1257, in __init__
    self._RealGetContents()
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1324, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
---
', tests/common/mod.rs:93:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

---- develop_pyo3_pure stdout ----
thread 'develop_pyo3_pure' panicked at 'Failed to install cffi: exit status: 2
---stdout:
Requirement already satisfied: pip in ./test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages (21.3.1)
Collecting cffi
  Using cached cffi-1.15.0.tar.gz (484 kB)
  Preparing metadata (setup.py): started
  Preparing metadata (setup.py): finished with status 'done'
Collecting pycparser
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Building wheels for collected packages: cffi
  Building wheel for cffi (setup.py): started
  Building wheel for cffi (setup.py): finished with status 'done'
  Created wheel for cffi: filename=cffi-1.15.0-cp39-cp39-netbsd_9_99_92_amd64.whl size=364478 sha256=1e7e22fcd09ca2a2ed0201ba39bc1d603af7b0020afb5e39634e464ec984888f
  Stored in directory: /home/wiz/.cache/pip/wheels/8e/0d/16/77c97b85a9f559c5412c85c129a2bae07c771d31e1beb03c40
---stderr:
ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 360, in run
    _, build_failures = build(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/wheel_builder.py", line 346, in build
    wheel_file = _build_one(
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/wheel_builder.py", line 227, in _build_one
    _verify_one(req, wheel_path)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/wheel_builder.py", line 174, in _verify_one
    dist = get_wheel_distribution(FilesystemWheel(wheel_path), canonical_name)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/metadata/__init__.py", line 51, in get_wheel_distribution
    return Distribution.from_wheel(wheel, canonical_name)
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py", line 37, in from_wheel
    with wheel.as_zipfile() as zf:
  File "/tmp/maturin/test-crates/venvs/pyo3-pure-develop/lib/python3.9/site-packages/pip/_internal/metadata/base.py", line 321, in as_zipfile
    return zipfile.ZipFile(self.location, allowZip64=True)
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1257, in __init__
    self._RealGetContents()
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1324, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
', tests/common/develop.rs:22:9


failures:
    develop_pyo3_pure
    integration_pyo3_pure

test result: FAILED. 18 passed; 2 failed; 0 ignored; 0 measured; 0 filtered out; finished in 66.95s

error: test failed, to rerun pass '--test run'

Am I missing another dependency or is there a bug here?

Originally posted by @0-wiz-0 in #703 (comment)

https://github.com/PyO3/maturin/runs/4329769684?check_suite_focus=true

@messense messense added the bug Something isn't working label Nov 26, 2021
@messense
Copy link
Member Author

@0-wiz-0 It would be helpful if you can upload the pyo3_pure-2.1.2-cp36-abi3-netbsd_9_99_92_amd64.whl file here.

@0-wiz-0
Copy link

0-wiz-0 commented Nov 26, 2021

Sorry, I had deleted the checkout with the failure. I've just retried and it didn't fail. Here's the wheel (zipped, because otherwise github wouldn't let me attach it) anyway, I hope it's useful. I'll try a couple more times.
wheel.zip

@0-wiz-0
Copy link

0-wiz-0 commented Nov 26, 2021

So I ran git clean -fdx && cargo test and got the error again (after a couple cargo test that didn't reproduce it):

failures:

---- integration_cffi_mixed stdout ----
🍹 Building a mixed python/rust project
🐍 Using CPython 3.9 at python3 to generate the cffi bindings
📡 Using build options bindings from pyproject.toml
📦 Built wheel to /tmp/g/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.whl
pip install in /tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi failed running ["-m", "pip", "--disable-pip-version-check", "install", "--force-reinstall", "/tmp/g/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.whl"]: exit status: 2
--- Stdout:
Processing ./test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.whl
--- Stderr:
ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 338, in run
    requirement_set = resolver.resolve(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 73, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in collect_root_requirements
    req = self._make_requirement_from_install_req(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 430, in _make_requirement_from_install_req
    cand = self._make_candidate_from_link(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 201, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 281, in __init__
    super().__init__(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
    dist = self._prepare_distribution()
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 546, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 59, in _get_prepared_distribution
    return abstract_dist.get_metadata_distribution()
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/distributions/wheel.py", line 26, in get_metadata_distribution
    return get_wheel_distribution(wheel, canonicalize_name(self.req.name))
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/metadata/__init__.py", line 51, in get_wheel_distribution
    return Distribution.from_wheel(wheel, canonical_name)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py", line 37, in from_wheel
    with wheel.as_zipfile() as zf:
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/metadata/base.py", line 321, in as_zipfile
    return zipfile.ZipFile(self.location, allowZip64=True)
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1257, in __init__
    self._RealGetContents()
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1324, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
---

thread 'integration_cffi_mixed' panicked at 'pip install in /tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi failed running ["-m", "pip", "--disable-pip-version-check", "install", "--force-reinstall", "/tmp/g/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.whl"]: exit status: 2
--- Stdout:
Processing ./test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.whl
--- Stderr:
ERROR: Exception:
Traceback (most recent call last):
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/cli/base_command.py", line 164, in exc_logging_wrapper
    status = run_func(*args)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/cli/req_command.py", line 205, in wrapper
    return func(self, options, args)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/commands/install.py", line 338, in run
    requirement_set = resolver.resolve(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/resolver.py", line 73, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 468, in collect_root_requirements
    req = self._make_requirement_from_install_req(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 430, in _make_requirement_from_install_req
    cand = self._make_candidate_from_link(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/factory.py", line 201, in _make_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 281, in __init__
    super().__init__(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 156, in __init__
    self.dist = self._prepare()
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 225, in _prepare
    dist = self._prepare_distribution()
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/resolution/resolvelib/candidates.py", line 292, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 482, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 546, in _prepare_linked_requirement
    dist = _get_prepared_distribution(
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/operations/prepare.py", line 59, in _get_prepared_distribution
    return abstract_dist.get_metadata_distribution()
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/distributions/wheel.py", line 26, in get_metadata_distribution
    return get_wheel_distribution(wheel, canonicalize_name(self.req.name))
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/metadata/__init__.py", line 51, in get_wheel_distribution
    return Distribution.from_wheel(wheel, canonical_name)
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/metadata/pkg_resources.py", line 37, in from_wheel
    with wheel.as_zipfile() as zf:
  File "/tmp/g/maturin/test-crates/venvs/cffi-mixed-cffi/lib/python3.9/site-packages/pip/_internal/metadata/base.py", line 321, in as_zipfile
    return zipfile.ZipFile(self.location, allowZip64=True)
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1257, in __init__
    self._RealGetContents()
  File "/usr/pkg/lib/python3.9/zipfile.py", line 1324, in _RealGetContents
    raise BadZipFile("File is not a zip file")
zipfile.BadZipFile: File is not a zip file
---
', tests/common/mod.rs:93:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    integration_cffi_mixed

test result: FAILED. 19 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 123.29s

error: test failed, to rerun pass '--test run'

wheel-error.zip
/tmp/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.whl is in the zip.

@ionenwks
Copy link

I don't have much to add to help debug this (couldn't reproduce myself yet), but our automated testing ran into something I believe is the same in https://bugs.gentoo.org/825242, aka develop_pyo3_pure + zipfile.BadZipFile: File is not a zip file

@messense
Copy link
Member Author

messense commented Nov 27, 2021

❯ file cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.zip
cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.zip: Zip archive data, at least v2.0 to extract, compression method=deflate

~/Downloads
❯ unzip cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.zip
Archive:  cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.zip
  inflating: cffi_mixed-0.1.0.dist-info/METADATA
  inflating: cffi_mixed-0.1.0.dist-info/WHEEL
  inflating: cffi_mixed.pth
  inflating: cffi_mixed-0.1.0.dist-info/RECORD

Looks like it is a valid zip file.

Python 3.9.2 (default, Mar 20 2021, 21:34:09)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from zipfile import ZipFile
>>> f = ZipFile('cffi_mixed-0.1.0-py3-none-netbsd_9_99_92_amd64.zip', allowZip64=True)
>>> f.namelist()
['cffi_mixed-0.1.0.dist-info/METADATA', 'cffi_mixed-0.1.0.dist-info/WHEEL', 'cffi_mixed.pth', 'cffi_mixed-0.1.0.dist-info/RECORD']
>>>

The error from zipfile module is raised from https://github.com/python/cpython/blob/86c1265cdc64030c8921e0da5fcae2ac64299c26/Lib/zipfile.py#L1324 , somehow it didn't read data from the "End of Central Directory" record

@messense
Copy link
Member Author

Is it possible it's not the issue of maturin built wheel but the issue of their dependencies get corrupted somehow? pyo3-pure and cffi-mixed both depends on other packages for example attrs, boltons and cffi.

pypa/pip#10535

@messense
Copy link
Member Author

I don't have much to add to help debug this (couldn't reproduce myself yet), but our automated testing ran into something I believe is the same in https://bugs.gentoo.org/825242, aka develop_pyo3_pure + zipfile.BadZipFile: File is not a zip file

I'm unable to open https://bugs.gentoo.org/show_bug.cgi?id=825242, it gives me 500 Internal Server Error.

@ionenwks
Copy link

ionenwks commented Nov 27, 2021

I don't have much to add to help debug this (couldn't reproduce myself yet), but our automated testing ran into something I believe is the same in https://bugs.gentoo.org/825242, aka develop_pyo3_pure + zipfile.BadZipFile: File is not a zip file

I'm unable to open https://bugs.gentoo.org/show_bug.cgi?id=825242, it gives me 500 Internal Server Error.

Sorry, link is fine but ended up being bad timing (down right now) https://infra-status.gentoo.org/

Edit: think still having intermittent issues, not that there's much to see on the bug beside the unhelpful log

@messense
Copy link
Member Author

We will have a better understanding about this once pypa/pip#10535 released in a new pip version.

@konstin
Copy link
Member

konstin commented Dec 30, 2021

I tried with pip install from git, it doesn't give much more information:

---- develop_cffi_mixed stdout ----
🍹 Building a mixed python/rust project
🐍 Using CPython 3.8 at /home/konsti/maturin/test-crates/venvs/cffi-mixed-develop/bin/python to generate the cffi bindings
📡 Using build options bindings from pyproject.toml
📦 Built wheel to /home/konsti/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-linux_x86_64.whl
pip install in /home/konsti/maturin/test-crates/venvs/cffi-mixed-develop failed running ["-m", "pip", "--disable-pip-version-check", "install", "--force-reinstall", "/home/konsti/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-linux_x86_64.whl"]: exit status: 1
--- Stdout:
Processing ./test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-linux_x86_64.whl
--- Stderr:
ERROR: Wheel 'cffi-mixed' located at /home/konsti/maturin/test-crates/cffi-mixed/target/wheels/cffi_mixed-0.1.0-py3-none-linux_x86_64.whl is invalid.
---

---- develop_cffi_pure stdout ----
🐍 Using CPython 3.8 at /home/konsti/maturin/test-crates/venvs/cffi-pure-develop/bin/python to generate the cffi bindings
📡 Using build options bindings from pyproject.toml
📦 Built wheel to /home/konsti/maturin/test-crates/cffi-pure/target/wheels/cffi_pure-0.1.0-py3-none-linux_x86_64.whl
pip install in /home/konsti/maturin/test-crates/venvs/cffi-pure-develop failed running ["-m", "pip", "--disable-pip-version-check", "install", "--force-reinstall", "/home/konsti/maturin/test-crates/cffi-pure/target/wheels/cffi_pure-0.1.0-py3-none-linux_x86_64.whl"]: exit status: 1
--- Stdout:
Processing ./test-crates/cffi-pure/target/wheels/cffi_pure-0.1.0-py3-none-linux_x86_64.whl
--- Stderr:
ERROR: Wheel 'cffi-pure' located at /home/konsti/maturin/test-crates/cffi-pure/target/wheels/cffi_pure-0.1.0-py3-none-linux_x86_64.whl is invalid.
---

Both wheels are actually valid and can be installed.

@ionenwks
Copy link

My rough guess is that there's some kind of race condition happening that mis-detects a failure, I'm never able to reproduce if I use --test-threads 1

@konstin
Copy link
Member

konstin commented Dec 31, 2021

I hopefully fixed it in 28d273a, we were writing to the same wheel from different threads

@messense
Copy link
Member Author

Closing for now, feel free to reopen if it still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants