azmyrajab / polars_ols

Polars least squares extension - enables fast linear model polar expressions
MIT License
113 stars 10 forks source link

Issue installing with poetry #1

Closed AdrienDart closed 7 months ago

AdrienDart commented 7 months ago

Hi,

Thank you very much for your work, much appreciated!

I seem to have an issue with the installation.

"ChefBuildError

Backend 'maturin' is not available. ... ModuleNotFoundError: No module named 'tomllib'

During the handling of the above exception, another exception occurred:

... ...\sites-packages\maturin__init__.py import tomli as tomllib # type: ignore ModukeNotFoundError: No module named 'tomli' ...

Note: this error originates from the build backend, and is likely not a problem with poetry but with polars-ols (0.1.1) not supporting PEP 517 builds. You can verify this by running 'pio wheel --no-cache-dir --use-pep517 "polars-ols (==0.1.1)" ' "

I have tomli installed in my poetry project.

I believe polars_ds is using a similar project architecture and I experienced no issue like that with that package.

Any help would be appreciated!

Thanks again !

azmyrajab commented 7 months ago

Hi Adrien, thank you for raising the issue - and glad you think this package may be useful

Happy to look into this for you - mind if I start by asking you what platform / architecture / OS you are on?

Github CI tests cover most (but not all) Linux and macOS systems but not windows yet. I can then hopefully reproduce your issue on the server and try to get it fixed

azmyrajab commented 7 months ago

Also if you could share your python version that would be helpful too!

AdrienDart commented 7 months ago

Hi, thank you for your reply! I am using Python 3.9.0 from a poetry environment on a Windows machine.

azmyrajab commented 7 months ago

Hi @AdrienDart

windows support should be ready which should resolve the issue (see https://github.com/azmyrajab/polars_ols/commit/6a30e8c02014cf25076cde28c29e800d4fe39b41 and https://github.com/azmyrajab/polars_ols/commit/7060e6cbb67c6f4f1805756d9dacb53ad8899c24, and latest CI tests just passed)

So I'll let you know once the new pypy tag is released and you could try it out again? Will bundle in another improvement to how coefficients are outputted.

AdrienDart commented 7 months ago

Amazing! Take your time and again, thank you for your work!

azmyrajab commented 7 months ago

Hi @AdrienDart can you try installing again, just released v0.2.0 which should support windows OS

Could you please let me know if this resolves your issue?

AdrienDart commented 7 months ago

Hi, I just tried and I unfortunately got the same error message (with version 0.2.0 obviously). I'll migrate towards python 3.9.5 in a few days, maybe that will change something. Not sure what is causing this issue.

azmyrajab commented 7 months ago

Hey sorry about that, I think I have an idea what might be causing the issue now.

https://github.com/psf/black/blob/main/pyproject.toml#L70 https://github.com/psf/black/issues/3447

I think its because my project has a dependency on black (the python linting tool). which itself if on 3.8 depends on this tomli your installation is complaining about.

and then in my pyproject.toml ...

[tool.black]
target-version = ["py310", "py311"]

I think if I add py38 and py39 to the target versions it should work. To confirm this, let me try adding a CI test/build for windows on python 3.8 (it currently does windows on 3.10). Let me try that and get back to you (https://github.com/azmyrajab/polars_ols/commit/a09349c1abdb6b926b1e33aad45e97ed4ddebce8 - pending tests)

azmyrajab commented 7 months ago

Feel free to try again whenever you can and let me know if it works for you now. Tests here indicate py38 windows succeeds If forever reason it doesn't, let's wait until you upgrade to 3.9 and see if that resolves it

AdrienDart commented 7 months ago

Apologies for the confusion, I meant to upgrade from Python 3.9.0 to 3.9.5. It currently looks like my poetry is not picking up the version 0.2.2 of the package yet, still showing the 0.2.0. I'll try tomorrow. Thanks for the help!

AdrienDart commented 7 months ago

Hi, unfortunately, I get the same error with version 0.2.3.

azmyrajab commented 7 months ago

Strange. Unfortunately, I can’t reproduce on the windows test I am able to run on my side.

Whenever you could, can you please try installing manually with pip install in a new venv. And if errors copy the stack trace here. It will help us understand if this is specific to a poetry install or the specifics of your system so I can hopefully reproduce.

Sorry about this!

AdrienDart commented 7 months ago

No worries. I tried on a new venv running python 3.9.5. I manage to install polars and polars-ds on it with pip (24.0). When trying to do polars-ols, I got the following error:

" (...) Preparing metadata (pyproject.toml) ... error

x Preparing metadata (pyproject.toml) did not run successfully exit code: 1 Cargo, the Rust package manager, is not installed or not on PATH. This package requires Rust and Cargo to compile extensions. Install it though the system's package manager ot via https://rustup.rs/ Checking for Rust toolchain...

note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed

x Encountered error while generating package metadata.

(...) "

azmyrajab commented 7 months ago

Great, this is very helpful, I think I should be able to do something about this. Leave with me and I will keep you posted

azmyrajab commented 7 months ago

Hi @AdrienDart

I managed to finally reproduce your issue (..on an Azure windows VM) - and specifically on py39 but on no later versions (e.g. py312). So after some digging - I found the culprit to be this pyo3: feature flag in cargo.toml

Changing it to py38 from py310 means pyo3 (which is responsible for the rust bindings in python) must ensure wheels produced are compatible since py38+. Given my code is already backwards compatible, it made sense to change it pyo3 = { version = "*", features = ["extension-module", "abi3-py38"] } # set > py38 supported version

After releasing to PyPI the latest version (0.2.4):

image

Closing as this should now resolve your issue, whenever you can upgrade - but please do confirm that all is smooth when you have a chance!

AdrienDart commented 7 months ago

I can confirm that installation now works! Thank you for the package and for looking into this!