SyneRBI / SIRF-Exercises

SIRF Training and demonstration material
http://www.ccpsynerbi.ac.uk
Apache License 2.0
17 stars 21 forks source link

remove --only-binary #187

Closed paskino closed 1 year ago

paskino commented 1 year ago

Removes --only-binary from the requirements.txt that make conda fail install with this file, see https://github.com/SyneRBI/SIRF-SuperBuild/actions/runs/3892212789/jobs/6645282809#step:7:2249

KrisThielemans commented 1 year ago

as long as someone has tried this, I would just merge

paskino commented 1 year ago

the command conda install -c conda-forge -y --file requirements.txt fails anyway on brainweb which isn't available on conda-forge.

Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - brainweb[version='>=1.5.1']
KrisThielemans commented 1 year ago

oh well. presumably an extra requirements.yml would do it, that goes to pip for brainweb only.

paskino commented 1 year ago

Or we change the install command to do line-by-line with python.

paskino commented 1 year ago

oh well. presumably an extra requirements.yml would do it, that goes to pip for brainweb only.

This would work, however, we use the yml file to modify a current environment, so we need to know the name of the environment!

paskino commented 1 year ago

something like the following seems to to be able to read the requirements.txt filter out the brainweb and make a single install command for conda, which is preferrable.

However, it fails to resolve (also with mamba)

Encountered problems while solving:
  - package llvmlite-0.2.0-py33_0 requires python 3.3*, but none of the providers can be installed

import sys
import re
import subprocess
import functools

def conda_install(package):
    return f'conda install -y -c conda-forge {package}'.rstrip()

def pip_install(package):
    return f'pip install -U -r {package}'.rstrip()

not_on_conda_forge = ['brainweb']

if __name__ == '__main__':
    infile = sys.argv[1]

    install_by_conda = []
    install_by_pip = []
    with open(infile , 'r') as f:
        for line in f:
            if line[0].strip() not in ['#', '']:
                # clean line after any comment
                if '#' in line:
                    line = line.split('#')[0]
                for pkg in not_on_conda_forge:
                    pattern = re.compile(f'{pkg}(.*)')
                    mtc = pattern.match(line.rstrip())
                    if mtc is None:
                        install_by_conda.append(line.rstrip())
                    else:
                        print (f'Not on conda-forge: {line.rstrip()}')
                        install_by_pip.append(line.rstrip())

    install_by_conda = functools.reduce(lambda x, y: x + ' ' + y, install_by_conda, '')
    print (install_by_conda)

    install_by_pip = functools.reduce(lambda x, y: x + ' ' + y, install_by_pip, '')
    print (install_by_pip)

    try:
        subprocess.run(conda_install(install_by_conda), shell=True, check=True)
        subprocess.run(pip_install(install_by_pip), shell=True, check=True)

    except subprocess.CalledProcessError as cpe:
        print (cpe)
paskino commented 1 year ago

It failed because I had python 3.11 installed, downgrading to 3.9 worked.