Skip to content

Allow running Preciso and installing the package

Arnaud requested to merge setup-py into master

J'ai :

  • Ajouté un setup.py qui permet d'installer Preciso pour le rendre importable depuis n'importe où.
  • Ajouté un binaire Linux, celui pour Mac ne marche pas sur mon PC. Je les ai renommés et mis dans le dossier preciso/bin à cause de contraintes d'installation.
  • Ecrit une fonction qui lance un InputFile avec le bon exécutable de PreciSo selon la plateforme. A tester sur Mac et Windows...

Pour tester :

Télécharger les modifications

Extraire l'archive, entrer dedans, depuis un terminal installer le paquet avec :

pip3 install -e . --user

puis, depuis un autre dossier (un dossier vide appelé test par exemple), lancer la commande :

python3 -c "import preciso.run; print(preciso.run.run.__doc__); print(preciso.run.run('hello'))" 

Cela devrait donner la doc de ma nouvelle fonction, ce qui montre qu'elle a bien été importée :

Run PreciSo with specified inputFileName.
    It makes use of a system call to the PreciSo executable. The input file
    should be formatted as described [here](https://framagit.org/arnall/preciso/wikis/Input%20files%20in%20PreciSo).
    PreciSo binaries are treated as [package data](https://docs.python.org/3/distutils/setupscript.html#installing-package-data) and are therefore accessible using the `pkg_ressources` module.
    System calls are made using [subprocess.getoutput](https://docs.python.org/3/library/subprocess.html#subprocess.getoutput).

    Parameters
    ----------

    inputFileName : pathlib.Path object or str
        The path to the input file to use in Preciso. Can be given either as
        a `pathlib.Path` object (recommended as it is cross-plateform) or as
        a `str` that complies with the computer's filesystem.

    Returns
    ----------
    out : str
        The `stdout` obtained from running PreciSo using `subprocess`.

    Examples
    --------
    >>> preciso.run.run('')
    Welcome to PreciSo v3.0
    FATAL ERROR: PreciSo have been launch with an incorrect number of arguments

suivi du résultat de preciso.run.run('hello') :

Welcome to PreciSo v3.0
FATAL ERROR: File hello not found

Si ça ne marche pas tu peux répondre directement sur cette page, sinon tu peux accepter.

Merge request reports