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

Implemented AMBER_PATH for import lookup #681

Open
wants to merge 2 commits into
base: staging
Choose a base branch
from

Conversation

Thesola10
Copy link

@Thesola10 Thesola10 commented Feb 27, 2025

This fixes #668 and opens up possibilities for simpler package managers, as they could export a set of standard paths.

Now, if AMBER_PATH is set to /usr/lib/amber:$HOME/.local/lib/amber for instance, in addition to the current directory, import directives will look in those directories as well.

This is a draft/proof-of-concept and there's a couple things to do:

  •  Exclude paths that start with . or .. from environment lookup
  • Define a default set of AMBER_PATH paths
  • Ideally move the stdlib out into one of these paths (how do other cargo projects distribute installable resources???)

@Mte90 Mte90 requested review from hdwalters, Ph0enixKM and b1ek and removed request for hdwalters February 27, 2025 14:23
@hdwalters hdwalters changed the base branch from main to staging March 2, 2025 14:31
@Thesola10 Thesola10 requested a review from hdwalters March 5, 2025 15:52
@Thesola10 Thesola10 marked this pull request as ready for review March 6, 2025 19:09
@Thesola10 Thesola10 marked this pull request as draft March 6, 2025 19:09
@b1ek
Copy link
Member

b1ek commented Mar 10, 2025

i dont know if this is the right way forward. wouldn't it cause a lot of confusion and inconsistency between different package managers? since there is no rigidly defined place where should they place their packages

@Thesola10
Copy link
Author

Thesola10 commented Mar 10, 2025

i dont know if this is the right way forward. wouldn't it cause a lot of confusion and inconsistency between different package managers? since there is no rigidly defined place where should they place their packages

That is how every compiler does it under the hood. There are default values (which I intend to add for Amber as well as soon as I can make sure we can ship stdlib in one of them) but leaving this path system open allows for integrating with other buildsystems like Meson, Autoconf or Nix, where dependencies may not be in standard paths for technical reasons.

In the future adding a default package manager to Amber isn't incompatible with this option, just wish to keep modularity in mind -- amber would be a git-like modular CLI which could call amberc, a pure and simple compiler.

Another reason to allow flexible paths is virtual environments. The only way to prevent dependency collision is to let users specify where dependencies are on a per-project basis.

Just as Python developers rarely think about PYTHONPATH, ideally you won't need to know about AMBER_PATH. Your build tool just sets it for you.

@Thesola10 Thesola10 marked this pull request as ready for review March 10, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] Package loader for amber
3 participants