17
$\begingroup$

I'd like to get a serious discussion started about a package manager. This has come up elsewhere, and many people have implemented their own solutions. It would be nice to have a standardized way to deploy and distribute Mathematica code to anyone.

I also imagine we could distribute other content this way. For example, one thing I think would be nice, if there were interest, would be to collate information from this site and serve it as a package that includes tools and supplemental documentation.

Please share your ideas on how we can achieve this.

$\endgroup$
5
  • $\begingroup$ It might be better to follow halirutan's lead and make this a self-answered question (Q. Can we create a package manager? A. Yes we can...) with an associated chat room for discussions. As currently posed it's not clear what would constitute a "correct" answer and it risks being closed as primarily opinion based. $\endgroup$ Jun 4, 2014 at 15:46
  • 1
    $\begingroup$ Have you looked at ProjectInstaller by @LeonidShifrin. It's not a full blown package management system, but installer like that could be a part of such system. $\endgroup$
    – jkuczm
    Jun 11, 2014 at 14:18
  • $\begingroup$ @jkuczm Since you brought this up, let me just mention that I do have Mathematica package manager under development, but it has to incorporate a number of things to become really useful for Mathematica code. In particular, in my framework, the package manager is only a part of the larger infrastructure aimed to enable people to easily share and reuse Mathematica code. Given this fresh initiative, I will publish my ideas in a separate answer some time soon (currently in the hospital and not fully functional). $\endgroup$ Jun 12, 2014 at 11:27
  • $\begingroup$ @LeonidShifrin Can't wait to see it. I hope you'll get well soon. $\endgroup$
    – jkuczm
    Jun 12, 2014 at 18:39
  • $\begingroup$ @jkuczm Thanks! $\endgroup$ Jun 12, 2014 at 18:45

1 Answer 1

13
$\begingroup$

I've prototyped a package downloading system (Mapt) that supports multiple versions, and will show its basic functionality below. Does it work? would you use it? what needs to change? what else would you want it to do? what packages do you want? do you want to work on this project together? do you have an alternative way of doing this?

Load Mapt:

Get[ "http://mfvonh.me/mapt" ] ;
??Mapt

enter image description here

It is not yet installed locally:

Mapt[ Path ]

None

It can be installed anywhere in $Path.

Mapt[ Install ]

enter image description here

True

Then it can be loaded with Needs[ "Mapt`" ] if it is not in an Autoload folder:

FindFile[ "Mapt`" ]

D:\Program Files\Wolfram Research\Mathematica\9.0\AddOns\Autoload\Mapt\init.m

These are the available packages:

Mapt[ List ]

{"HelloWorld", "LevelScheme"}

And basic installation:

Mapt[ Get , "HelloWorld" ]

True

Packages can then be loaded like this:

Needs["HelloWorld`Current`"]
??HelloWorld

enter image description here

All available versions of a package can be listed:

Mapt[ VersionNumber , "HelloWorld" , All ]

{1.0, 1.1}

A specific version can be installed:

Mapt[ Get , "HelloWorld" , "1.0" ]

True

Multiple versions can be on the disk:

Needs[ "HelloWorld`Version1$0`" ]
??HelloWorld

enter image description here

A more complex package:

Mapt[ Get , "LevelScheme" ]

Fetching LevelScheme...

Extracting...

Initializing...

Done

Needs[ "LevelScheme`Current`" ]

enter image description here

Figure[{
  SetOptions[Lev, Thickness -> 3, Color -> Red], 
  SetOptions[Trans, ArrowType -> ShapeArrow, FillColor -> LightGray], 
  Lev[lev1, 0, 2, 0],
  Lev[lev2, 1, 2, 100],
  Lev[lev3, 0, 2, 200],
  Trans[lev2, 0.5, lev1, 0.9, Width -> 10], 
  Trans[lev3, 0.5, lev1, 0.5, Width -> 20]},
 PlotRange -> {{0, 2}, {-10, 210}},
 ImageSize -> 72*{3, 3}]

enter image description here

To install the package Mapt creates a temporary directory, sets it, and then just pulls a small script:

Import[Mapt[Path,"Mapt-Packages"]<>"LevelScheme/install-LevelScheme-3.53.m","Text"]

=

Module[
  { progress , update } ,
  Print[ "Fetching LevelScheme... " ] ;
  progress = 0 ;
  update[ _ , "progress" , { now_ , total_ , __ } ] :=
      progress = now / total // Quiet ;
  URLSaveAsynchronous[
    "http://scidraw.nd.edu/levelscheme/versions/LevelScheme-3.53.zip" ,
    "ls.zip" ,
    update ,
    "Progress" -> True ] ;
  While[ progress < 1 , Pause[ .1 ] ] ;
  Print[ "Extracting..." ] ;
  ExtractArchive[ "ls.zip", Directory[ ] ] ;
  SetDirectory[ "LevelScheme" ] ;
  URLSave[
    Mapt[ Path , "Mapt-Packages" ] <> "LevelScheme/3.53/init.m" ,
    "init.m" ] ;
  Print[ "Initializing..." ] ;
  Mapt[ Initialization , "LevelScheme" , "3.53" ] ;
  Print[ "Done." ] ] ;

I would like to get a project going on GitHub, so if you are interested in working on it please chime in.

$\endgroup$
2
  • 1
    $\begingroup$ I'm totally in to help with this. I'll start (resume) lurking in the Mathematica stack exchange chat room when I can. $\endgroup$
    – sblom
    Jun 4, 2014 at 18:21
  • $\begingroup$ Interested too, though I still can't find spare time for a project I've promised to participate in already. :-\ Email me anytime to remind of this, the address is in my profile. $\endgroup$
    – akater
    Jun 5, 2014 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.