curdling icon indicating copy to clipboard operation
curdling copied to clipboard

`curd` can't install packages in editable form

Open suzaku opened this issue 12 years ago • 5 comments

Some of my projects depend on packages in editable mode, and I use pip freeze to generate requirements.txt which would include lines like this:

-e git+https://github.com/suzaku/curdling.git@864313157e4f0966a32f24fae4e525de71ce435c#egg=curdling-master

Such lines will cause curd to throw UnknownURL, because Downloader currently doesn't try to parse them.

Most existing Python projects use pip to install packages, so I think there may be others like me who encounter problem like this trying to use curd.

So maybe we should add pip-compatible support of VCS editable mode to curdling?

suzaku avatar Nov 12 '13 08:11 suzaku

+1

harobed avatar Jan 21 '14 14:01 harobed

It is definitely a feature I've been expecting to see in curdling. However, my life is kinda crazy right now and I don't have time to implement that command. It would be great to see it working though, let me know if any of you guys is interested in working on a patch! Thanks for filing the issue!

clarete avatar Jan 21 '14 15:01 clarete

@clarete do you know if distlib have function to install simple package ? (no wheel package)

harobed avatar Jan 21 '14 16:01 harobed

@harobed IRC, distlib does not provide this feature so far, It's usually setuptools that does this job. People like pip and curdling just fork a subprocess to run the setup.py script. The setup() function will, among other things, call the code that installs each file in its target directory.

Curdling only uses the setup.py script of a package to build it, but you could definitely use the machinery inside of curdling to install regular packages.

Take a look here: https://github.com/clarete/curdling/blob/master/curdling/services/curdler.py#L77-L99

I guess you could install a regular package using curdling as a library:

import tempfile, shutil
from curdling.services.curdler import *

def install_package(path_to_the_tarball_or_zip):
    tmp = tempfile.mkdtemp()
    try:
        setup_py = get_setup_from_package(path_to_the_tarball_or_zip, tmp)
        run_setup_script(setup_py, 'install')
    except (NoSetupScriptFound, UnpackingError) as exception:
        print('Meh, your package is not installed: {0}'.format(exception))
    finally:
        shutil.rmtree(tmp)

I didn't test this snippet, so it might not work! Let me know if you need any extra help! :)

clarete avatar Jan 21 '14 20:01 clarete

Just reporting that the script above works like a charm for tar.bz2, tar.gz and zip files! It sounds like good feature for curdling too! Thanks!

clarete avatar Jan 21 '14 20:01 clarete