thatstoasty / mog

Style definitions for nice terminal layouts.
MIT License
35 stars 2 forks source link

cannot package #5

Closed dimitrilw closed 6 months ago

dimitrilw commented 6 months ago

I am using Mojo version mojo 24.2.1 (2f0dcf11).

I cloned the mog repository and cd'd to the root of the repo. Then, I ran mojo package mog/ -o mog.📦, resulting in this error output:

Included from mog/__init__.mojo:1:
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/mog/align.mojo:2:
/Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/ansi/ansi.mojo:59:37: error: no matching function in initialization
    var p = DTypePointer[DType.int8](s.data).bitcast[DType.uint8]()
            ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
mog/__init__.mojo:1:1: note: candidate not viable: expected at most 0 positional arguments, got 1
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'pointer<scalar<si8>>'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'Pointer[SIMD[si8, 1], 0]'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'SIMD[address, 1]'
from .style import Style, NO_TAB_CONVERSION
^
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/__init__.mojo:1:
/Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/wordwrap.mojo:93:41: error: no matching function in initialization
        var p = DTypePointer[DType.int8](s_bytes.steal_data()).bitcast[DType.uint8]()
                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mog/__init__.mojo:1:1: note: candidate not viable: expected at most 0 positional arguments, got 1
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'pointer<scalar<si8>>'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'Pointer[SIMD[si8, 1], 0]'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'SIMD[address, 1]'
from .style import Style, NO_TAB_CONVERSION
^
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/__init__.mojo:1:
/Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/wrap.mojo:79:41: error: no matching function in initialization
        var p = DTypePointer[DType.int8](s_bytes.steal_data()).bitcast[DType.uint8]()
                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
mog/__init__.mojo:1:1: note: candidate not viable: expected at most 0 positional arguments, got 1
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'pointer<scalar<si8>>'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'Pointer[SIMD[si8, 1], 0]'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'SIMD[address, 1]'
from .style import Style, NO_TAB_CONVERSION
^
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/__init__.mojo:1:
/Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/truncate.mojo:42:41: error: no matching function in initialization
        var p = DTypePointer[DType.int8](src.data).bitcast[DType.uint8]()
                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
mog/__init__.mojo:1:1: note: candidate not viable: expected at most 0 positional arguments, got 1
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'pointer<scalar<si8>>'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'Pointer[SIMD[si8, 1], 0]'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'SIMD[address, 1]'
from .style import Style, NO_TAB_CONVERSION
^
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/ansi/__init__.mojo:1:
/Users/dimitri/code/MOJO-PACKAGES/mog/external/weave/ansi/writer.mojo:36:41: error: no matching function in initialization
        var p = DTypePointer[DType.int8](src.data).bitcast[DType.uint8]()
                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
mog/__init__.mojo:1:1: note: candidate not viable: expected at most 0 positional arguments, got 1
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'pointer<scalar<si8>>'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'Pointer[SIMD[si8, 1], 0]'
from .style import Style, NO_TAB_CONVERSION
^
mog/__init__.mojo:1:1: note: candidate not viable: argument #0 cannot be converted from 'AnyPointer[SIMD[si8, 1]]' to 'SIMD[address, 1]'
from .style import Style, NO_TAB_CONVERSION
^
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/external/gojo/builtins/__init__.mojo:1:
Included from /Users/dimitri/code/MOJO-PACKAGES/mog/external/gojo/builtins/__init__.mojo:4:
/Users/dimitri/code/MOJO-PACKAGES/mog/external/gojo/builtins/errors.mojo:1:17: error: package 'sys' does not contain 'exit'
from sys import exit
                ^
mojo: error: failed to parse the provided Mojo
thatstoasty commented 6 months ago

Hey! Sorry, I should drop a note in the README until the next Mojo release comes out. There are a few features that rely on changes currently in the nightly/mojo version, namely the Tuple unpacking update. We should probably see a new Mojo release which includes these features within a week or so I would think. After this release, the library will go back to being in sync with the latest Mojo release.

If you want to try this out now, please install the nightly mojo build with modular install nightly/mojo.

dimitrilw commented 6 months ago

Ty!

dimitrilw commented 6 months ago

Some day we'll have an improved packaging system with pinned versions (including mojo version) that makes all this a lot easier. The bleeding edge is bloody after all. 😄

thatstoasty commented 6 months ago

I can't wait for a proper packaging system, it's definitely a challenge for the time being. It's like coding in hard mode just trying to build something while fighting against the compiler, the language, and the packaging haha

dimitrilw commented 6 months ago

^this. 100% this.

dimitrilw commented 6 months ago

Perhaps you could add a badge to the top of the readme. Something like: Mojo Nightly 24.x

thatstoasty commented 6 months ago

Oh nice, that's pretty cool! I'll add that, thank you

dimitrilw commented 6 months ago

I should have included easy-to-copy line:

![Mojo Nightly 24.x](https://img.shields.io/badge/Mojo%F0%9F%94%A5-Nightly_24.x-purple)
dimitrilw commented 6 months ago

Sorry for comment spam -- I should slow down and thing before pressing enter; I'm using this issue like a rapid-fire chat channel.

Note that the sample has the version inside the alt-text ([Mojo Nightly 24.x]) and also in the badge's URL. You'll want to update both as needed.

thatstoasty commented 6 months ago

No worries, I appreciate it! Were you able to build the package while using nightly mojo?

dimitrilw commented 6 months ago

I haven't tried yet. Most of my keyboard time the last couple days has been on client work. And most of my Mojo time was "crazed imaginary coding while I took a few walks to break up the client work hours." 😂

I'm installing nightly/mojo right now. But not finding the right documentation on it -- do you know if you can easily toggle between nightly & stable? I'm not aware of any "nvm" like system in Mojo (yet) or version pinning or anything. After I install, am I basically doing everything in nightly when I mojo blahblah.mojo and mojo package blahblah.mojo -o blahblah.📦 etc...?

Thank you for letting me abuse you as a source of knowledge. 😊

dimitrilw commented 6 months ago

Ah, think I got my answer. The launcher is just determined by PATH search order, so I did this as a lazy quick-n-manual toggle in my ~/.zshrc. In the future, I might add an alias that lets me hot-swap my PATH settings. I've done that before in the early days of "how many versions of Python/JS/whatever do I need to keep installed??" But it gets messy. For now, this works.

# mojo versions: stable & nightly
export MOJO_STABLE_PATH="/Users/dimitri/.modular/pkg/packages.modular.com_mojo/bin"
export MOJO_NIGHTLY_PATH="/Users/dimitri/.modular/pkg/packages.modular.com_nightly_mojo/bin"
# mojo version in use
export PATH="$MOJO_NIGHTLY_PATH:$PATH"
dimitrilw commented 6 months ago

Looks like it worked. I haven't tried importing and using the package, but it did run the command and generate the output file. I'll mark this issue closed. Ty!

image
thatstoasty commented 6 months ago

There's some documentation on using nightly in the mojo GitHub repository but it's pretty sparse like you've said. I usually just update my PATH variables to swap between the two. Not very elegant, but it works