Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

approach to default packages #23876

Merged
merged 2 commits into from
Sep 29, 2017
Merged

approach to default packages #23876

merged 2 commits into from
Sep 29, 2017

Conversation

JeffBezanson
Copy link
Member

Here's a strawman to get started on #18795. It's simple but basically does what I'd want. Here's what I did:

  • Make a new top-level directory called stdlib.
  • As a demo, move DataFmt (readdlm and writedlm) to stdlib/DelimitedFiles.
  • During build, link to stdlib from usr/share/julia/site/VERSION so it's available in LOAD_PATH. The files will be copied by make install as well.
  • (optional) Put using DelimitedFiles in the default juliarc, so the default repl experience is identical to before.

It should also be possible to put the using Whatever in sysimg.jl for faster startup. In that case I think there's still a clear code organization improvement; increased coupling can only take the form of adding a single using line to sysimg.jl or juliarc.jl.

Initially, the files can remain in this repo. Eventually, we might want to make some into external packages, and clone those repos into stdlib/ as a build step. By path/depot priority, it will be possible to install different versions of these packages and load them instead of the defaults.

If we move lots of Base submodules right away using this method, we can gain lots of flexibility, e.g. being able to update Distributed using the package manager during 1.x.

@ararslan ararslan added the packages Package management and loading label Sep 25, 2017
@JeffBezanson JeffBezanson force-pushed the jb/stdlib branch 2 times, most recently from 5cb8252 to 1e65047 Compare September 26, 2017 04:08
@JeffBezanson JeffBezanson added the excision Removal of code from Base or the repository label Sep 26, 2017
@vtjnash
Copy link
Member

vtjnash commented Sep 27, 2017

If we add these back to the bottom of sysimg.jl (for now, e.g. outside of Base), I think we can get on with merging this, and then work on making it lazy later in this development cycle. Otherwise, lgtm! Glad to see progress getting made on this.

@JeffBezanson
Copy link
Member Author

Done.

Copy link
Member

@quinnj quinnj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting! It'd be nice to maybe outline the process somewhere for moving something to /stdlib. Something along the lines of:

  • Create directories in /stdlib/Package/src and /stdlib/Package/test`
  • Remove code/references from Base, exports.jl, docs, etc. to /stdlib/Package/src
  • Move code from /test to /stdlib/Package/test
  • Add using Package to sysimg.jl

Though what's the general thought on doing sysimg.jl vs. .juliarc.jl?

:detect_ambiguities, :detect_unbound_args]
@eval Base.@deprecate_moved $f "Test" true true
end
end
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do Base.@deprecate_moved Test "Test" true true, or would that do something different?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deprecate_moved only seems to support the format @deprecate_moved function package.

@JeffBezanson
Copy link
Member Author

@quinnj Adding to sysimg.jl just improves startup time. Adding to juliarc.jl makes the names still available by default in the repl. For each package you can pick whether to do one or both of those.

I think I'm going to need help with the doc build for this. How can we set things up so docs live in package directories, but each one becomes a section of the manual?

@KristofferC
Copy link
Member

KristofferC commented Sep 27, 2017

I did the following hack to seems to make the docs generate like before:

  • Move the doc/src/stdlib/test.md file to e.g stdlib/Test/docs/src/index.md.
  • Change all the Base.Test in that file to just be Test.
  • Make a symlink from the current doc/src/stdlib/test.md to the moved stdlib/Test/docs/src/index.md.
  • Add using Test to doc/make.jl above the makedocs call.

Diff: https://gist.github.com/KristofferC/d0dd3009fd42d13bef91c919f186c3b7

Not pretty but perhaps it allows for moving forward on this and move out more packages, and a better workflow for the documentation could be worked out later.

This Documenter issue and PR are relevant: JuliaDocs/Documenter.jl#551, JuliaDocs/Documenter.jl#552

@KristofferC
Copy link
Member

Any thought of what should be done with packages that are somehow used in precompile.jl?

@yuyichao
Copy link
Contributor

Just have their own precompile?

@KristofferC
Copy link
Member

Yeah, of course :). I forgot that since they are included in the sysimg.jl the precompile.jl in the stdlib packages will work just like if it was inside the main precompile.jl.

@JeffBezanson
Copy link
Member Author

Thanks, @KristofferC ! I think this should be ready to go now.

end),
default_package ? :(function $eold(args...; kwargs...)
error($eold, " has been moved to the standard library package ", $new, ".\n",
"Restart Julia and then run `using ", $new, "` to load it.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need to restart Julia in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe, but it's fairly easy to end up with conflicting identifiers and such.

@JeffBezanson
Copy link
Member Author

JeffBezanson commented Sep 27, 2017

Is there any way to see the doc build log on AV?

EDIT: nvm, I suspect we can't do symlinks there.

@JeffBezanson JeffBezanson force-pushed the jb/stdlib branch 2 times, most recently from badbe0c to ab1878f Compare September 27, 2017 18:54
@@ -16,6 +16,15 @@ end

# Documenter Setup.

# make links for stdlib package docs
if Sys.iswindows()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this dirty the repo if one builds the docs? Locally, I just committed the symlinked file that is being created here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will that work everywhere? Do we have any symlinks in the repo currently? I didn't want to be the first :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen people do it for linking in the README.md into the documentation. Whether it will work everywhere... your guess is much better than mine.

@JeffBezanson
Copy link
Member Author

Ok, done. I'm just making symlinks (unix) or copies (windows) during the doc build, with an appropriate .gitignore file. Can be improved later. I believe this is now ready to merge.

@JeffBezanson JeffBezanson changed the title RFC: prototype approach to default packages approach to default packages Sep 28, 2017
as a demo, moves DataFmt out of Base. adds a line to default juliarc
so the functions are still available by default.
@StefanKarpinski
Copy link
Member

Do we want to call this stdlib? The set of functionality that ships with a language is often called the "standard library", which would make that name kind of confusing. If we call this directory stdlib then we should be ok with referring to package in it as part of Julia's standard library.

@JeffBezanson
Copy link
Member Author

Yes, I'm ok with considering everything in there the standard library. I like what wikipedia says in the very first paragraph of that entry though: "contents of a language's associated library may also be determined (in part or whole) by more informal practices of a language's community". So what happens to be in stdlib is not necessarily the end of the story.

Another good name might be stdpkg, for standard packages. Any other ideas?

@StefanKarpinski
Copy link
Member

The name stdpkg was also bouncing around in my head.

@JeffBezanson JeffBezanson merged commit ae8bbf6 into master Sep 29, 2017
@JeffBezanson JeffBezanson deleted the jb/stdlib branch September 29, 2017 19:16
@fredrikekre
Copy link
Member

julia> using Base.Test
WARNING: Base.Test is deprecated, use Base.Test instead.
  likely near no file:0

@rfourquet
Copy link
Member

Running make after modifying "stdlib/Test/src" doesn't re-build Julia, but using Test loads the old version... what is the way to rebuild a package in "stdlib"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
excision Removal of code from Base or the repository packages Package management and loading
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants