ubarsc / rios

A raster processing layer on top of GDAL
https://www.rioshome.org
GNU General Public License v3.0
14 stars 7 forks source link

Package version isn't available to pip install from version 2.0.1 onwards #97

Closed tonykgill closed 2 months ago

tonykgill commented 2 months ago

Just wondering what behaviour you observe when you pip install the package, from version 2.0.1 onwards.

The issue for me is that package version number isn't recognised when running 'pip install'. Example:

root@ccda2a69d740:/home/cibouser# export RIOS_VERSION=2.0.3
root@ccda2a69d740:/home/cibouser# cd /tmp
root@ccda2a69d740:/tmp# wget -q https://github.com/ubarsc/rios/releases/download/rios-${RIOS_VERSION}/rios-${RIOS_VERSION}.tar.gz
root@ccda2a69d740:/tmp# tar xf rios-${RIOS_VERSION}.tar.gz 
root@ccda2a69d740:/tmp# cd rios-${RIOS_VERSION}
root@ccda2a69d740:/tmp/rios-2.0.3# echo ${SW_VOLUME}
/cibosw
root@ccda2a69d740:/tmp/rios-2.0.3# pip install --prefix=${SW_VOLUME} .
Processing /tmp/rios-2.0.3
  Installing build dependencies ... done
  Getting requirements to build wheel ... 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=13297 sha256=a23cc36745523b0b2dd040ea983cac5e1ca46c49f477e0b10dfe35dd8b911591
  Stored in directory: /root/.cache/pip/wheels/0c/02/75/9c58237876d0ea98bc066aeb4a8f74e34c8a86aaf54903d048
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
  Attempting uninstall: UNKNOWN
    Found existing installation: UNKNOWN 0.0.0
    Uninstalling UNKNOWN-0.0.0:
      Successfully uninstalled UNKNOWN-0.0.0
Successfully installed UNKNOWN-0.0.0

I see that the version is defined dynamically in pyproject.toml, referring to the rios.version attribute. Reading this documentation I would expect this to work.

I upgraded to setuptools 70.1.1 (latest), thinking my distro's version (59.x.y) might have been the problem. But, no, I get the same behaviour.

Just wondering if you are also observing the same behaviour?

If so, perhaps a workaround is to store the version number in a file called rios/VERSION. It has one line with the version number.

2.0.3

Then modify pyproject.toml:

[tool.setuptools.dynamic]
version = {file = "rios/VERSION"}

And update rios/init.py:

import pathlib
version_file_path = pathlib.Path(__file__).parent / 'VERSION'
with open(version_file_path, 'r') as version_file:
    RIOS_VERSION = version_file.read().strip()
__version__ = RIOS_VERSION
tonykgill commented 2 months ago

Updating both pip and setuptools seems to have solved my crisis.

neilflood commented 2 months ago

Just a further note. The error is caused by an older version of setuptools. However, pyproject.toml specifies that it requires a newer version, but older versions of pip don't know enough to honour this. So, the key here is to upgrade pip, and this then installs its own newer version of setuptools in the venv it uses to do the build.

There is a note at the top of pyproject.toml explaining that it needs at least version 23 of pip, but there is no way to enforce this.