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

Support building from a local directory / non-Packagist source #79

Closed
TimWolla opened this issue Oct 28, 2024 · 12 comments · Fixed by #176
Closed

Support building from a local directory / non-Packagist source #79

TimWolla opened this issue Oct 28, 2024 · 12 comments · Fixed by #176
Assignees
Labels
enhancement New feature or request maintainer feedback needed Needs details or feedback to be added by maintainers
Milestone

Comments

@TimWolla
Copy link
Member

TimWolla commented Oct 28, 2024

This would be useful to test if what I've written into composer.json is correct and whether the build actually works, before committing to my changes by pushing them into a public repository and submitting them to Packagist.

This includes both the test after the initial pie-ification and before submission to Packagist and also tests after adding or removing configure flags.

see https://phpc.social/@timwolla/113367860412703002

@asgrim asgrim added the enhancement New feature or request label Oct 28, 2024
@asgrim
Copy link
Collaborator

asgrim commented Oct 28, 2024

Thanks - this should be possible once #48 is complete 👍

@asgrim asgrim self-assigned this Nov 7, 2024
@asgrim
Copy link
Collaborator

asgrim commented Nov 14, 2024

With the PR #83, this becomes possible, and the following steps will enable you to download/build/install source code for a PIE package that has not yet been published to Packagist:

  • Use PIE with work in progress branch asgrim:adapt-to-use-composer-installer (see PR Adapt to use composer installer #83)
  • If you have not run PIE for the target PHP before:
    • Run pie info -v foo/bar:dev-pie (doesn't actually matter what command really)
    • First run will not work, but will have created an empty pie.json
  • Locate pie.json for your target PHP, e.g. in ~/.config/pie/php8.3_<hash>/pie.json
  • Update pie.json manually to add the repository for what you're trying to do:

Example for a GitHub repo:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/foo/bar"
        }
    ]
}

Example for a local repo:

{
    "repositories": [
        {
            "type": "path",
            "url": "/path/to/foo/bar"
        }
    ]
}
  • Then you can use the package as normal, (using whatever version constraint is appropriate, e.g. foo/bar:* for local repo, foo/bar:dev-branch-name for a GH repo, e.g.:
    • bin/pie info foo/bar:dev-pie (useful for checking the ./configure options available in PIE)
    • bin/pie download -v foo/bar:dev-pie
    • bin/pie build -v foo/bar:dev-pie --enable-some-option
    • bin/pie install -v foo/bar:dev-pie --enable-some-option

Given the above possibility, maybe adding a new pie CLI option to combine (i.e. it would add the repository into pie.json for you), maybe something like:

  • --path-repository=/path/to/foo/bar
  • --vcs-repository=https://github.com/foo/bar

Usage examples:

  • bin/pie install --path-repository=/path/to/foo/bar foo/bar:*
  • bin/pie install --vcs-repository=https://github.com/foo/bar foo/bar:*

Since repository configuration can actually get quite advanced, I'm not sure we could get a fully comprehensive syntax in the CLI for defining all possible kinds of repositories, so maybe just providing the basics would suffice? I'm open to feedback on how we actually would do this though, perhaps there is a better way :D

@asgrim asgrim removed their assignment Nov 15, 2024
@macintoshplus
Copy link

Is it possible to add a custom repository like private composer into the pie.json file?

It's to allow a repository to help distribute extension code sources or pre-built DLL. Especially the oldest extensions.

@asgrim
Copy link
Collaborator

asgrim commented Nov 19, 2024

Is it possible to add a custom repository like private composer into the pie.json file?

It's to allow a repository to help distribute extension code sources or pre-built DLL. Especially the oldest extensions.

I have not tried a private repo, feel free to try it, the above guide may help :)

@macintoshplus

This comment was marked as off-topic.

@asgrim
Copy link
Collaborator

asgrim commented Nov 19, 2024

@macintoshplus I am not sure what your latest comment means, or how it relates to building from different Composer repositories, which is what the OP is asking about. The sources and dist keys don't exist in composer.json. It sounds like you are trying to solve a separate problem, so please can you open a separate ticket :)

@macintoshplus
Copy link

Right @asgrim, I have open #110.

@asgrim asgrim added the maintainer feedback needed Needs details or feedback to be added by maintainers label Nov 21, 2024
@asgrim asgrim self-assigned this Nov 21, 2024
@asgrim
Copy link
Collaborator

asgrim commented Jan 20, 2025

As an update to this, I'm working on a separate command to list/add/remove repositories from a target PHP in PIE. It'll be something like:

  • list pie repository:list --with-php-config=/path/to/php-config
  • add pie repository:add vcs https://github.com/asgrim/example-pie-extension --with-php-config=/path/to/php-config
  • remove pie repository:remove https://github.com/asgrim/example-pie-extension --with-php-config=/path/to/php-config
  • add pie repository:add path /path/to/your/local/extension --with-php-config=/path/to/php-config
  • remove pie repository:remove /path/to/your/local/extension --with-php-config=/path/to/php-config

Assuming there are no objections/issues/concerns/etc, this should make the next release :)

@macintoshplus
Copy link

As an update to this, I'm working on a separate command to list/add/remove repositories from a target PHP in PIE. It'll be something like:

  • list pie repository:list --with-php-config=/path/to/php-config
  • add pie repository:add vcs https://github.com/asgrim/example-pie-extension --with-php-config=/path/to/php-config
  • remove pie repository:remove https://github.com/asgrim/example-pie-extension --with-php-config=/path/to/php-config
  • add pie repository:add path /path/to/your/local/extension --with-php-config=/path/to/php-config
  • remove pie repository:remove /path/to/your/local/extension --with-php-config=/path/to/php-config

Assuming there are no objections/issues/concerns/etc, this should make the next release :)

Why the with-php-config option? The repository is not added into the composer.json project file?

@asgrim
Copy link
Collaborator

asgrim commented Jan 24, 2025

Why the with-php-config option? The repository is not added into the composer.json project file?

No, PIE does not use your consuming project's composer.json to install extensions (yet - although it has been discussed). It uses a pie.json specific to each target PHP version. This is because Composer installs dependencies for your project (in vendor/) as you are probably aware, but PHP extensions are global per PHP install, so we have a pie.json per PHP install that you have. If you have one PHP install on your machine, and php-config is in your $PATH, then you do not need to specify --with-php-config (this is the most common scenario). So when you use these commands, PIE is modifying $PIE_WORKING_DIRECTORY/php8.3_<somehash>/pie.json repositories (which is what PIE uses to manage extension dependencies, per "Target PHP" installation).

@macintoshplus
Copy link

Ok. I can't ask Pie to install all PHP Ext for my project based on composer configuration?

@asgrim
Copy link
Collaborator

asgrim commented Jan 24, 2025

Ok. I can't ask Pie to install all PHP Ext for my project based on composer configuration?

I did already directly answer that:

No, PIE does not use your consuming project's composer.json to install extensions (yet - although it has been discussed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maintainer feedback needed Needs details or feedback to be added by maintainers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants