The TechLang Package Manager (tlpm) helps you manage global and project-wide packages for TechLang projects.
# Initialize a new project
tlpm init
# Install a package from local path
tlpm install ./mylib
# Install a package globally
tlpm install -g ./mylib
# Install from git repository
tlpm install https://github.com/user/package.git
# List installed packages
tlpm list
# Run a script
tlpm run startAfter installing TechLang, tlpm is available as a command-line tool:
# If installed via pip
tlpm --help
# Or run directly
python tlpm.py --helpInitialize a new TechLang project in the current directory.
tlpm init # Interactive mode
tlpm init myproject # Specify name
tlpm init -y # Use defaults (non-interactive)Creates:
tlpackage.json- Project manifesttl_packages/- Local packages directorymain.tl- Entry point (if not exists)
Install packages.
# Install all dependencies from tlpackage.json
tlpm install
# Install specific package
tlpm install ./mylib # From local path
tlpm install https://github.com/user/pkg.git # From git
tlpm install https://github.com/user/pkg.git#v1.0.0 # From git tag/branch
tlpm install global:mylib # From global packages
# Options
tlpm install -g ./mylib # Install globally
tlpm install -D ./mylib # Add to devDependencies
tlpm install --no-save ./x # Don't update tlpackage.jsonRemove a package.
tlpm uninstall mylib # Remove local package
tlpm uninstall -g mylib # Remove global packageList installed packages.
tlpm list # List local packages
tlpm list -g # List global packages
tlpm list -a # List all packagesShow package information.
tlpm info mylibRun a script defined in tlpackage.json.
tlpm run start
tlpm run testLink a local package to global packages for development.
cd mypackage
tlpm link # Link current directory globally
tlpm link ./other # Link specific pathRemove a global package link.
tlpm unlink # Unlink current directory
tlpm unlink mylib # Unlink specific packageAfter tlpm init, your project will have this structure:
myproject/
├── tlpackage.json # Project manifest
├── tl_packages/ # Installed packages
│ ├── package1/
│ └── package2/
└── main.tl # Entry point
The manifest file describes your project and its dependencies:
{
"name": "myproject",
"version": "1.0.0",
"description": "My TechLang project",
"author": "Your Name",
"main": "main.tl",
"dependencies": {
"utils": "1.0.0",
"helpers": "./local/helpers"
},
"dev_dependencies": {
"testing": "1.0.0"
},
"scripts": {
"start": "tl main.tl",
"test": "tl tests/test.tl"
}
}To create a reusable package:
- Create a directory with your package code:
mypackage/
├── tlpackage.json
├── __init__.tl # Main entry point
└── utils.tl # Additional modules
- Add a manifest (
tlpackage.json):
{
"name": "mypackage",
"version": "1.0.0",
"description": "My reusable package",
"main": "__init__.tl"
}- Export functions in
__init__.tl:
def greet name
str_create msg "Hello, "
str_concat msg name
print msg
end
export greet
def add_numbers a b
set result a
add result b
return result
end
export add_numbers
- Share your package:
- Publish to GitHub
- Share the folder path
- Link globally for local development
Once installed, packages can be imported in your TechLang code:
# Import the whole package
import mypackage
call mypackage.greet "World"
# Import with alias
import mypackage as mp
call mp.greet "World"
# Import specific functions
from mypackage import greet
call greet "World"
# Import multiple functions
from mypackage import greet, add_numbers
call greet "User"
set x 5
call add_numbers x 10 result
print result
When you import a package, TechLang searches in this order:
- Current directory - Relative imports
tl_packages/- Project-local packages~/.techlang/packages/- Global packages- Built-in
stl/- Standard library
Global packages are stored in ~/.techlang/packages/ (or %USERPROFILE%\.techlang\packages on Windows).
Use global packages for:
- Utilities you use across multiple projects
- Development tools
- Packages you're developing (via
tlpm link)
- Create your package in a separate directory
- Use
tlpm linkto make it globally available - Import it in your projects during development
- When ready, publish or share the package
Add to your .gitignore:
tl_packages/
This is automatically done by tlpm init.
Define common tasks in tlpackage.json:
{
"scripts": {
"start": "tl main.tl",
"test": "tl tests/run_tests.tl",
"build": "tl scripts/build.tl",
"lint": "python format_tl.py --lint *.tl"
}
}Run with tlpm run <script>.
- Check the package is installed:
tlpm list - Verify the import path matches the package name
- Check search paths by importing in code
tlpm link requires either:
- Administrator privileges, or
- Developer Mode enabled in Windows Settings
Ensure your package has:
- An
__init__.tlfile for folder packages - Or a
.tlextension for file modules - Functions are exported with
export
- Python-like Imports - Import syntax details
- Modules - Module system overview
- Standard Library - Built-in stl packages