metno / pyaro-readers

implementations of readers for the pyaerocom project using pyaro as interface
GNU Lesser General Public License v2.1
0 stars 2 forks source link

Consider older ways of installation so older Python versions can be used #25

Closed jgriesfeller closed 10 months ago

jgriesfeller commented 10 months ago

like setup.cfg

avaldebe commented 10 months ago

Do you have an example where this is a problem? Or you mean to extend the Python support down to Python 3.8?

All that is needed to install with only pyproject.toml is a not to old version of pip. In general, the first step after creating a virtual environment is to update pip.

jgriesfeller commented 10 months ago

Heiko used the system wide Python in Jammy and was not able to do a pip install or python -m pip install with that. For the EBAS reader I want to support as many versions of Python as possible. If you have a way around that using pyproject.toml please let know. I am not an expert with that. pip issue: https://github.com/pypa/pip/issues/6264

jgriesfeller commented 10 months ago

I just tried with the standard Python in Jammy (the noted versions are those installed by apt): Python 3.10.12 and pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10) pyaro-readers is not installable from git there:

jang@pc5988:~$ python -m pip install 'pyaro-readers@git+https://github.com/metno/pyaro-readers.git'
Defaulting to user installation because normal site-packages is not writeable
Collecting pyaro-readers@ git+https://github.com/metno/pyaro-readers.git
  Cloning https://github.com/metno/pyaro-readers.git to /tmp/pip-install-epjkb_ch/pyaro-readers_e8b955d6e9b94aa1976b336f6ba0190f
  Running command git clone --filter=blob:none --quiet https://github.com/metno/pyaro-readers.git /tmp/pip-install-epjkb_ch/pyaro-readers_e8b955d6e9b94aa1976b336f6ba0190f
  Resolved https://github.com/metno/pyaro-readers.git to commit e5363fcc11b83d4739b61bfdfbc32cbbfb8aed8c
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
  WARNING: Generating metadata for package pyaro-readers produced metadata for project name unknown. Fix your #egg=pyaro-readers fragments.
Discarding git+https://github.com/metno/pyaro-readers.git: Requested unknown from git+https://github.com/metno/pyaro-readers.git has inconsistent name: filename has 'pyaro-readers', but metadata has 'unknown'
ERROR: Could not find a version that satisfies the requirement pyaro-readers (unavailable) (from versions: none)
ERROR: No matching distribution found for pyaro-readers (unavailable)

and also not with having the source locally:

jang@pc5988:~/.../Python3/pyaro-readers$ pip install .
Defaulting to user installation because normal site-packages is not writeable
Processing /home/jang/data/Python3/pyaro-readers
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: UNKNOWN
  Building wheel for UNKNOWN (pyproject.toml) ... done
  Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=10510 sha256=44d5402ba5f6d4bede44d4aa066d0093b883fdf2c68882691fab84eeaf49857c
  Stored in directory: /home/jang/.cache/pip/wheels/ea/b7/b3/6778b8c04e650f4e44b2f240068988ba77feb8283c2d59f950
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
Successfully installed UNKNOWN-0.0.0
avaldebe commented 10 months ago

I think the problem is trying to build the package with an old version of setuptools, installing the package from PyPI should not be a problem.

Jammy by default comes with python3.10, python and pip are not installed by default.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy

$ python
Command 'python' not found, did you mean:
  command 'python3' from deb python3
  command 'python' from deb python-is-python3

$ python3 --version
Python 3.10.12

The python3-pip package for Jammy provides pip version 22.0.2, which should be new enough to install a wheel from PyPI (or a prebuild wheel from somewhere else). The python3-setuptools package for Jammy provides setuptools version 59.6.0, which is too old to build the package. To build the package one needs setuptools version 61 or newer.

https://github.com/metno/pyaro-readers/blob/e5363fcc11b83d4739b61bfdfbc32cbbfb8aed8c/pyproject.toml#L1-L3

avaldebe commented 10 months ago
$ python -m pip install 'pyaro-readers@git+https://github.com/metno/pyaro-readers.git'

It is a bad idea to install python packages outside a virtual environment.

avaldebe commented 10 months ago

do this instead

# create and activate a virtual env
$ python3 -m venv --upgrade-deps --prompt pyaero path/to/virtual/env./venv

# activate virtual env
$ source path/to/virtual/env./venv/bin/activate

# install whatever you want
$ pip install 'pyaro-readers@git+https://github.com/metno/pyaro-readers.git'
jgriesfeller commented 10 months ago
$ python -m pip install 'pyaro-readers@git+https://github.com/metno/pyaro-readers.git'

It is a bad idea to install python packages outside a virtual environment.

That was just for testing...

avaldebe commented 10 months ago
$ python3 -m venv --upgrade-deps --prompt pyaero pyaero-env
$ pyaero-env/bin/pip --version
pip 23.3.2 from /home/alvarov/pyaero-env/lib/python3.10/site-packages/pip (python 3.10)
$ pyaero-env/bin/pip install 'pyaro-readers@git+https://github.com/metno/pyaro-readers.git'
[...]
Successfully built pyaro-readers pyaro
Installing collected packages: urllib3, tqdm, six, rtree, numpy, idna, click, charset-normalizer, certifi, attrs, shapely, requests, pyaro, cligj, click-plugins, fiona, pyaro-readers
Successfully installed attrs-23.2.0 certifi-2023.11.17 charset-normalizer-3.3.2 click-8.1.7 click-plugins-1.1.1 cligj-0.7.2 fiona-1.9.5 idna-3.6 numpy-1.26.3 pyaro-0.0.7.dev0 pyaro-readers-0.0.3 requests-2.31.0 rtree-1.1.0 shapely-2.0.2 six-1.16.0 tqdm-4.66.1 urllib3-2.1.0