-
Notifications
You must be signed in to change notification settings - Fork 131
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
How to consume a package with source files not in src
?
#288
Comments
@joneshf I think it depends on the definition of monorepo that we have: in my experience I have only encountered monorepos as "final consumers" of other packages.
It sounds like you're looking for (2), which at first sight makes sense to me. Thinking more about it though, it looks like the rest of the ecosystem is not compatible with this setup, e.g.:
I would be wary of supporting another way of fetching packages without coordination with other tooling (because introducing splits, etc etc), so I guess the most usable way to do this would be to use submodules, at the price of not being able to share the top-level |
Yep, that's exactly what I'm thinking. I appreciate your position and I have a few thoughts:
I appreciate that you're thinking about these things, and want to make sure things work out okay. But, I'd like to live in the I'd like to be able to build out a monorepo using On the subject of consuming monorepos, it is a thing that happens in many other ecosystems: babel, go, nixpkgs, rails, symfony, wai. Some of these ship end products (like gofmt), but they all allow you to consume the components of the monorepo. How that happens depends on the ecosystem. Most of them work by distributing an artifact that's separate from the file structure of the source code. E.g. wai's monorepo works because you can distribute a tarball that encapsulates only the important parts of warp. In the PS ecosystem, we've so far coupled what a distributed package looks like with what the source code of that package looks like. It's a sensible model, and it's gotten us far, but it's an arbitrary coupling. If |
@joneshf thanks for the kind words! 😊
In principle this would not be too hard (the "arbitrary coupling" is there for ease of implementation), some observations:
Oh, TIL. If someone puts together such a resolver then I'd be fine investigating this further
It's more like a general feeling about our package distribution being extremely tied to |
Sorry, I'm not too familiar with the interplay/architecture. Why is that?
I'm totally fine with that. None of my packages are in the package set anymore anyway. I'm fine living in a
I'm not too interested in being part of that discussion. A package registry is basically something you throw money at: pay for servers/storage, pay someone to build an API around it with authentication/authorization (or do it yourself), and step away. I recognize that it's not that cut and dry, but it's also not orders of magnitude more complex. I've tried many times in the past to dump money into an official PS account/foundation/whatever in hopes that we could solve problems like this. Each time the response was that money wasn't going to be accepted in any official regard. I think we're wasting useful energy trying to figure out another way around it and I don't think it's fruitful for me to say much more. If someone comes up with a solution, I'll try to support it. But, I don't want to spend a bunch of time on it.
Would you feel differently if the official way to work with PS was moved from
Can we add a |
Quoting from here, this is the handwavy Dhall type of the spago configuration: -- The basic building block is a Package:
let Package =
{ dependencies : List Text -- the list of dependencies of the Package
, repo = Text -- the address of the git repo the Package is at
, version = Text -- git tag
}
-- The type of `packages.dhall` is a Record from a PackageName to a Package
-- We're kind of stretching Dhall syntax here when defining this, but let's
-- say that its type is something like this:
let PackageSet =
{ console : Package
, effect : Package
... -- and so on, for all the packages in the package-set
}
-- The type of the `spago.dhall` configuration is then the following:
let Config =
{ name : Text -- the name of our project
, dependencies : List Text -- the list of dependencies of our app
, sources : List Text -- the list of globs for the paths to always include in the build
, packages : PackageSet -- this is the type we just defined above
} Right now Now, as you can see above the
At some point in the thread I propose to use the
We'd stop creating new bower users, but we'd still need to worry about the
I think we'd still need some kind of manifest in the root of the repo or in some other default location right? (so that spago would be able to locate a file to read the |
Oh. Because
Sorry, I'm not sure I understand what we're talking about. Lemme explain what I'm suggesting more explicitly and you can tell me where I'm going wrong 🙂. Let's say I want to move https://github.com/joneshf/purescript-httpure-middleware into https://github.com/joneshf/open-source. There's really only one file in that package. I'd like it to sit at:
Now, let's say someone else wants to consume let additions =
{ httpure-middleware =
{ dependencies =
[ "purescript-httpure" ]
, repo =
"https://github.com/joneshf/open-source.git"
, sources =
[ "packages/purescript-httpure-middleware/src/**/*.purs" ]
, version =
"d03884217eed3f2d41205ac0a56573b2a1443107"
}
}
... Instead of
λ(package : Package) → { sources = [ "src/**/*.purs" ] } ⫽ package while also not requiring (but still allowing) a change in the upstream. I think having written it out, what I'm really asking for is some way to override https://github.com/spacchetti/spago/blob/40551e3765ffd07637e7afabd2a169238626ace0/src/Spago/Packages.hs#L87 This isn't even specific to monorepos anymore. We've always assumed people would put PS source code at the top-level in a Does this re-phrasing change any of the stuff we've discussed so far? In other words, if we only think about improving robustness of packaging–and don't think about the fact that it extends |
Not really, but kind of: because it uses types from
Oh right sorry, now it makes sense, thanks for detailing 💯 This would be a neat solution, but I think it'd still require changing the type of the upstream and the migration you proposed to happen there (again, this is not a huge deal, will just require more care) because there's no nicer place to perform that migration:
However I'm still unsure about this, as I have the feeling that it would incentivize a "split" in the ecosystem by changing the relationship "one repo == one package" - even if we can make Bower compatible, |
@joneshf a temporary, low-effort solution for now would be to move your packages to the monorepo, but keep the repo there for publishing them. Then you can add a script to the repo that just pulls the monorepo, focuses on the package you need, and copies that to the root of the repo |
Well that's unfortunate, but understandable. I'm not upset about it or anything, but I need to find a solution to my hundreds of repos. I'm mostly lazy, don't want to write a bunch of git-based stuff, but still want people to be able to consume the packages I make. I want to live in a |
Wait, what does this mean? Does this mean the decision for If so, the change to |
The more I think about it, the more I realize that I came in here and asked the wrong question. This was never about monorepos, but always about supporting dependencies where the source files weren't in |
src
?
Yes, because I want the ecosystem to reasonably move in sync and avoid breakages/splits/etc (the Just to make it clear I'd agree with this change, but I'd like agreement from the wider community too so we can sync up if we need to make changes (because it's about changing one of the basic assumptions of packaging in PureScript) Ping @justinwoo @hdgarrood |
Can you give some examples (outside of the feature being requested in this issue)? I very much disagree with this, actually; I think the more things you have which are configurable, the more things other tools need to worry about when they are consuming packages, so we should only allow configurability if we are certain that it is absolutely necessary. In this case, I think requiring source files to be in My preferred way forward here would be to stop having packages necessarily tied to git repositories, so that you could have one repo containing a bunch of packages which you can publish individually. That probably entails using a real package registry and distributing packages as tarballs or something. |
Thinking a bit more about the underlying problem, there's a parallel decision we made and changed: assuming a package will be in a It's another arbitrary decision we made in the past that was also neither free nor intuitive. It made things easier at the time because we had a handful of packages, and we were prefixing all of them with That change hasn't stopped anything in the ecosystem from growing, nor has it created a bifurcation. In fact, the vast majority of repos still start with I understand and respect wanting to be sure that this change doesn't adversely affect the community. I think @f-f Given that we have an example of changing a similar convention of the past into an explicit configuration in effect for years without any negative consequences on the ecosystem, does that change your thoughts on consuming packages with files not in
I won't give any more examples because the way this request has played out in the past is that I attempt to justify my thoughts, and they're dismissed. I know you can be convinced of other ideas, but I don't want to spend the time convincing you of this one. I'm fine with us having different opinions.
I'm fine with that as well. Having fleshed out what the actual problem is though, allowing to specify where source files exist sounds way easier than breaking the git convention. |
Having different opinions is of course fine, but I think that adding a feature which would enable the possibility of packages which can only be consumed by spago should ideally come with proper justification.
Moving away from git will indeed be a lot of effort, but a proper package registry is very desirable for various reasons, which are discussed in https://discourse.purescript.org/t/blogged-thoughts-on-purescript-package-management/809. I think we need to do it at some point anyway. |
Just to clarify, I did make sure format-nix can be installed and used via bower. It's registered on bower as purescript-format-nix, and installs into that directory structure and can be built with pulp accordingly:
https://github.com/justinwoo/test-bower-install-format-nix |
Can we not use the same justification as what was used for |
I don't find this example particularly compelling, because for a package like that, all you would need to do is to put the |
I'm sorry you're not compelled by it, but it's showing that the ecosystem can be trusted to not break everything. You just outlined how the ecosystem can still keep it together even though The community can make similar glue if their source files are allowed to be in a different place. One example is to publish from a new repo, as @f-f outlined above. Another example is to tag a commit where the files are moved to where Ultimately, the decision comes down to @f-f. I've made my case, discussed how the ecosystem has stayed in sync even with the ability to bifurcate. You've weighed in with your thoughts about |
@f-f Given that |
@joneshf yes. Since we'll have control over the new registry we can (and I think we should) make this configurable, since we'll be packaging sources in a tarball anyways. We can leave this issue open or close it and move the discussion over to that repo, since the implementation details will have to be ironed out there first |
Sweet! Excited to see what comes of the registry. Maybe keep this issue open until there's a concrete way forward, if that's alright? |
@joneshf there is now an issue tracking this discussion in the registry repo: purescript/registry#16 I would say we should close this issue, as that one addresses the upstream concern and this one will come for free once that's in place - i.e. since the Registry and Spago will use the same schema, once we can publish packages with sources in a different place, then Spago will be able to use them. Makes sense? |
I'm okay with that. |
The current title "How to consume a package with source files not in src" was confusing to me, the original "How to consume a monorepo" makes more sense (to my view). First, because I think that the location of sources inside the package is definitely better to be restricted to make things more standard at the top, and the packages, in general, should be a simple thing as it possible for them to be (which now they are certainly not in many cases). The second thing, definitely a package should be decoupled from a git repo, but currently, as the ecosystem in most cases relies upon git repo version tags, it would be more difficult to keep things in sync with a monorepo, even if not to consider the "bower compatibility". At the same time, I think that eventually having the ability to pull packages content from git repo subdirectories could be still valuable even along with the existing registry (as not everything that could be consumed should be published in the registry). So currently If I had a number of separate packages that I would choose to reside in monorepos, I would make a Github Org and published (pushed there) package's code with appropriate version tags (as @f-f already proposed here). This would be definitely a non-standard (and even kinda hacky) solution and would require some additional setup, but it could be quite ok (esp. for someone who would like to publish hundreds of one's packages @joneshf ;-)) |
In the readme, it mentions that
spago
is about supporting monorepos. It seems to support producing a monorepo fairly well. However, it's not readily clear how to consume a monorepo. It seems like everything is hardcoded to expect files to exist in thesrc
directory at the root of a git repo. Is there any plan to support files existing at a different directory? Say someone had a repo with the structure laid out in the README:Is there any way to consume
lib/src/Main.purs
from outside of the repository? If the files are local to the machine, it seems like it can work. If the files are remote to the machine (like hosted on GitHub), it doesn't seem like we can currently consume it.Any thoughts?
The text was updated successfully, but these errors were encountered: