| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
# Symlink install flit & flit_core for development. |
| 4 |
# Most projects can do the same with 'flit install --symlink'. |
| 5 |
# But that doesn't work until Flit is installed, so we need some bootstrapping. |
| 6 |
|
| 7 |
import argparse |
| 8 |
import logging |
| 9 |
import os |
| 10 |
from pathlib import Path |
| 11 |
import sys |
| 12 |
|
| 13 |
my_dir = Path(__file__).parent |
| 14 |
os.chdir(str(my_dir)) |
| 15 |
sys.path.insert(0, 'flit_core') |
| 16 |
|
| 17 |
from flit.install import Installer |
| 18 |
|
| 19 |
ap = argparse.ArgumentParser() |
| 20 |
ap.add_argument('--user') |
| 21 |
args = ap.parse_args() |
| 22 |
|
| 23 |
logging.basicConfig(level=logging.INFO) |
| 24 |
|
| 25 |
install_kwargs = {'symlink': True} |
| 26 |
if os.name == 'nt': |
| 27 |
# Use .pth files instead of symlinking on Windows |
| 28 |
install_kwargs = {'symlink': False, 'pth': True} |
| 29 |
|
| 30 |
# Install flit_core |
| 31 |
Installer.from_ini_path( |
| 32 |
my_dir / 'flit_core' / 'pyproject.toml', user=args.user, **install_kwargs |
| 33 |
).install() |
| 34 |
print("Linked flit_core into site-packages.") |
| 35 |
|
| 36 |
# Install flit |
| 37 |
Installer.from_ini_path( |
| 38 |
my_dir / 'pyproject.toml', user=args.user, **install_kwargs |
| 39 |
).install() |
| 40 |
print("Linked flit into site-packages.") |