netlas-io / netlas-python

Netlas.io Python library
https://netlas.io
Other
21 stars 4 forks source link

Can't install sdk from pip due to orjson failure #5

Closed ovalsec-oz closed 1 year ago

ovalsec-oz commented 1 year ago

Python 3.11.3 / pip 23.1.2

pip install netlas                                   
Collecting netlas
  Using cached netlas-0.4.0-py3-none-any.whl (10.0 kB)
Requirement already satisfied: requests>=2.12.5 in ./venv/lib/python3.11/site-packages (from netlas) (2.31.0)
Requirement already satisfied: click>=7.0 in ./venv/lib/python3.11/site-packages (from netlas) (8.1.3)
Collecting PyYAML>=3.13 (from netlas)
  Using cached PyYAML-6.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (757 kB)
Collecting orjson<=3.6.0,>=3.0.1 (from netlas)
  Using cached orjson-3.6.0.tar.gz (746 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [11 lines of output]
      💥 maturin failed
        Caused by: Cargo metadata failed. Does your crate compile with `cargo build`?
        Caused by: `cargo metadata` exited with an error: error: failed to run `rustc` to learn about target-specific information

      Caused by:
        process didn't exit successfully: `rustc - --crate-name ___ --print=file-names -Z mutable-noalias=yes -C target-feature=+sse2 --crate-type bin --crate-type rlib --crate-type dylib --crate-type cdylib --crate-type staticlib --crate-type proc-macro --print=sysroot --print=split-debuginfo --print=crate-name --print=cfg` (exit status: 1)
        --- stderr
        error: the option `Z` is only accepted on the nightly compiler
      Error running maturin: Command '['maturin', 'pep517', 'write-dist-info', '--metadata-directory', '/tmp/pip-modern-metadata-ujyt_ypi', '--interpreter', '/home/tam/ovalsec_git/dal/venv/bin/python', '--manylinux=off', '--strip=on']' returned non-zero exit status 1.
      Checking for Rust toolchain....
      Running `maturin pep517 write-dist-info --metadata-directory /tmp/pip-modern-metadata-ujyt_ypi --interpreter /home/tam/ovalsec_git/dal/venv/bin/python --manylinux=off --strip=on`
      [end of output]
netlas-io commented 1 year ago

Hi, Can you try to uninstall and install again orjson with --verbose flag? Also you can try to install other version orjson, because as I can see, there is several problems in orjson while installing at macos. And please check that you have rust:

brew install rustup && rustup-init

qwertyaya commented 1 year ago

MacOS here I have the same issue, I've done- 'rustup default nightly' which limited the error to a different one:

Collecting netlas
  Using cached netlas-0.4.0-py3-none-any.whl (10.0 kB)
Requirement already satisfied: requests>=2.12.5 in /usr/local/lib/python3.11/site-packages (from netlas) (2.29.0)
Requirement already satisfied: click>=7.0 in /usr/local/lib/python3.11/site-packages (from netlas) (8.1.3)
Requirement already satisfied: PyYAML>=3.13 in /usr/local/lib/python3.11/site-packages (from netlas) (6.0)
Collecting orjson<=3.6.0,>=3.0.1 (from netlas)
  Using cached orjson-3.6.0.tar.gz (746 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: pygments>=2.5.0 in /usr/local/lib/python3.11/site-packages (from netlas) (2.15.1)
Requirement already satisfied: tqdm>=4.0.0 in /usr/local/lib/python3.11/site-packages (from netlas) (4.65.0)
Collecting appdirs>=1.4.3 (from netlas)
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/site-packages (from requests>=2.12.5->netlas) (3.1.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/site-packages (from requests>=2.12.5->netlas) (3.4)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /usr/local/lib/python3.11/site-packages (from requests>=2.12.5->netlas) (1.26.15)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/site-packages (from requests>=2.12.5->netlas) (2022.12.7)
Building wheels for collected packages: orjson
  Building wheel for orjson (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for orjson (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      Running `maturin pep517 build-wheel -i /usr/local/Cellar/python@3.11/3.11.3/bin/python3.11 --manylinux=off --strip=on`
         Compiling cfg-if v1.0.0
         Compiling libc v0.2.98
         Compiling autocfg v1.0.1
         Compiling libm v0.1.4
         Compiling bitflags v1.2.1
         Compiling ryu v1.0.5
         Compiling packed_simd_2 v0.3.5
         Compiling version_check v0.9.3
         Compiling cfg-if v0.1.10
         Compiling scopeguard v1.1.0
         Compiling lexical-core v0.7.6
         Compiling serde v1.0.126
         Compiling smallvec v1.6.1
         Compiling pyo3 v0.13.2
         Compiling arrayvec v0.5.2
         Compiling static_assertions v1.1.0
         Compiling instant v0.1.9
         Compiling encoding_rs v0.8.28
         Compiling orjson v3.6.0 (/private/var/folders/s6/01ymknqx77q_gxz2fdghjvyw0000gr/T/pip-install-yb6anvub/orjson_7c31ba13dce44240af8c839dbbad0dc0)
         Compiling lock_api v0.4.4
         Compiling once_cell v1.8.0
         Compiling itoa v0.4.7
         Compiling associative-cache v1.0.1
         Compiling inlinable_string v0.1.14
         Compiling ahash v0.7.4
         Compiling num-traits v0.2.14
         Compiling num-integer v0.1.44
      error: could not compile `packed_simd_2` (lib) due to 2 previous errors
      warning: build failed, waiting for other jobs to finish...
      💥 maturin failed
        Caused by: Failed to build a native library through cargo
        Caused by: Cargo build finished with "exit code: 101": `cargo rustc --message-format json --manifest-path Cargo.toml --release --lib -- -C link-arg=-undefined -C link-arg=dynamic_lookup -C link-args=-Wl,-install_name,@rpath/orjson.cpython-311-darwin.so -C link-arg=-s`
      🔗 Found pyo3 bindings
      🐍 Found CPython 3.11 at /usr/local/Cellar/python@3.11/3.11.3/bin/python3.11
      error: expected one of `!` or `::`, found keyword `mod`
         --> /Users/ilana/.cargo/registry/src/index.crates.io-6f17d22bba15001f/packed_simd_2-0.3.5/src/lib.rs:348:7
          |
      348 | crate mod llvm {
          |       ^^^ expected one of `!` or `::`

      error: aborting due to previous error

      Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/usr/local/Cellar/python@3.11/3.11.3/bin/python3.11', '--manylinux=off', '--strip=on'] returned non-zero exit status 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for orjson
Failed to build orjson
ERROR: Could not build wheels for orjson, which is required to install pyproject.toml-based projects

I've followed the suggested steps, reinstalled orjson with --verbose flag Which did not help Then I trued to limit the orjson version with:

pip install 'orjson<=3.6.0,>=3.0.1'
or
pip install 'orjson==3.5.4'

Tried both in venv with python 3.10 and outside of it, get the same error as above

ovalsec-oz commented 1 year ago

I lifted the requirement that orjson will be <= 3.6.0 and now it seems to work. Seems that orjson versions I tested, requires rust compiler's nightly (-z) flag to be turned on and on orjson==3.9.0 this isn't a requirement.

If this is a valid solution, please update the SDK accordingly. Thanks :)

qwertyaya commented 1 year ago

That worked for me too! I've cloned the repo and locally changed the requirements to 'orjson==3.9.0' and disabled the nightly flag Worked like a charm

netlas-io commented 1 year ago

Requirements has been updated. PIP package has been updated too. Please check new version.

ovalsec-oz commented 1 year ago

Confirming 0.4.1 doesn't have this problem. Thanks