46
$\begingroup$

I want to bundle up a Mathematica package that I've written and distribute it as open source. It has a couple of dependencies that I'd like to automatically download independently from my package as well.

Is there any sort of established Mathematica package manager and package distribution site? (I'm thinking along the lines of pip for Python, gem for Ruby, nuget for .NET, hackage for Haskell, that sort of thing.)

I've seen Wolfram MathSource, and as near as I can tell its aim seems to be to collect various contributed packages from around the web into a central place, but it doesn't feel very active (maybe I'm wrong?).

$\endgroup$

7 Answers 7

27
$\begingroup$

I'm not aware of any existing package manager. As to activity of Wolfram MathSource, let's ask Mathematica:

libraryLinks = 
  Select[
     Import[
         "http://library.wolfram.com/infocenter/search/?page=1;search_results=1;search_item_type=19&pages_count=100000", 
         "Hyperlinks"
     ], 
     StringMatchQ[#, RegularExpression[".*library.*"]] &
  ];

dates = 
   Function[{ll},
      Cases[Import[ll,"Data"], 
            _String?(StringMatchQ[#,DatePattern[{"Year", "Month", "Day"}]] &),
            Infinity]
      ] /@  libraryLinks // Flatten;

Histogram[(DateList /@ dates)[[All, 1]], {1}]

Mathematica graphics

Indeed, it doesn't seem to be too busy lately.

$\endgroup$
7
  • 1
    $\begingroup$ Nice method/chart. I wonder why the collapse. $\endgroup$
    – Mr.Wizard
    Jul 10, 2012 at 14:56
  • 1
    $\begingroup$ @Mr.Wizard might have something to do with the launch of Wolfram Demonstrations. I believe that happened somewhere in 2006. There are now over 8000 demonstrations and only about 1800 MathSource entries. $\endgroup$ Jul 10, 2012 at 15:18
  • $\begingroup$ Perhaps, but there used to be a lot of (re)usable packages posted to MathSource. Demonstrations are neat, but hardly a substitute. $\endgroup$
    – Mr.Wizard
    Jul 10, 2012 at 15:29
  • $\begingroup$ mr.wizard Agreed, but I imagine many of the package authors have moved over. $\endgroup$ Jul 10, 2012 at 15:40
  • 1
    $\begingroup$ Absolutely, it would be very good if such a central service would exist. If something is started now, I think it probably would need to be at least as good as existing services/repositories AND be readily availabe from Mathematica, like an app-store with search + public review + one click installation. WRI offered repositories based on svn a few years ago but I don't even know if that service still exists, it certainly wasn't attractive enough. An feature that would certainly attract me as a developer would be a distributed version control well suited for notebooks (=not line based) :-) $\endgroup$ May 28, 2013 at 12:27
13
$\begingroup$

This is not really a response, but a comment. I think that the collapse of MathSource could be because of GitHub. Almost half of the packages at PackageData.net are hosted there:

Needs["GeneralUtilities`"]

data = Import["http://packagedata.net/index.php/api/packages", "JSON"];
domains = URLParse[#url, "Domain"] & /@ ToAssociations[data];
PieChart[
 Sort@Counts@domains,
 ChartLabels -> Placed[Automatic, "RadialCallout"],
 SectorOrigin -> 110 Degree,
 ImagePadding -> {{100, 0}, {0, 0}}
 ]

enter image description here

$\endgroup$
1
  • 2
    $\begingroup$ I really like the chart!:) $\endgroup$
    – Sascha
    Dec 3, 2015 at 20:50
11
$\begingroup$

Here's something that ought to handle many cases: https://paclets.github.io/PacletServer/

[enter image description here](https://paclets.github.io/PacletServer/)

It can handle one-line installation, gives a log of who changed what, and you can submit your own packages via GitHub so it's nicely integrated there.

This is in some sense still in beta, but without users there's not much space to see where exactly the dark corners are and what should be patched up.


Here's some info on how to add paclets copped from here:

To show how to do that I'll add my Ems package that I showcased in my post Making a Blog in 30 Minutes. The first step is to install the interface paclet off the paclet server. To do this we'll go to its page and copy the installation instructions given there:

PacletInstall[
  "PublicPacletServer",
  "Site"->
    "http://raw.githubusercontent.com/paclets/PacletServer/master"
  ]

(*Out:*)

post21-6722923238009970110
(source: wolframcloud.com)

Now, we load this package

<<PublicPacletServer`

Then since Ems is already on my personal server I can just point the registration there:

PublicPacletServer["RegisterPaclet",
  <|
    "Name"->"Ems",
    "Author"->"b3m2a1 <[email protected]>",
    "URL"->"http://www.wolframcloud.com/objects/b3m2a1.paclets/PacletServer",
    "Update"->"DownloadOnce"
    |>
  ]

(*Out:*)

post21-2385149726991367475

If I wanted it to download from GitHub, since I already have it on my GitHub instead I could also have just done:

PublicPacletServer["RegisterPaclet", "Ems"]

Which would have done the same.

Now we can look at the request that was made :

post21-4494400686262893646
(source: wolframcloud.com)

And that's basically all that needs to be done. At that point the ball is firmly in my court and I handle the small changes and the rest of the build process.

If you want to build the server yourself to add some features, feel free and just submit the changes as a GitHub pull request.

$\endgroup$
9
$\begingroup$

Is there any sort of established Mathematica package manager and package distribution site?

PackageData.net is a free, open-source package distribution site. It is collaborative so that anyone can add packages and improve on existing entries. It could potentially have package management features in the future if it grows in popularity.

$\endgroup$
5
$\begingroup$

At the Wolfram Technology Conference 2015 there was mention (at the keynote, if I recall correctly) of a Wolfram App Store that is in development. This would allow people to sell or freely distribute packages, mobile apps, and CDFs developed with the Wolfram Language. It was not stated how far out this service was.

$\endgroup$
4
$\begingroup$

Why don't we make one? Here's a start -- feel free to try it at home :)

ClearAll[mfvonh, HelloWorld];
Import["http://mfvonh.me/mma/install", "Text"] // ToExpression;
mfvonh[Install, {"Testing", "HelloWorld"}];
HelloWorld[]

Hello, world! -mfvonh

You can distribute any kind of content (definitions, data, docs, etc.) this way. Here's how it works:

I run a webserver at mfvonh.me, and /mma is just a directory containing whatever I need to transfer (text files with definitions, data, etc.). The "install" file looks like this:

Import["http://mfvonh.me/mma/install", "Text"]

=

ClearAll[mfvonh];
mfvonh[dir_, args___] :=
 Module[{
   BaseURI = "http://mfvonh.me/mma",
   ValidDirQ := MatchQ[dir, _Symbol],   
   ValidArgsQ = MatchQ[{args}, {} | {{__String} .., ___Rule}],
   FromMFVONH = Import[#, "Text"] &,
   Exec = ToExpression[#] &},
  Switch[dir,
    Install, 
    Exec /@ FromMFVONH /@ (StringJoin[Riffle[{BaseURI, ##}, "/"]] & @@@
         Cases[{args}, _List])
    ] /; ValidDirQ && ValidArgsQ
  ]

So in the example {"Testing", "HellWorld"} is resolved to the corresponding path on the server, which is also just a file:

Import["http://mfvonh.me/mma/Testing/HelloWorld", "Text"]

=

SetDelayed[HelloWorld[],Print["Hello, world! -mfvonh"]]

The simple way to define dependencies would be to include a reference to them in the install script, and a generic check to see if a package has already been loaded. It would be pretty easy to build out all the features of a decent package manager. Obviously executing code off the internet introduces some security considerations.

I would be willing to take this on as a project if people would use it.

$\endgroup$
3
  • 1
    $\begingroup$ Talk to Leonid in chat, he's been working on one. $\endgroup$
    – Szabolcs
    May 28, 2014 at 23:51
  • 2
    $\begingroup$ I also have a start at github.com/mathematica-packages/mpg, and have been sort of waiting to see whether there was even enough interest in the idea to justify more effort. Starting to look like there might be enough interest for this to work. You use mine by saying Import["https://j.mp/needs-mpg"], or if Mpg is already installed, by saying Needs[Mpg``]. It doesn't really do much yet, but I'm really proud of the bootstrap story. $\endgroup$
    – sblom
    May 28, 2014 at 23:52
  • $\begingroup$ @sblom If you have a chance would you please share here? Yours has some functionality that my prototype does not. $\endgroup$
    – mfvonh
    Jun 4, 2014 at 16:12
1
$\begingroup$

I ended up using just Github and custom package manager that keeps the stuff in the projects folder like npm

LPM

It helps me a lot to collaborate and keep new version of all my paclets/packages without publishing them on wolfram.

$\endgroup$

Your Answer

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

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