This repository was archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker_dev_python.py
More file actions
64 lines (55 loc) · 2.21 KB
/
docker_dev_python.py
File metadata and controls
64 lines (55 loc) · 2.21 KB
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
##############################################################################
#
# Copyright (c) 2016, 2degrees Limited.
# All Rights Reserved.
#
# This file is part of django-pastedeploy-settings
# <https://github.com/2degrees/django-pastedeploy-settings>, which is subject
# to the provisions of the BSD at
# <http://dev.2degreesnetwork.com/p/2degrees-license.html>. A copy of the
# license should accompany this distribution. THIS SOFTWARE IS PROVIDED "AS IS"
# AND ANY AND ALL EXPRESS OR IMPLIED WARRANTIES ARE DISCLAIMED, INCLUDING, BUT
# NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST
# INFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE.
#
##############################################################################
from logging import getLogger
from os.path import isfile as is_file
from os.path import join as join_path
from sys import executable as PYTHON_INTERPRETER_PATH
from docker_dev.docker_interface import get_docker_compose_config
from docker_dev.subprocess import run_command
_LOGGER = getLogger(__name__)
def build_python_distributions(docker_compose_file_path, project_name):
docker_compose_config = \
get_docker_compose_config(docker_compose_file_path, project_name)
services = docker_compose_config['services'].values()
build_dir_paths = {s['build']['context'] for s in services if 'build' in s}
for dir_path in build_dir_paths:
_generate_egg_info_directory(dir_path)
def _generate_egg_info_directory(distribution_path):
if _is_dir_python_distribution(distribution_path):
_LOGGER.info(
'Generating .egg-info directory for distribution at %r',
distribution_path,
)
run_command(
PYTHON_INTERPRETER_PATH,
[
'setup.py',
'develop',
'--editable',
'--build-directory',
'.',
'--no-deps',
'--dry-run',
],
cwd=distribution_path,
)
else:
_LOGGER.info(
'%r does not contain a Python distribution',
distribution_path,
)
def _is_dir_python_distribution(dir_path):
return is_file(join_path(dir_path, 'setup.py'))