• Installing a module

    From saito@saitology9@gmail.com to comp.lang.tcl on Sun Jun 22 17:34:17 2025
    From Newsgroup: comp.lang.tcl

    With packages, there is a single folder where I collect all packages I
    may use, whether they are built-in or downloaded from somewhere. The
    folder location is the default, and I don't need to muck around paths
    either when I start tkcon.

    Modules seem to refuse this simplicity. A module is supposed be a
    single file. But I am not sure this is true in practice.

    So there is a module I want to use. It comes as a zipped file. Unzipped,
    it has a readme, a copyright file, a subfolder, and a .tm file.

    I could create a folder dedicated to modules, adjust the tm paths, and
    put all those in there. At first, this seems like it will work.

    However, what happens when I want to use a new module? Presumable it too
    will have its own readme, copyright, etc. So I can't just put it in that folder as it will overwrite the previous module. So I need to create a
    new folder, revise the tm paths, etc.

    Is there a way to simplify this so you can just download modules, put
    them somewhere and forget about the maintenance overhead? Something
    similar to traditional packages and their single folder policy where
    each package comes with its own folder and the load command knows this.


    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Rich@rich@example.invalid to comp.lang.tcl on Mon Jun 23 03:58:16 2025
    From Newsgroup: comp.lang.tcl

    saito <saitology9@gmail.com> wrote:
    Modules seem to refuse this simplicity. A module is supposed be a
    single file. But I am not sure this is true in practice.

    This is in reference to the Tcl interpreter view, not the "human
    distributor viewpoint".

    So there is a module I want to use. It comes as a zipped file. Unzipped,
    it has a readme, a copyright file, a subfolder, and a .tm file.

    The only "module" file present there (as far as Tcl is concerned) is
    the .tm file. That is the "module", and is all Tcl will look for when
    you try to package require the module. The other files are essentially side-cars for human use. The subfolder may or may not contain files
    that the code inside the .tm uses, so it may, or may not, be needed.

    I could create a folder dedicated to modules, adjust the tm paths, and
    put all those in there. At first, this seems like it will work.

    If all your .tm files do not try to consume other files (code in a
    mudule can do anything Tcl can do) you could have a single directory containing 100 .tm files, and be able to package require any one to
    all, by pointing the module path at that single directory. And you
    could continue to add more by adding more .tm files there.

    However, what happens when I want to use a new module? Presumable it too will have its own readme, copyright, etc. So I can't just put it in that folder as it will overwrite the previous module. So I need to create a
    new folder, revise the tm paths, etc.

    Only if you wish to keep copies of all the side-car files present for
    human consumption. If you just want a collection of modules, you don't
    need the side-cars (for package require purposes). Of course, if in X
    years you wonder where module blah.tm came from, not having the
    side-car files around might make the task of tracking it down a bit
    more difficult.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Harald Oehlmann@wortkarg3@yahoo.com to comp.lang.tcl on Mon Jun 23 13:28:37 2025
    From Newsgroup: comp.lang.tcl

    Am 23.06.2025 um 05:58 schrieb Rich:
    saito <saitology9@gmail.com> wrote:
    Modules seem to refuse this simplicity. A module is supposed be a
    single file. But I am not sure this is true in practice.

    This is in reference to the Tcl interpreter view, not the "human
    distributor viewpoint".

    So there is a module I want to use. It comes as a zipped file. Unzipped,
    it has a readme, a copyright file, a subfolder, and a .tm file.

    The only "module" file present there (as far as Tcl is concerned) is
    the .tm file. That is the "module", and is all Tcl will look for when
    you try to package require the module. The other files are essentially side-cars for human use. The subfolder may or may not contain files
    that the code inside the .tm uses, so it may, or may not, be needed.

    I could create a folder dedicated to modules, adjust the tm paths, and
    put all those in there. At first, this seems like it will work.

    If all your .tm files do not try to consume other files (code in a
    mudule can do anything Tcl can do) you could have a single directory containing 100 .tm files, and be able to package require any one to
    all, by pointing the module path at that single directory. And you
    could continue to add more by adding more .tm files there.

    However, what happens when I want to use a new module? Presumable it too
    will have its own readme, copyright, etc. So I can't just put it in that
    folder as it will overwrite the previous module. So I need to create a
    new folder, revise the tm paths, etc.

    Only if you wish to keep copies of all the side-car files present for
    human consumption. If you just want a collection of modules, you don't
    need the side-cars (for package require purposes). Of course, if in X
    years you wonder where module blah.tm came from, not having the
    side-car files around might make the task of tracking it down a bit
    more difficult.


    Perhaps an additional information:
    the search path for ".tm" files and "pckIndex.tcl files is different:

    set auto_path
    search path for pckIndex.tcl files
    ::tcl::tm::path list
    search for .tm files

    The idea of .tm files is, that basically the pckIndex.tcl is included in
    the file name for single file packages.

    So a package "demo" has:
    demo/pckIndex.tcl
    demo/demo.tcl
    where "pckIndex.tcl" has the content: "package ifneeded demo 1.0 [list
    source [file join $dir demo.tcl]]"

    Then, the one file distribution as .tm file can be created by:
    file copy demo/demo.tcl demo-1.0.tm
    The pckIndex.tcl is not needed any more.

    Harald

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From saito@saitology9@gmail.com to comp.lang.tcl on Mon Jun 23 10:04:42 2025
    From Newsgroup: comp.lang.tcl

    On 6/22/2025 11:58 PM, Rich wrote:

    Only if you wish to keep copies of all the side-car files present for
    human consumption. If you just want a collection of modules, you don't
    need the side-cars (for package require purposes). Of course, if in X
    years you wonder where module blah.tm came from, not having the
    side-car files around might make the task of tracking it down a bit
    more difficult.


    I think we are in agreement on all the points you raised on interpreter
    vs. human distributor point of views. The current mechanism seems to put
    the burden on the human consumer in that they will have to take extra
    steps. Either you will have to unzip and extract .tm file out, and
    discard the rest, or keep track of what modules you have and add tm path commands for each to your setup.

    Either way is fine with me. I wondered how other people were handling it.

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From saito@saitology9@gmail.com to comp.lang.tcl on Mon Jun 23 10:10:31 2025
    From Newsgroup: comp.lang.tcl

    On 6/23/2025 7:28 AM, Harald Oehlmann wrote:

    Then, the one file distribution as .tm fileĀ  can be created by:
    file copy demo/demo.tcl demo-1.0.tm
    The pckIndex.tcl is not needed any more.


    As an end user or consumer of a module, I find it has other files and sub-directories than just a pkgindex file, and it is distributed as as a compressed file.

    --- Synchronet 3.21a-Linux NewsLink 1.2