1
|
|
|
# -*- coding: utf-8 -*- |
2
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
3
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
4
|
|
|
# this work for additional information regarding copyright ownership. |
5
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
6
|
|
|
# (the "License"); you may not use this file except in compliance with |
7
|
|
|
# the License. You may obtain a copy of the License at |
8
|
|
|
# |
9
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
10
|
|
|
# |
11
|
|
|
# Unless required by applicable law or agreed to in writing, software |
12
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
13
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
14
|
|
|
# See the License for the specific language governing permissions and |
15
|
|
|
# limitations under the License. |
16
|
|
|
|
17
|
|
|
import os |
18
|
|
|
|
19
|
|
|
from pip.req import parse_requirements |
20
|
|
|
|
21
|
|
|
__all__ = [ |
22
|
|
|
'fetch_requirements', |
23
|
|
|
'apply_vagrant_workaround' |
24
|
|
|
] |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
def fetch_requirements(requirements_file_path): |
28
|
|
|
""" |
29
|
|
|
Return a list of requirements and links by parsing the provided requirements file. |
30
|
|
|
""" |
31
|
|
|
links = [] |
32
|
|
|
reqs = [] |
33
|
|
|
for req in parse_requirements(requirements_file_path, session=False): |
34
|
|
|
if req.link: |
35
|
|
|
links.append(str(req.link)) |
36
|
|
|
reqs.append(str(req.req)) |
37
|
|
|
return (reqs, links) |
38
|
|
|
|
39
|
|
|
|
40
|
|
|
def apply_vagrant_workaround(): |
41
|
|
|
""" |
42
|
|
|
Function which detects if the script is being executed inside vagrant and if it is, it deletes |
43
|
|
|
"os.link" attribute. |
44
|
|
|
Note: Without this workaround, setup.py sdist will fail when running inside a shared directory |
45
|
|
|
(nfs / virtualbox shared folders). |
46
|
|
|
""" |
47
|
|
|
if os.environ.get('USER', None) == 'vagrant': |
48
|
|
|
del os.link |
49
|
|
|
|