summaryrefslogtreecommitdiffstats
path: root/bootstrap_dev.py
blob: e7cf3e1426c9f7a860e55b49dbcbc58200861921 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3

# Symlink install flit & flit_core for development.
# Most projects can do the same with 'flit install --symlink'.
# But that doesn't work until Flit is installed, so we need some bootstrapping.

import argparse
import logging
import os
from pathlib import Path
import sys

my_dir = Path(__file__).parent
os.chdir(str(my_dir))
sys.path.insert(0, 'flit_core')

from flit.install import Installer

ap = argparse.ArgumentParser()
ap.add_argument('--user')
args = ap.parse_args()

logging.basicConfig(level=logging.INFO)

install_kwargs = {'symlink': True}
if os.name == 'nt':
    # Use .pth files instead of symlinking on Windows
    install_kwargs = {'symlink': False, 'pth': True}

# Install flit_core
Installer.from_ini_path(
    my_dir / 'flit_core' / 'pyproject.toml', user=args.user, **install_kwargs
).install()
print("Linked flit_core into site-packages.")

# Install flit
Installer.from_ini_path(
    my_dir / 'pyproject.toml', user=args.user, **install_kwargs
).install()
print("Linked flit into site-packages.")