跳到主要内容
知仓学习社ZHICANG

generating-julia-package

Use when you create a JuliaLang package

不碰外部(只输出文字)无严重或高危命中hashgraph-online/awesome-codex-plugins

它会碰到什么

扫了多少1 个文本文件,3 KB
它会碰到什么不碰外部(只输出文字)
命中总数0 处
命中统计严重 0 · 高 0 · 中 0 · 低 0

这一栏是扫描器报的事实,不是结论。命中多不等于有毒(安全工具、规则库、示例脚本本来就会包含危险写法),命中少也不等于干净。它和你手上的凭据、文件、网络有什么关系,需要你自己看。

技能内容

Creating a Julia Package

Project Environment

If you want to create a simple script that depends on external libraries, you should create a "project environment". This means making a Project.toml file like the one below.

[deps]
"<Installed Package 1>" = "<UUID for Installed Package 1>"
"<Installed Package 2>" = "<UUID for Installed Package 2>"
"<Installed Package 3>" = "<UUID for Installed Package 3>"

To install an external library (for example, TargetPackage), run the following in your terminal:

julia --project -e 'using Pkg; Pkg.add("TargetPackage")'

Package Directory

If you want to create a reusable package or a larger scale script, you should create a "package directory".

Choosing the layout

Default: in-place layout. Create ./Project.toml and ./src/MyPkg.jl directly in the current working directory, with no subdirectory named after the package. Use this whenever the user asks to "create a package MyPkg" without further qualification.

Opt-in: subdirectory layout. Only use this when the user explicitly asks for a subdirectory — for example "create the package under a new directory", "サブディレクトリを作って", "MyPkg/ 配下に作って", or when the user is bootstrapping multiple packages side by side under a single workspace and a subdirectory is necessary to disambiguate them.

Do NOT use Pkg.generate("MyPkg") for the in-place layout — it always creates a subdirectory. The in-place layout is the default and must be produced by hand-writing the files (see the steps below).

In-place layout (default, no subdirectory)

To create Project.toml and src/MyPkg.jl directly in the current working directory:

  1. Generate a UUID for the uuid field of Project.toml:
   $ julia -E 'using UUIDs; string(uuid4())'
   "43d6671a-6eab-408d-9ef9-8f584d9146fb" # Example output.
  1. Write ./Project.toml with the package name and the UUID from step 1:
   name = "MyPkg"
   uuid = "43d6671a-6eab-408d-9ef9-8f584d9146fb"
   authors = ["Your Name <you@example.com>"]
   version = "0.1.0"
  1. Write ./src/MyPkg.jl with the module skeleton:
   module MyPkg

   greet() = "Hello"

   end # module MyPkg
  1. Verify by loading the package from the current directory:
   $ julia --project=. -e 'using MyPkg; println(MyPkg.greet())'

Subdirectory layout (opt-in only)

Only use this when the user explicitly asks for it. To create a package named MyPkg under a new subdirectory, run:

$ julia -e 'using Pkg; Pkg.generate("MyPkg")'

This will create:

$ tree
.
└── MyPkg
    ├── Project.toml
    └── src
        └── MyPkg.jl

3 directories, 2 files

想直接用这个技能?

本站把开放许可(MIT / Apache 等)的技能按仓库打包整理到网盘,点一下转存到你自己的网盘,不用一个个从 GitHub 拉。许可未声明的技能只给原始仓库链接,不打包。

它属于哪个仓库

星标★ 1,027
本站分层T1
该仓技能数1910
原文件路径plugins/AtelierArith/atelier-arith-julia-development-skills/skills/generating-julia-package/SKILL.md

同一个仓库里的其他技能

看这个仓库的全部 1910 个技能