Skip to content

Project.jl as an extension to Projec.tomlΒ #1828

@aminya

Description

@aminya

It would be nice if we can have a Project.jl as an extension to Project.toml in our root directory to perform custom things that are not covered in Project.toml.

Pkg.instantiate() should run this file after it processes Project.toml.

Some use cases:

Interactive experience

function prompt(message::String="")::String
   print(message)
   return chomp(readline())
end

use_newfeature  = prompt("Do you want to use the new feature of this package? (Y, N)")
# do some stuff with use_newfeature  

backend_lib = prompt("Which XML library do you want to use as the backend?")
# do some stuff with backend_lib 

Dependency based on the VERSION or OS

using Pkg
@static if VERSION > v"1.3"
	Pkg.add("AcuteML")
else
	Pkg.add(PackageSpec(url="https://github.com/aminya/AcuteML.jl", version=v"0.5"))
end

Unregistered packages

I might want to add a dependency that is not registered yet. I can simply do it in the Project.jl file.

using Pkg
Pkg.add(PackageSpec(url="https://github.com/aminya/AcuteML.jl", rev="master"))

Adding compat methods based on the VERSION or OS

@static if VERSION < v"1.3"
	Base.write("src/compat.jl","""
    	static_hasmethod(args...) = hasmethod(args...)
	""")
	# inside the package, one can use `@static isfile("compat.jl")`
else
	Pkg.add("Tricks") # some package with compat `julia = 1.3`
end

Custom script after installation

include("src/build.jl")
include("src/postinstallation.jl")

Run the tests after installation

using Pkg
Pkg.test()

and many other examples.

This is similar to deps/build.jl, but being in the root, separates the Pkg and init stuff from building.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions