nim-lang / atlas

The Atlas Package cloner. It manages an isolated workspace that contains projects and dependencies.
MIT License
99 stars 14 forks source link

Custom extractors #3

Open Araq opened 1 year ago

Araq commented 1 year ago

The parser that process project.nimble is what I call an extractor. Custom extractors allow to extend this mechanism to cover other package managers, including ones for different programming languages. An extractor can be written in any programming language you like.

The entry in the configuration would look somewhat like:

"extractor": {"pattern": "requirements.txt", "language": "python", "parser": "<url to extension>", "resolver": "SemVer"}
elcritch commented 1 year ago

One piece I'm not sure about is where non-Nim dependencies should be added/defined.

Would it just be overloading the requires in the nimble file and adding it as another dep? That'd possibly bork Nimble compat. Is there another option I haven't thought of?

Araq commented 1 year ago

You would setup an extractor as a plugin and its tied to a filename. For example

"requirements.txt" -> Pip compatible parser "Cargo.toml" -> Cargo compatible parser

etc.

elcritch commented 1 year ago

Ok that makes sense for running the extractors. Would the extractors also be responsible for outputting a list of dependencies/repos then from a Nim project?

Alternatively would non-Nim projects be just another requires which when cloned has one of the available extractor files in the repo?

As an example let's say that you have a cmake dependency that needs to be built. Do we specify it in the nimble file, or do we create a CMakeList.txt file in the Nim project that can then be parsed? I sorta like the idea of saying in the Nimble file what the dependency is, however that'd break Nimble compatibility right?

Araq commented 1 year ago

Do we specify it in the nimble file, or do we create a CMakeList.txt file in the Nim project that can then be parsed?

Neither. You specify in the .nimble file the URL of the dependency and its version. In the dependency there is already the CMakeList.txt file and Atlas understands this is a build step. This works today but you need to enable the cmake plugin first. But currently you cannot declare in the .nimble file the requirement of this plugin.

Araq commented 1 year ago

And now I repeated the same mistake again. Talking about custom builders when the topic is custom extractors...

elcritch commented 1 year ago

No worries on my end, it's a bit overloaded and I'm unsure if it's more of a builders or extractors issue. It's really neither?

But currently you cannot declare in the .nimble file the requirement of this plugin.

Ah so in the Nimble file, but some other DSL construct like foreignDep "github.com/opencv/opencv"? I'd imagine Nimble could be able to be patched to ignore them or let people use them in custom nimble tasks.