ironpython2 icon indicating copy to clipboard operation
ironpython2 copied to clipboard

Cannot run pip on Mono

Open slide opened this issue 8 years ago • 12 comments

From @matthewblott on November 22, 2015 16:32

Hi,

I've installed IronPython for mono on OSX and it seems to work without any issues. I can open a terminal using ipy and call .NET code successfully. However pip doesn't run. I get the following error when I run "ipy -X:Frames -m pip install [package name]" from the terminal:

Could not import runpy module

Any ideas?

Thanks in advance.

Matt :-)

Copied from original issue: IronLanguages/main#1243

slide avatar Jun 09 '17 14:06 slide

Sorry for the long response time, we are just getting tests up and running on mono. Our mono support should be better in the future. I'll take s look at this issue soon.

slide avatar Jun 09 '17 14:06 slide

From @matthewblott on October 8, 2016 17:28

Thanks for the response. I just downloaded and built the last release (2.7.6.3) and the error was the same so I presume this is still open?

Moving forward, is Mono going to get full support or will the focus be on .NET Core? My assumption was the latter but my experience with .NET Core hasn't been good so far (it's a real moving target) in which case I'm guessing a fully supported and stable IronPython on POSIX based systems is some time away.

slide avatar Jun 09 '17 14:06 slide

We're going to support mono AND .NET Core.

slide avatar Jun 09 '17 14:06 slide

From @devkhan on January 20, 2017 9:56

Getting this:

$ mono ./ipy64.exe -X:Frames -X:FullFrames -m ensurepip
  File "/temp/ironpython3/Src/StdLib/Lib/_collections_abc.py", line 65
    class Hashable(metaclass=ABCMeta):

                            ^
SyntaxError: unexpected token '='
Could not import runpy module

on IronPython 3.0.0a0 DEBUG (3.0.0.0) on Mono 4.0.30319.42000 (32-bit) on macOS 10.12.

slide avatar Jun 09 '17 14:06 slide

Ipy3 is in a different repo and is not currently ready for usage.

slide avatar Jun 09 '17 14:06 slide

Didn't mean to close

slide avatar Jun 09 '17 14:06 slide

From @cwt on February 7, 2017 17:7

FYI: I also got this on Fedora 25, Mono JIT compiler version 4.4.2

$ mono ipyw64.exe -X:Frames -m ensurepip
Traceback (most recent call last):
  File "/home/cwt/Temp/IronPython-2.7.7/Lib/logging/__init__.py", line 861, in emit
    msg = self.format(record)
  File "/tmp/tmpborCfd/pip-8.1.1-py2.py3-none-any.whl/pip/utils/logging.py", line 108, in format
    if self.should_color():
  File "/tmp/tmpborCfd/pip-8.1.1-py2.py3-none-any.whl/pip/utils/logging.py", line 95, in should_color
    if hasattr(real_stream, "isatty") and real_stream.isatty():
SystemError: GetStdHandle
Logged from file basecommand.py, line 1

slide avatar Jun 09 '17 14:06 slide

Yeah, the isatty function currently will only work on Windows. It calls GetStdHandle via P/Invoke, which doesn't exist on non-Windows platforms.

slide avatar Jun 09 '17 14:06 slide

So technically no way to install pip packages on mono at the moment?

  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/Lib/distutils/util.py", line 101, in get_platform
  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/Lib/distutils/sysconfig.py", line 454, in get_config_vars
ImportError: No module named _sysconfigdata

Ok so one can generate this by calling the sysdata module (will generate an empty dictionary), similar to https://github.com/IronLanguages/ironpython2/commit/3071442ad4c1669441798db3fdc927430a284c80.

Afterwards, things will not work as we don't add the installed path to the sys path:

# installs here
/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages/pip/__main__.py

# below added automatically, note small and large lib matters 👍  
.
/Library/Frameworks/IronPython.framework/Versions/2.7.9/Lib
/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib
/Library/Frameworks/IronPython.framework/Versions/2.7.9/DLLs
/Library/Frameworks/IronPython.framework/Versions/2.7.9/Lib/site-packages

So in end you need:

env IRONPYTHONPATH=/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages \
 mono /Library/Frameworks/IronPython.framework/Versions/2.7.9/bin/ipy.exe \
   -X:Frames -m pip list
pip (8.1.1)
setuptools (20.10.1)
env IRONPYTHONPATH=/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages  mono /Library/Frameworks/IronPython.framework/Versions/2.7.9/bin/ipy.exe -X:Frames -m pip -vvv  install .
Processing /Users/bgabor8/git/virtualenv
  Running setup.py (path:/var/folders/kt/btg285ds5kx4l1k398lb7df80000gr/T/pip-VXlIi4-build/setup.py) egg_info for package from file:///Users/bgabor8/git/virtualenv
    Running command python setup.py egg_info
    Error Cannont redirect stderr to stdout yet. while executing command python setup.py egg_info
Cleaning up...
Exception:
Traceback (most recent call last):
  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
    status = self.run(options, args)
  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages/pip/commands/install.py", line 299, in run
    requirement_set.prepare_files(finder)
  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages/pip/req/req_set.py", line 356, in prepare_files
    discovered_reqs.extend(self._prepare_file(
  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/Lib/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Library/Frameworks/IronPython.framework/Versions/2.7.9/lib/python2.7/site-packages/pip/utils/logging.py", line 36, in indent_log
    yield
NotImplementedError: Cannont redirect stderr to stdout yet.

gaborbernat avatar Dec 16 '18 20:12 gaborbernat

We merged in an empty _sysconfigmodule recently, I am not sure what else might be missing at this point

slide avatar Dec 17 '18 01:12 slide

I believe there are some tweaks that need to be done in distutils to get the pip install folders to work properly on Linux.

slozier avatar Dec 17 '18 01:12 slozier

At the moment my blocker seems to be NotImplementedError: Cannont redirect stderr to stdout yet.

gaborbernat avatar Dec 17 '18 07:12 gaborbernat