linuxdeploy / linuxdeploy-plugin-conda

Python plugin for linuxdeploy. Sets up miniconda in an AppDir and installs user specified packages.
MIT License
29 stars 13 forks source link

Give an example for an application that uses setup.py #14

Closed probonopd closed 5 years ago

probonopd commented 5 years ago

Please give an example for an application that uses setup.py such as this one:

https://github.com/BasioMeusPuga/Lector

TheAssassin commented 5 years ago

They all use setup.py. What do you want to do? Install directly from git/GitHub? Install from a local clone?

For the latter use case, just use export PIP_REQUIREMENTS=".". Note that you have to cd there to make this work. You can also provide an absolute/relative path. If you encounter issues because setup.py assumes you're in the directory, you can use PIP_WORKDIR as a workaround, which instructs the plugin to cd to a directory before running pip.

probonopd commented 5 years ago

I would like to make an AppImage for https://github.com/BasioMeusPuga/Lector from its git master using linuxdeploy-plugin-conda but I do not know how to do this. Can you provide an example please? I don't think that Lector is in PyPI (and hence, pip).

TheAssassin commented 5 years ago

pip != PyPI. You've already used it to install stuff from git directly. It's not limited to PyPI. I've already given an example how you could use the plugin in a build script, just put a (relative) path into PIP_REQUIREMENTS.

probonopd commented 5 years ago

OK, let me give it a try. Sorry for the noise

TheAssassin commented 5 years ago

Don't worry, this can be confusing. In the Python world, things are IMO a bit "more open" than elsewhere, easier/more flexible in their use. Can be confusing for people who aren't used to it.

Keep asking questions please -- they'll probably be the base for some docs, if I ever get to it.

probonopd commented 5 years ago

The application has no requirements.txt file so I tried this:

export PIP_REQUIREMENTS="-e git+https://github.com/BasioMeusPuga/Lector#egg=Lector -c conda-forge pyqt -c conda-forge beautifulsoup4 -c conda-forge poppler"

But I am getting

[conda/stdout] installing: conda-4.5.12-py37_0 ...
[conda/stdout] installation finished.
[conda/stderr] Warning: 'conda-forge' already in 'channels' list, moving to the top
[conda/stderr] Could not open requirements file: [Errno 2] No such file or directory: 'conda-forge'
ERROR: Failed to run plugin: conda (exit code: 1) 

https://anaconda.org/conda-forge/pyqt gave me the idea that I might try -c conda-forge pyqt but apparently this was wrong?

probonopd commented 5 years ago

Possibly I need export CONDA_CHANNELS=??? CONDA_PACKAGES=???

TheAssassin commented 5 years ago

This -c <...> stuff is for the conda CLI.

Did you mean to install stuff using the conda package manager? You need to use the other variables for this. I think it's quite apparent that PIP_* isn't for conda.

Perhaps something like this?


export CONDA_CHANNELS="conda-forge"
export CONDA_PACKAGES="pyqt5"
export PIP_REQUIREMENTS="-e git+https://github.com/BasioMeusPuga/Lector#egg=Lector beautifulsoup4 poppler"
probonopd commented 5 years ago

What would I do if I wanted package A from conda-forge and package B from anaconda?

From the beginning I found the environment variables counter intuitive. Why not expand the https://github.com/AppImage/pkg2appimage/blob/master/YML.md format so that we could write something like:

ingredients:
  conda:
    - git:https://github.com/BasioMeusPuga/Lector
    - conda-forge:pyqt
    - conda-forge:beautifulsoup4
    - conda-forge:poppler

Something like this... just an idea... maybe we can even write a small wrapper around the existing tools?

probonopd commented 5 years ago

With export CONDA_PACKAGES="pyqt beautifulsoup4 poppler" I get

[conda/stderr] Warning: 'conda-forge' already in 'channels' list, moving to the top
[conda/stdout] failed
[conda/stderr] 
[conda/stderr] PackagesNotFoundError: The following packages are not available from current channels:
[conda/stderr] 
[conda/stderr]   - pyqt==beautifulsoup4=poppler
[conda/stderr] 
probonopd commented 5 years ago

Got it, needs to be export CONDA_PACKAGES="pyqt;beautifulsoup4;poppler"

TheAssassin commented 5 years ago

Sorry for that, the UI isn't too consistent yet. Conda wants stuff in one way, pip wants it the other way, ...

probonopd commented 5 years ago

This is what I have put together for now:

#! /bin/bash

sudo apt -y install git

export VERSION=$(wget -q "https://api.github.com/repos/BasioMeusPuga/Lector/commits?sha=master" -O - | grep sha | head -n 1 | cut -d '"' -f 4 | head -c 7
)

export APPNAME=lector
export PIP_REQUIREMENTS="-e git+https://github.com/BasioMeusPuga/Lector#egg=$APPNAME"
export CONDA_CHANNELS="conda-forge"
export CONDA_PACKAGES="pyqt;beautifulsoup4"  # Only use this if the package is in a Conda channel (e.g., conda-forge); can also be used for dependencies if the main application has no depends.txt

wget -c "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget -c "https://raw.githubusercontent.com/TheAssassin/linuxdeploy-plugin-conda/master/linuxdeploy-plugin-conda.sh"
chmod +x linuxdeploy-x86_64.AppImage linuxdeploy-plugin-conda.sh

rm -r AppDir || true

wget -c "https://github.com/BasioMeusPuga/Lector/raw/master/lector/resources/raw/lector.desktop"

cat > AppRun <<\EOF
#!/bin/bash
HERE="$(dirname "$(readlink -f "${0}")")"
exec "$HERE/usr/conda/bin/python" "$HERE/usr/conda/bin/lector" "$@"
EOF
chmod +x AppRun

wget -c "https://raw.githubusercontent.com/BasioMeusPuga/Lector/ed5bc0b2b9b92a506d4eb2144e349075caf3a8c0/lector/resources/raw/Lector.png" -O app.png
convert app.png -resize 512x512 $APPNAME.png

./linuxdeploy-x86_64.AppImage --appdir AppDir --plugin conda -i $APPNAME.png -d $(readlink -f "$APPNAME.desktop") --custom-apprun AppRun --output appimage

How can I make it use https://github.com/BasioMeusPuga/Lector/blob/master/lector/resources/raw/lector.desktop directly?

TheAssassin commented 5 years ago

Does it work, though?

probonopd commented 5 years ago

Still running because it downloads everything again

probonopd commented 5 years ago

"Works" as in "runs" :+1:

I can't seem to open EPUB 3.0 files from http://idpf.github.io/epub3-samples/30/samples.html with it but that may well be unrelated to the AppImage packaging.