toolsetup:buildingapackagelocally
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| toolsetup:buildingapackagelocally [2022/02/15 21:45] – f2b216 | toolsetup:buildingapackagelocally [2025/10/08 00:48] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Building a package locally from source using " | ====== Building a package locally from source using " | ||
| - | * in the project folder type: | + | ===== Use case ===== |
| + | |||
| + | One wants to use the original sources of a package (of the Stackage/ | ||
| + | |||
| + | ===== Procedures ===== | ||
| + | |||
| + | We can choose out of the following two opportunities: | ||
| + | * | ||
| + | * with use of tarball files | ||
| + | ==== Procedure without tarball files ==== | ||
| + | |||
| + | * unpack the package that should be obtained as source code | ||
| * command:< | * command:< | ||
| + | stack unpack random | ||
| + | </ | ||
| + | * or command with dedicated version number:< | ||
| + | stack unpack random-1.2.1 | ||
| + | </ | ||
| + | * output:< | ||
| + | Unpacked random (from Hackage) to C: | ||
| + | </ | ||
| + | |||
| + | * change the current directory | ||
| + | * command:< | ||
| + | cd random-1.2.1 | ||
| + | </ | ||
| + | |||
| + | * initialise the folder of the package (here `random-1.2.1`), | ||
| + | * command:< | ||
| + | stack init | ||
| + | </ | ||
| + | * output:< | ||
| + | Looking for .cabal or package.yaml files to use to init the project. | ||
| + | Using cabal packages: | ||
| + | - .\ | ||
| + | |||
| + | Selecting the best among 20 snapshots... | ||
| + | |||
| + | * Matches https:// | ||
| + | |||
| + | Selected resolver: https:// | ||
| + | Initialising configuration using resolver: https:// | ||
| + | Total number of user packages considered: 1 | ||
| + | Writing configuration to file: stack.yaml | ||
| + | All done. | ||
| + | </ | ||
| + | |||
| + | * change the current directory back to the main one | ||
| + | * command:< | ||
| + | cd .. | ||
| + | </ | ||
| + | |||
| + | * to `stack.yaml` of main project, add package with relative path (here `./ | ||
| + | |||
| + | * extract< | ||
| + | # - auto-update | ||
| + | # - wai | ||
| + | packages: | ||
| + | - . | ||
| + | - ./ | ||
| + | |||
| + | # Dependency packages to be pulled from upstream that are not in the resolver. | ||
| + | # These entries can reference officially published versions as well as | ||
| + | </ | ||
| + | |||
| + | * to `package.yaml` of main project add dependency to package (here `random`) with constraint (here ` == 1.2.1`) to section `dependencies` | ||
| + | * extract< | ||
| + | . | ||
| + | . | ||
| + | . | ||
| + | # common to point users to the README.md file. | ||
| + | description: | ||
| + | |||
| + | dependencies: | ||
| + | - base >= 4.7 && < 5 | ||
| + | - random == 1.2.1 | ||
| + | |||
| + | library: | ||
| + | source-dirs: | ||
| + | . | ||
| + | . | ||
| + | . | ||
| + | </ | ||
| + | |||
| + | * delete cabal-file (here `Test7.cabal`), | ||
| + | |||
| + | * build the main project | ||
| + | * command:< | ||
| + | stack build | ||
| + | </ | ||
| + | * output:< | ||
| + | random> configure (lib) | ||
| + | random> Configuring random-1.2.1... | ||
| + | random> build (lib) | ||
| + | random> Preprocessing library for random-1.2.1.. | ||
| + | random> Building library for random-1.2.1.. | ||
| + | random> copy/ | ||
| + | random> Installing library in C: | ||
| + | random> Registering library for random-1.2.1.. | ||
| + | Building all executables for `Test7' | ||
| + | Test7 > configure (lib + exe) | ||
| + | Test7 > Configuring Test7-0.1.0.0... | ||
| + | Test7 > build (lib + exe) | ||
| + | Test7 > Preprocessing library for Test7-0.1.0.0.. | ||
| + | Test7 > Building library for Test7-0.1.0.0.. | ||
| + | Test7 > [1 of 2] Compiling Lib | ||
| + | Test7 > [2 of 2] Compiling Paths_Test7 | ||
| + | Test7 > Preprocessing executable ' | ||
| + | Test7 > Building executable ' | ||
| + | Test7 > [1 of 2] Compiling Main | ||
| + | Test7 > [2 of 2] Compiling Paths_Test7 | ||
| + | Test7 > Linking .stack-work\dist\274b403a\build\Test7-exe\Test7-exe.exe ... | ||
| + | Test7 > copy/ | ||
| + | Test7 > Installing library in C: | ||
| + | Test7 > Installing executable Test7-exe in C: | ||
| + | Test7 > Registering library for Test7-0.1.0.0.. | ||
| + | Completed 2 action(s). | ||
| + | </ | ||
| + | |||
| + | ==== Procedure with tarball files ==== | ||
| + | |||
| + | * unpack the package that should be obtained as source code | ||
| + | * command:< | ||
| + | stack unpack random | ||
| + | </ | ||
| + | * or command with dedicated version number:< | ||
| stack unpack random-1.2.1 | stack unpack random-1.2.1 | ||
| </ | </ | ||
| Line 9: | Line 133: | ||
| </ | </ | ||
| - | * ... | + | * change the current directory |
| * command:< | * command:< | ||
| cd random-1.2.1 | cd random-1.2.1 | ||
| </ | </ | ||
| - | * ... | + | * initialise the folder of the package (here `random-1.2.1`), will create file `stack.yaml` |
| * command:< | * command:< | ||
| stack init | stack init | ||
| Line 34: | Line 158: | ||
| </ | </ | ||
| - | * ... | + | * generate a tarball file of the package code |
| * command:< | * command:< | ||
| stack sdist | stack sdist | ||
| Line 49: | Line 173: | ||
| </ | </ | ||
| - | * ... | + | * change the current directory back to the main one |
| * command:< | * command:< | ||
| cd .. | cd .. | ||
| </ | </ | ||
| - | * to `stack.yaml` of main project add package (here `random-1.2.1`) to section `extra-deps` | + | * to `stack.yaml` of main project, add package |
| * extract< | * extract< | ||
| . | . | ||
| Line 66: | Line 190: | ||
| # extra-deps: [] | # extra-deps: [] | ||
| extra-deps: | extra-deps: | ||
| - | - random-1.2.1 | + | - ./random-1.2.1 |
| # Override default flag values for local packages and extra-deps | # Override default flag values for local packages and extra-deps | ||
| Line 94: | Line 218: | ||
| </ | </ | ||
| - | * delete cabal-file (here `Test6.cabal`) | + | * delete cabal-file (here `Test6.cabal`), if any |
| - | * ... | + | * build the main project |
| * command:< | * command:< | ||
| stack build | stack build | ||
| </ | </ | ||
| + | * output:< | ||
| + | random> configure (lib) | ||
| + | random> Configuring random-1.2.1... | ||
| + | random> build (lib) | ||
| + | random> Preprocessing library for random-1.2.1.. | ||
| + | random> Building library for random-1.2.1.. | ||
| + | random> [1 of 4] Compiling System.Random.GFinite | ||
| + | random> [2 of 4] Compiling System.Random.Internal | ||
| + | random> [3 of 4] Compiling System.Random | ||
| + | random> [4 of 4] Compiling System.Random.Stateful | ||
| + | random> copy/ | ||
| + | random> Installing library in C: | ||
| + | random> Registering library for random-1.2.1.. | ||
| + | Building all executables for `Test6' | ||
| + | Test6 > configure (lib + exe) | ||
| + | Configuring Test6-0.1.0.0... | ||
| + | Test6 > build (lib + exe) | ||
| + | Preprocessing library for Test6-0.1.0.0.. | ||
| + | Building library for Test6-0.1.0.0.. | ||
| + | [1 of 2] Compiling Lib | ||
| + | [2 of 2] Compiling Paths_Test6 | ||
| + | Preprocessing executable ' | ||
| + | Building executable ' | ||
| + | [1 of 2] Compiling Main | ||
| + | [2 of 2] Compiling Paths_Test6 | ||
| + | Linking .stack-work\dist\274b403a\build\Test6-exe\Test6-exe.exe ... | ||
| + | Test6 > copy/ | ||
| + | Installing library in C: | ||
| + | Installing executable Test6-exe in C: | ||
| + | Registering library for Test6-0.1.0.0.. | ||
| + | Completed 2 action(s). | ||
| + | </ | ||
| - | * ... | ||
| - | * command:< | ||
| - | stack build | ||
| - | </ | ||
| + | ===== ✎ ===== | ||
| + | ~~DISCUSSION~~ | ||
toolsetup/buildingapackagelocally.1644957955.txt.gz · Last modified: (external edit)
