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

[SR-4554] The command "swift package describe" should not fetch dependencies #5038

Closed
swift-ci opened this issue Apr 10, 2017 · 8 comments
Closed
Labels

Comments

@swift-ci
Copy link
Contributor

Previous ID SR-4554
Radar None
Original Reporter tonisuter (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Apple Swift version 3.1 (swiftlang-802.0.51 clang-802.0.41)
Target: x86_64-apple-macosx10.9

Additional Detail from JIRA
Votes 0
Component/s Package Manager
Labels Bug, StarterBug
Assignee None
Priority Medium

md5: a5f2a9e569e5e7f476f1d2d659a6fd15

Issue Description:

The Swift Package Manager command swift package describe lists all modules of the current package. However, if a package's dependencies haven't been downloaded yet, the command swift package describe will fetch them first. This should not be necessary, because the information to describe the current package can be obtained from the file structure.

@heckj
Copy link
Contributor

heckj commented Apr 13, 2017

the command shows the entire depth history of the packages and dependencies - are you asserting it should only show "the first layer" (The details that are otherwise just in the manifest or pins file) if the dependencies havent been fully resolved?

@swift-ci
Copy link
Contributor Author

Comment by Toni Suter (JIRA)

Maybe I am missing something. But when I create a project with the following Package.swift file:

// swift-tools-version:3.1

import PackageDescription

let package = Package(
  name: "MyProject",
  dependencies: [
    .Package(url: "https://github.com/IBM-Swift/Kitura.git", majorVersion: 1, minor: 6)
  ]
)

And when I now run the command swift package describe, the Swift Package Manager first fetches the dependencies and then prints the following output:

Name: MyProject
Path: /Users/tonisuter/Desktop/MyProject
Modules: 
    Name: MyProject
    C99name: MyProject
    Test module: false
    Type: executable
    Module type: SwiftModule
    Path: /Users/tonisuter/Desktop/MyProject/Sources
    Sources: main.swift

This output contains nothing about the dependencies, right?

@heckj
Copy link
Contributor

heckj commented Apr 13, 2017

Hey tonisuter (JIRA User), sorry - my mistake. I was thinking of swift package show-dependencies, which outputs:

.
└── Kitura<https://github.com/IBM-Swift/Kitura.git@1.6.3>
    ├── Kitura-net<https://github.com/IBM-Swift/Kitura-net.git@1.6.2>
    │   ├── LoggerAPI<https://github.com/IBM-Swift/LoggerAPI.git@1.6.0>
    │   ├── Socket<https://github.com/IBM-Swift/BlueSocket.git@0.12.45>
    │   ├── CCurl<https://github.com/IBM-Swift/CCurl.git@0.2.3>
    │   └── SSLService<https://github.com/IBM-Swift/BlueSSLService.git@0.12.32>
    │       └── Socket<https://github.com/IBM-Swift/BlueSocket.git@0.12.45>
    ├── SwiftyJSON<https://github.com/IBM-Swift/SwiftyJSON.git@15.0.6>
    └── Kitura-TemplateEngine<https://github.com/IBM-Swift/Kitura-TemplateEngine.git@1.6.0>

I was confusing the two commands in my head when I was scanning open bugs yesterday.

For what it's worth, swift package show-dependencies, swift package describe, and swift package dump-package all utilize the same code pathes, loading up the package manifest with let graph = try loadPackageGraph() which loads the manifests, parses it, loads any pins defined, and does a full dependency resolution pass over the whole kit before returning back - the resulting datastructure handed back is what's passed back to describe to provide the output - or to the variant description mechanisms like show-dependencies.

Is the process causing you problems, or are you reporting this because it's doing potentially needless work for that specific outcome?

@ankitspd
Copy link
Member

We need a separate method to load just the root packages so we avoid unnecessary work.

@swift-ci
Copy link
Contributor Author

Comment by Toni Suter (JIRA)

No problem :-) I am currently working on an Eclipse-based Swift IDE (https://www.tifig.net/) which uses the Swift Package Manager as its build system. In order to be able to correctly index a project, the IDE needs to know about all the packages and all the modules in the project. So I thought I could use the Swift Package Manager to obtain that information. Basically, I wanted to first call swift package show-dependencies --format json which would give me the path of each package as well as the dependency graph. Then I would execute the command swift package describe --type json for the main package as well as for all packages that have been downloaded as dependencies. This would then output the name, path and type of each module for each package.

Going back to my previous example, the process would look like this:

  1. Execute swift package show-dependencies --format json
    => Downloads all the dependencies, which is good
  2. Execute swift package describe --type json for the main package
    => Doesn't download anything, because its dependencies have already been fetched in step 1
  3. For each dependency (e.g., Kitura, Kitura-net, etc):
  • Execute cd <path-of-dependency>

  • Execute swift package describe --type json
    => Downloads the dependency's own dependencies. However, those have already been fetched in step 1, which makes this whole process very slow, because indirect dependencies are downloaded at least 2 times.

I hope my explanation makes sense :-)

@ankitspd
Copy link
Member

tonisuter (JIRA User) In that case, it is better to use libSwiftPM. It is basically package manager as a framework, so it can be integrated into various IDEs.
The APIs are not stable as of now but you won't need to work around limitation of the CLI tools. You also get things like build plan to generate compiler arguments and dependencies.

If you want to have a quick chat sometime, you can join our slack: http://swift-package-manager.herokuapp.com

@swift-ci
Copy link
Contributor Author

Comment by Toni Suter (JIRA)

Thanks @aciidb0mb3r![]( That looks interesting. I will certainly have a look at that)

@ankitspd
Copy link
Member

ankitspd commented May 8, 2017

This is done with the new "package resolve" command

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants