forked from pylayers/pylayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
65 lines (55 loc) · 2.04 KB
/
setup.py
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#-*- coding:Utf-8 -*-
#!/usr/bin/env python
"""
Setup script for pylayers
"""
import numpy
from setuptools import setup,find_packages
import os
setup(name='pylayers' ,
version='0.5',
description='Advanced Radio Channel Simulator',
author='UGUEN Bernard, AMIOT Nicolas, LAARAIEDH Mohamed, MHEDHBI Meriem',
url='https://github.com/pylayers/pylayers',
include_dirs = [numpy.get_include()],
install_requires=[],
packages=find_packages()
)
# detect if project and source are already locate in .pylayers
# if not create both
# if so just update the source path
# detect users home
home = os.path.expanduser('~')
# detect directory from which setup is launched
source = os.getcwd()
# project directory name. If no BASENAME env is already set, it is created @home
project = 'pylayers_project'
# check fresh install of pylayers
if not os.path.isfile(os.path.join(home,'.pylayers')):
with open(os.path.join(home,'.pylayers'),'a') as f:
f.write('source\n')
f.write(source)
basen_env = os.getenv('BASENAME')
# test if env var BASENAME already set
#if not create a pyproject directory
if basen_env == None:
if not os.path.isdir(os.path.join(home,project)):
os.mkdir(os.path.join(home,project))
else:
project=basen_env
f.write('\nproject\n')
f.write(os.path.join(home,project))
# if pylayers has already been installed, a .pylayers exists.
# The idea here is to maintain the project path and to update the source path.
else:
with open(os.path.join(home,'.pylayers'),'r') as f:
lines = f.readlines()
# line corresponding to the source's path
with open(os.path.join(home,'.pylayers'),'w') as f:
for il,l in enumerate(lines):
# line corresponding to the source's path
if il != 1:
f.write(l)
else :
f.write(source+"\n")