🐍 🐍 Installing TuskLang for Python
🐍 Installing TuskLang for Python
"We don't bow to any king" - Python Edition
TuskLang brings revolutionary configuration capabilities to Python applications. This guide covers everything you need to get TuskLang running in your Python environment.
🚀 Quick Installation
One-Line Install (Recommended)
Direct install from official source
curl -sSL https://python.tuskt.sk | python3 -Alternative with wget
wget -qO- https://python.tuskt.sk | python3 -Verify installation
python3 -c "import tsk; print(f'TuskLang {tsk.__version__} installed successfully!')"
PyPI Installation
Install from PyPI
pip install tusklangInstall with specific version
pip install tusklang==1.0.0Install with all optional dependencies
pip install tusklang[all]Verify installation
python -c "import tsk; print(tsk.__version__)"
Source Installation
Clone the repository
git clone https://github.com/tusklang/python.git
cd pythonInstall in development mode
pip install -e .Run tests to verify
python -m pytest tests/
🔧 System Requirements
Python Versions
- Python 3.8+ (Recommended: Python 3.11+) - pip package manager - setuptools for development installationsOptional Dependencies
- PostgreSQL:pip install psycopg2-binary
- MongoDB: pip install pymongo
- Redis: pip install redis
- Async support: pip install asyncio
Operating System Support
- Linux: Ubuntu 18.04+, CentOS 7+, RHEL 7+ - macOS: 10.14+ (Mojave and later) - Windows: Windows 10+ with Python 3.8+📦 Installation Methods
1. Virtual Environment (Recommended)
Create virtual environment
python3 -m venv tusk-envActivate environment
On Linux/macOS:
source tusk-env/bin/activate
On Windows:
tusk-env\Scripts\activateInstall TuskLang
pip install tusklangVerify installation
python -c "import tsk; print('TuskLang ready!')"
2. Conda Environment
Create conda environment
conda create -n tusk-env python=3.11Activate environment
conda activate tusk-envInstall TuskLang
pip install tusklangVerify installation
python -c "import tsk; print('TuskLang ready!')"
3. Docker Installation
Dockerfile
FROM python:3.11-slimWORKDIR /app
Install system dependencies
RUN apt-get update && apt-get install -y \
gcc \
&& rm -rf /var/lib/apt/lists/*Install TuskLang
RUN pip install tusklangCopy your application
COPY . .Run your app
CMD ["python", "app.py"]
Build and run
docker build -t tusk-app .
docker run -it tusk-app
4. Poetry Installation
Initialize poetry project
poetry initAdd TuskLang dependency
poetry add tusklangInstall dependencies
poetry installRun in poetry environment
poetry run python -c "import tsk; print('TuskLang ready!')"
🔍 Verification Steps
Basic Verification
Test basic import
import tsk
print(f"TuskLang version: {tsk.__version__}")Test TSK object creation
from tsk import TSK
config = TSK.from_string("""
$app_name: "TestApp"
$version: "1.0.0"
""")
print("TSK object created successfully!")
Advanced Verification
Test database adapter
from tsk.adapters import SQLiteAdapter
db = SQLiteAdapter(':memory:')
result = db.query("SELECT 1 as test")
print(f"Database test: {result[0]['test']}")Test FUJSEN execution
config = TSK.from_string("""
[test]
hello_fujsen = '''
def hello(name):
return f"Hello, {name}!"
'''
""")result = config.execute_fujsen('test', 'hello', 'TuskLang')
print(f"FUJSEN test: {result}")
CLI Verification
Test CLI installation
tsk --versionTest basic parsing
echo 'app_name: "TestApp"' > test.tsk
tsk parse test.tskTest validation
tsk validate test.tsk
🛠️ Troubleshooting
Common Installation Issues
#### 1. Import Error: No module named 'tsk'
Check if TuskLang is installed
pip list | grep tusklangReinstall if needed
pip uninstall tusklang
pip install tusklangCheck Python path
python -c "import sys; print(sys.path)"
#### 2. Permission Errors
Install with user flag
pip install --user tusklangOr use virtual environment
python3 -m venv tusk-env
source tusk-env/bin/activate
pip install tusklang
#### 3. Compilation Errors
Install build dependencies
On Ubuntu/Debian:
sudo apt-get install python3-dev build-essentialOn CentOS/RHEL:
sudo yum install python3-devel gccOn macOS:
xcode-select --installReinstall
pip install --force-reinstall tusklang
#### 4. Database Adapter Issues
Install database drivers
pip install psycopg2-binary # PostgreSQL
pip install pymongo # MongoDB
pip install redis # RedisTest database connection
python -c "
from tsk.adapters import SQLiteAdapter
db = SQLiteAdapter(':memory:')
print('Database adapter working!')
"
Version Compatibility
Check version compatibility
import sys
import tskprint(f"Python version: {sys.version}")
print(f"TuskLang version: {tsk.__version__}")
Minimum requirements
if sys.version_info < (3, 8):
print("Warning: Python 3.8+ recommended")
Environment Issues
Check environment variables
echo $PYTHONPATH
echo $PATHReset environment
unset PYTHONPATH
export PATH="/usr/local/bin:/usr/bin:/bin:$PATH"Test in clean environment
python3 -c "import tsk; print('Clean environment test passed')"
🔧 Development Setup
Setting Up Development Environment
Clone repository
git clone https://github.com/tusklang/python.git
cd pythonCreate virtual environment
python3 -m venv venv
source venv/bin/activateInstall development dependencies
pip install -e ".[dev]"Install pre-commit hooks
pre-commit installRun tests
pytest tests/Run linting
flake8 src/
black src/
IDE Configuration
#### VS Code
{
"python.defaultInterpreterPath": "./venv/bin/python",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.formatting.provider": "black"
}
#### PyCharm 1. Go to Settings → Project → Python Interpreter 2. Add new interpreter → Virtual Environment 3. Select existing environment → Choose your venv 4. Apply and OK
📊 Performance Testing
Installation Performance
Time installation
time pip install tusklangCheck package size
pip show tusklangBenchmark import time
python -c "
import time
start = time.time()
import tsk
end = time.time()
print(f'Import time: {(end-start)*1000:.2f}ms')
"
Basic Performance Test
import time
from tsk import TSKTest parsing performance
config_content = """
$app_name: "PerformanceTest"
$version: "1.0.0"[database]
host: "localhost"
port: 5432
name: "testdb"
[api]
endpoint: "https://api.example.com"
timeout: 30
retries: 3
"""
start = time.time()
config = TSK.from_string(config_content)
parse_time = (time.time() - start) * 1000
print(f"Parsing time: {parse_time:.2f}ms")
🚀 Next Steps
After successful installation:
1. Create your first TSK file - See 002-quick-start-python.md 2. Learn basic syntax - See 003-basic-syntax-python.md 3. Explore FUJSEN capabilities - See 004-fujsen-python.md 4. Integrate with databases - See 005-database-integration-python.md
📚 Additional Resources
- Official Documentation: tuskt.sk/documents/python - GitHub Repository: github.com/tusklang/python - PyPI Package: pypi.org/project/tusklang - Community Support: community.tuskt.sk
---
"We don't bow to any king" - TuskLang gives you the power to write configuration with a heartbeat. Install it, verify it, and start building revolutionary applications!