Skip to content

Commit 0b455c7

Browse files
committed
Merge branch 'master' into release
2 parents dc411fb + d97b211 commit 0b455c7

File tree

8 files changed

+110
-80
lines changed

8 files changed

+110
-80
lines changed

.github/workflows/build.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Deploys to PyPi on new tags.
33
name: Build, test and publish
44

5-
on: [push, pull_request]
5+
on: [ push, pull_request ]
66

77
jobs:
88
build:
@@ -17,21 +17,18 @@ jobs:
1717
- name: Rewrite version for dev if not tag
1818
if: "!startsWith(github.ref, 'refs/tags/')"
1919
run: |
20-
perl -i -pe "s/__version__\s*=\s*'(.*?)(\.rc.*|\.a.*|\.post.*)?'/__version__='\1.dev0+${GITHUB_SHA::8}'/" setup.py
20+
perl -i -pe "s/version\s*=\s*\"(.*?)(\.rc.*|\.a.*|\.post.*)?\"/version=\"\1.dev0+${GITHUB_SHA::8}\"/" pyproject.toml
2121
- name: Note version
2222
run: |
23-
echo "PACKAGE_VERSION=$(python3 -- ./setup.py --version)" >> $GITHUB_ENV
24-
- name: Set up Python 3.8
23+
echo "PACKAGE_VERSION=$(tomlq '.project.version' pyproject.toml -r)" >> $GITHUB_ENV
24+
- name: Set up Python 3.12
2525
uses: actions/setup-python@v5
2626
with:
27-
python-version: 3.8
28-
- name: Upgrade pip
27+
python-version: 3.12
28+
- name: Build wheels
2929
run: |
30-
python -m pip install --upgrade pip
31-
- name: Build Python wheels
32-
uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64
33-
with:
34-
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
30+
python3 -m pip install --upgrade pip build
31+
python3 -m build
3532
- name: Upload wheels
3633
uses: actions/upload-artifact@v4
3734
with:
@@ -47,10 +44,10 @@ jobs:
4744
uses: actions/download-artifact@v4
4845
with:
4946
name: wheels
50-
- name: Set up Python 3.8
47+
- name: Set up Python 3.12
5148
uses: actions/setup-python@v5
5249
with:
53-
python-version: 3.8
50+
python-version: 3.12
5451
- name: Upgrade pip
5552
run: |
5653
python -m pip install --upgrade pip

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
graft riptide/assets

pyproject.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[build-system]
2+
requires = ["setuptools"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "riptide-lib"
7+
version = "0.9.0"
8+
description = "Tool to manage development environments for web applications using containers - Library Package"
9+
readme = "README.rst"
10+
requires-python = ">=3.8"
11+
license = { file = "LICENSE" }
12+
authors = [
13+
{ name = "Marco Köpcke", email = "hello@capypara.de" }
14+
]
15+
classifiers = [
16+
"Development Status :: 4 - Beta",
17+
"Programming Language :: Python",
18+
"Intended Audience :: Developers",
19+
"License :: OSI Approved :: MIT License",
20+
"Programming Language :: Python :: 3.8",
21+
"Programming Language :: Python :: 3.9",
22+
"Programming Language :: Python :: 3.10",
23+
"Programming Language :: Python :: 3.11",
24+
"Programming Language :: Python :: 3.12",
25+
"Programming Language :: Python :: 3.13",
26+
]
27+
dependencies = [
28+
"configcrunch >= 1.0.3",
29+
"schema >= 0.7",
30+
"pyyaml >= 5.4",
31+
"appdirs >= 1.4",
32+
"janus >= 0.7",
33+
"psutil >= 5.8",
34+
"GitPython >= 3.1",
35+
"pywinpty >= 0.5.5; sys_platform == 'win32'",
36+
"python-hosts >= 0.4",
37+
"python-dotenv >= 0.19.0"
38+
]
39+
40+
[project.urls]
41+
Repository = "https://github.com/theCapypara/riptide-lib"
42+
Documentation = "https://riptide-docs.readthedocs.io"
43+
44+
[tool.setuptools.packages.find]
45+
exclude = ["test_assets"]

requirements.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
schema==0.7.5
2-
pyyaml==6.0.1
3-
configcrunch==1.0.5
1+
schema==0.7.7
2+
pyyaml==6.0.2
3+
configcrunch==1.1.0.post1
44
appdirs==1.4.4
55
janus==1.0.0
6-
psutil==5.9.8
7-
GitPython==3.1.42
8-
pywinpty==2.0.12; sys_platform == 'win32'
9-
python-hosts==1.0.5
6+
psutil==6.0.0
7+
GitPython==3.1.43
8+
pywinpty==2.0.13; sys_platform == 'win32'
9+
python-hosts==1.0.7
1010
python-dotenv==1.0.1

riptide/config/document/command.py

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
from collections import OrderedDict
2-
31
import os
2+
from collections import OrderedDict
43
from pathlib import PurePosixPath
4+
from typing import TYPE_CHECKING, Union
55

6+
from configcrunch import variable_helper
67
from dotenv import dotenv_values
78
from schema import Schema, Optional, Or
8-
from typing import TYPE_CHECKING, Union
99

10-
from configcrunch import variable_helper
1110
from riptide.config.document.common_service_command import ContainerDefinitionYamlConfigDocument
1211
from riptide.config.files import get_project_meta_folder, CONTAINER_SRC_PATH
1312
from riptide.config.service.config_files import process_config
@@ -18,7 +17,6 @@
1817
from riptide.config.document.project import Project
1918
from riptide.config.document.app import App
2019

21-
2220
HEADER = 'command'
2321
KEY_IDENTIFIER_IN_SERVICE_COMMAND = 'in_service_with_role'
2422

@@ -30,6 +28,7 @@ class Command(ContainerDefinitionYamlConfigDocument):
3028
Placed inside an :class:`riptide.config.document.app.App`.
3129
3230
"""
31+
3332
@classmethod
3433
def header(cls) -> str:
3534
return HEADER
@@ -273,7 +272,8 @@ def collect_volumes(self) -> OrderedDict:
273272
services_already_checked.append(service)
274273
for config_name, config in service["config"].items():
275274
force_recreate = False
276-
if "force_recreate" in service["config"][config_name] and service["config"][config_name]["force_recreate"]:
275+
if "force_recreate" in service["config"][config_name] and service["config"][config_name][
276+
"force_recreate"]:
277277
force_recreate = True
278278
bind_path = str(PurePosixPath('/src/').joinpath(PurePosixPath(config["to"])))
279279
process_config(volumes, config_name, config, service, bind_path, regenerate=force_recreate)
@@ -308,7 +308,23 @@ def collect_environment(self) -> dict:
308308
:return: dict. Returned format is ``{key1: value1, key2: value2}``.
309309
"""
310310
env = os.environ.copy()
311-
keys_to_remove = {"PATH", "PS1", "USERNAME", "PWD", "SHELL", "HOME", "TMPDIR"}.intersection(set(env.keys()))
311+
keys_to_remove = {
312+
"PATH",
313+
"PS1",
314+
"USER",
315+
"USERNAME",
316+
"PWD",
317+
"SHELL",
318+
"HOME",
319+
"TMPDIR",
320+
"XDG_CACHE_HOME",
321+
"XDG_CONFIG_DIRS",
322+
"XDG_CONFIG_HOME",
323+
"XDG_DATA_DIRS",
324+
"XDG_DATA_HOME",
325+
"XDG_RUNTIME_DIR",
326+
"XDG_STATE_HOME"
327+
}.intersection(set(env.keys()))
312328
for key in keys_to_remove:
313329
del env[key]
314330

@@ -395,6 +411,7 @@ def volume_path(self) -> str:
395411
host: '/home/peter/my_projects/project1/_riptide/cmd_data/command_name/command_cache'
396412
container: '/foo/bar/cache'
397413
"""
398-
path = os.path.join(get_project_meta_folder(self.get_project().folder()), 'cmd_data', self.internal_get("$name"))
414+
path = os.path.join(get_project_meta_folder(self.get_project().folder()), 'cmd_data',
415+
self.internal_get("$name"))
399416
os.makedirs(path, exist_ok=True)
400417
return path

riptide/config/document/config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ def schema(cls) -> Schema:
6464
List of URLs to Git repositories containing
6565
`Riptide Repositories </config_docs/using_repo/how_repositories.html>`_.
6666
67-
update_hosts_file: bool
67+
update_hosts_file: Or[bool,str]
6868
Whether or not Riptide should automatically update the
6969
`system's host file </user_docs/3_installing.html#resolving-hostnames-permissions-for-the-etc-hosts-file>`_.
7070
71+
This may be set to string, in which case the string must be a path to a hosts file to update. If it
72+
is set to `true`, the system's default hosts file is updated.
73+
7174
[project]: :class:`~riptide.config.document.project.Project`
7275
If a project is loaded, Riptide inserts the project here. Do not manually insert a project
7376
into the actual system configuration file.
@@ -143,7 +146,7 @@ def schema(cls) -> Schema:
143146
Optional('compression'): bool,
144147
Optional('autoexit'): int # TODO: Not used, deprecated.
145148
},
146-
'update_hosts_file': bool,
149+
'update_hosts_file': Or(bool, str),
147150
'engine': str,
148151
'repos': [str],
149152
Optional('project'): DocReference(Project), # Added and overwritten by system

riptide/config/hosts.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
"""Management of hosts-file entries for project services"""
2+
import platform
3+
24
from python_hosts import Hosts, HostsEntry
35
from python_hosts.exception import UnableToWriteHosts
46

57
from riptide.config.document.config import Config
68
from riptide.engine.abstract import RIPTIDE_HOST_HOSTNAME
79

8-
910
IGNORE_LOCAL_HOSTNAMES = [
1011
"localhost", "localhost.localdomain"
1112
]
@@ -23,9 +24,17 @@ def update_hosts_file(system_config: Config, warning_callback=lambda msg: None):
2324
:param system_config: System configuration
2425
"""
2526

26-
if system_config["update_hosts_file"]:
27+
if system_config["update_hosts_file"] is not False:
2728
if "project" in system_config:
28-
hosts = Hosts()
29+
if isinstance(system_config["update_hosts_file"], str):
30+
hosts = Hosts(system_config["update_hosts_file"])
31+
else:
32+
if platform.system() == "Darwin":
33+
hosts = Hosts("/private/etc/hosts")
34+
elif platform.system() == "Windows":
35+
hosts = Hosts(r"C:\Windows\System32\Drivers\etc\hosts")
36+
else:
37+
hosts = Hosts()
2938
new_entries = []
3039
changes = False
3140

@@ -50,10 +59,11 @@ def update_hosts_file(system_config: Config, warning_callback=lambda msg: None):
5059
hosts.write()
5160
except UnableToWriteHosts:
5261
entries = "\n".join([f"{e.address}\t{e.names[0]}" for e in new_entries])
53-
warning_callback(f"Could not update the hosts-file ({hosts.hosts_path}) to configure proxy server routing.\n"
54-
f"> Give your user permission to edit this file, to remove this warning.\n"
55-
f"> If you wish to manually add the entries instead, "
56-
f"add the following entries to {hosts.hosts_path}:\n{entries}\n")
62+
warning_callback(
63+
f"Could not update the hosts-file ({hosts.path}) to configure proxy server routing.\n"
64+
f"> Give your user permission to edit this file, to remove this warning.\n"
65+
f"> If you wish to manually add the entries instead, "
66+
f"add the following entries to {hosts.path}:\n{entries}\n")
5767

5868

5969
def get_localhost_hosts():

setup.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)