mamba icon indicating copy to clipboard operation
mamba copied to clipboard

Enable list packages installed with pip in micromamba

Open Hind-M opened this issue 3 years ago • 13 comments

Fix #2059

Hind-M avatar Nov 08 '22 17:11 Hind-M

Awesome!

wolfv avatar Nov 08 '22 18:11 wolfv

Maybe naive question, why don't we just use pip freeze or something like that? Is the site-packages method guaranteed to work?

jonashaag avatar Nov 09 '22 14:11 jonashaag

Maybe naive question, why don't we just use pip freeze or something like that? Is the site-packages method guaranteed to work?

That could be a way too I guess (but then we should be able to get the output of the launched command, is there another method allowing that since reproc::run doesn't?)... Using site-packages method was inspired from the way they do it in conda but less complicated. I haven't fully tested it yet because I was trying to activate a micromamba env within a conda env (using a built micromamba) which doesn't seem to work... A bug or maybe I missed something?

Hind-M avatar Nov 09 '22 16:11 Hind-M

Hmm, actually I think that the way I did it won't do because I considered that pip install pkg passes necessarily through install code in micromamba, which is only the case when we do install from a spec file and pip is mentioned there... So I guess we should use a different method (maybe the pip freeze one if, as I said, there is a way to get the output)... I kind of understand now the complicated way of conda...

Hind-M avatar Nov 09 '22 18:11 Hind-M

does this also cover micromamba env export?

zacharyburnett avatar Nov 21 '22 19:11 zacharyburnett

This PR is still a WIP, but when done the env export should be pretty straightforward I think.

Hind-M avatar Nov 22 '22 09:11 Hind-M

>       assert expected_link_packages.issubset(link_packages)
E       AssertionError: assert False
E        +  where False = <built-in method issubset of set object at 0x10a0cb300>({'openssl', 'pip', 'python', 'readline', 'setuptools', 'sqlite', ...})
E        +    where <built-in method issubset of set object at 0x10a0cb300> = {'python', 'python_abi'}.issubset

is this a MacOS issue?

zacharyburnett avatar Dec 23 '22 17:12 zacharyburnett

>       assert expected_link_packages.issubset(link_packages)
E       AssertionError: assert False
E        +  where False = <built-in method issubset of set object at 0x10a0cb300>({'openssl', 'pip', 'python', 'readline', 'setuptools', 'sqlite', ...})
E        +    where <built-in method issubset of set object at 0x10a0cb300> = {'python', 'python_abi'}.issubset

is this a MacOS issue?

Well it does happen only on the MacOS on CI, but I can't tell for sure if the error is related to this PR or not... (I'll have to investigate more...)

Hind-M avatar Dec 26 '22 10:12 Hind-M

cc @AntoinePrv Thanks :)

Hind-M avatar Mar 24 '23 15:03 Hind-M

@Hind-M, playing around with pip, I found the following good ideas:

  • pip [...] --path [PrefixData] could be a good idea to make sure we are using the right path (even if the wrong pip, see comment)
  • pip inspect could be perfect here. It returns a json (therefore safe to parse) with plenty of useful information, in particular that installed[pgk_idx].installer (pip or conda) and installed[pgk_idx].requested
{
      "metadata": {
        "metadata_version": "2.1",
        "name": "args",
        "version": "0.1.0",
        "platform": [
          "any"
        ],
        "summary": "Command Arguments for Humans.",
        "home_page": "https://github.com/kennethreitz/args",
        "author": "Kenneth Reitz",
        "author_email": "[email protected]",
        "license": "BSD",
        "classifier": [
          "Environment :: Web Environment",
          "Intended Audience :: Developers",
          "License :: OSI Approved :: BSD License",
          "Operating System :: OS Independent",
          "Programming Language :: Python",
          "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
          "Topic :: Software Development :: Libraries :: Python Modules"
        ],
        "description": "\nargs\n~~~~\n\nThis simple module gives you an elegant interface for your command line argumemnts.\n\n\n\n"
      },
      "metadata_location": "/Users/antoine/.local/share/mamba/envs/mamba-dev/lib/python3.10/site-packages/args-0.1.0.dist-info",
      "direct_url": {
        "url": "file:///home/conda/feedstock_root/build_artifacts/args_1637347267685/work",
        "dir_info": {}
      },
      "installer": "conda",
      "requested": true
    },

AntoinePrv avatar Mar 30 '23 13:03 AntoinePrv

I think this would be an amazing feature to have Can't wait :)

RafailFridman avatar Jun 29 '23 07:06 RafailFridman

any updates? imho this is a priority bug because it prevents most people to use micromamba if they can't see any installed pip packages. workaround using conda works but then why use micromamba in the first place? it's main unique selling point is that it's a standalone application which makes it really stand out

agilebean avatar Nov 02 '23 02:11 agilebean

I really appreciate y'all's work on this PR, and just wanted to say I still find this to be an important missing feature in my workflow; for now, I install conda in my workflow's environment solely to do conda env export > environment.yml so I can have the pip: section in the output. Looking forward to this being merged eventually!

zacharyburnett avatar May 23 '24 16:05 zacharyburnett

Superseded by #3565

Hind-M avatar Oct 28 '24 13:10 Hind-M