Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
theCapypara committed Sep 24, 2024
2 parents dc411fb + d97b211 commit 0b455c7
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 80 deletions.
23 changes: 10 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Deploys to PyPi on new tags.
name: Build, test and publish

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
build:
Expand All @@ -17,21 +17,18 @@ jobs:
- name: Rewrite version for dev if not tag
if: "!startsWith(github.ref, 'refs/tags/')"
run: |
perl -i -pe "s/__version__\s*=\s*'(.*?)(\.rc.*|\.a.*|\.post.*)?'/__version__='\1.dev0+${GITHUB_SHA::8}'/" setup.py
perl -i -pe "s/version\s*=\s*\"(.*?)(\.rc.*|\.a.*|\.post.*)?\"/version=\"\1.dev0+${GITHUB_SHA::8}\"/" pyproject.toml
- name: Note version
run: |
echo "PACKAGE_VERSION=$(python3 -- ./setup.py --version)" >> $GITHUB_ENV
- name: Set up Python 3.8
echo "PACKAGE_VERSION=$(tomlq '.project.version' pyproject.toml -r)" >> $GITHUB_ENV
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
- name: Upgrade pip
python-version: 3.12
- name: Build wheels
run: |
python -m pip install --upgrade pip
- name: Build Python wheels
uses: RalfG/[email protected]_x86_64
with:
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
python3 -m pip install --upgrade pip build
python3 -m build
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
Expand All @@ -47,10 +44,10 @@ jobs:
uses: actions/download-artifact@v4
with:
name: wheels
- name: Set up Python 3.8
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
graft riptide/assets
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "riptide-lib"
version = "0.9.0"
description = "Tool to manage development environments for web applications using containers - Library Package"
readme = "README.rst"
requires-python = ">=3.8"
license = { file = "LICENSE" }
authors = [
{ name = "Marco Köpcke", email = "[email protected]" }
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]
dependencies = [
"configcrunch >= 1.0.3",
"schema >= 0.7",
"pyyaml >= 5.4",
"appdirs >= 1.4",
"janus >= 0.7",
"psutil >= 5.8",
"GitPython >= 3.1",
"pywinpty >= 0.5.5; sys_platform == 'win32'",
"python-hosts >= 0.4",
"python-dotenv >= 0.19.0"
]

[project.urls]
Repository = "https://github.com/theCapypara/riptide-lib"
Documentation = "https://riptide-docs.readthedocs.io"

[tool.setuptools.packages.find]
exclude = ["test_assets"]
14 changes: 7 additions & 7 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
schema==0.7.5
pyyaml==6.0.1
configcrunch==1.0.5
schema==0.7.7
pyyaml==6.0.2
configcrunch==1.1.0.post1
appdirs==1.4.4
janus==1.0.0
psutil==5.9.8
GitPython==3.1.42
pywinpty==2.0.12; sys_platform == 'win32'
python-hosts==1.0.5
psutil==6.0.0
GitPython==3.1.43
pywinpty==2.0.13; sys_platform == 'win32'
python-hosts==1.0.7
python-dotenv==1.0.1
33 changes: 25 additions & 8 deletions riptide/config/document/command.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from collections import OrderedDict

import os
from collections import OrderedDict
from pathlib import PurePosixPath
from typing import TYPE_CHECKING, Union

from configcrunch import variable_helper
from dotenv import dotenv_values
from schema import Schema, Optional, Or
from typing import TYPE_CHECKING, Union

from configcrunch import variable_helper
from riptide.config.document.common_service_command import ContainerDefinitionYamlConfigDocument
from riptide.config.files import get_project_meta_folder, CONTAINER_SRC_PATH
from riptide.config.service.config_files import process_config
Expand All @@ -18,7 +17,6 @@
from riptide.config.document.project import Project
from riptide.config.document.app import App


HEADER = 'command'
KEY_IDENTIFIER_IN_SERVICE_COMMAND = 'in_service_with_role'

Expand All @@ -30,6 +28,7 @@ class Command(ContainerDefinitionYamlConfigDocument):
Placed inside an :class:`riptide.config.document.app.App`.
"""

@classmethod
def header(cls) -> str:
return HEADER
Expand Down Expand Up @@ -273,7 +272,8 @@ def collect_volumes(self) -> OrderedDict:
services_already_checked.append(service)
for config_name, config in service["config"].items():
force_recreate = False
if "force_recreate" in service["config"][config_name] and service["config"][config_name]["force_recreate"]:
if "force_recreate" in service["config"][config_name] and service["config"][config_name][
"force_recreate"]:
force_recreate = True
bind_path = str(PurePosixPath('/src/').joinpath(PurePosixPath(config["to"])))
process_config(volumes, config_name, config, service, bind_path, regenerate=force_recreate)
Expand Down Expand Up @@ -308,7 +308,23 @@ def collect_environment(self) -> dict:
:return: dict. Returned format is ``{key1: value1, key2: value2}``.
"""
env = os.environ.copy()
keys_to_remove = {"PATH", "PS1", "USERNAME", "PWD", "SHELL", "HOME", "TMPDIR"}.intersection(set(env.keys()))
keys_to_remove = {
"PATH",
"PS1",
"USER",
"USERNAME",
"PWD",
"SHELL",
"HOME",
"TMPDIR",
"XDG_CACHE_HOME",
"XDG_CONFIG_DIRS",
"XDG_CONFIG_HOME",
"XDG_DATA_DIRS",
"XDG_DATA_HOME",
"XDG_RUNTIME_DIR",
"XDG_STATE_HOME"
}.intersection(set(env.keys()))
for key in keys_to_remove:
del env[key]

Expand Down Expand Up @@ -395,6 +411,7 @@ def volume_path(self) -> str:
host: '/home/peter/my_projects/project1/_riptide/cmd_data/command_name/command_cache'
container: '/foo/bar/cache'
"""
path = os.path.join(get_project_meta_folder(self.get_project().folder()), 'cmd_data', self.internal_get("$name"))
path = os.path.join(get_project_meta_folder(self.get_project().folder()), 'cmd_data',
self.internal_get("$name"))
os.makedirs(path, exist_ok=True)
return path
7 changes: 5 additions & 2 deletions riptide/config/document/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,13 @@ def schema(cls) -> Schema:
List of URLs to Git repositories containing
`Riptide Repositories </config_docs/using_repo/how_repositories.html>`_.
update_hosts_file: bool
update_hosts_file: Or[bool,str]
Whether or not Riptide should automatically update the
`system's host file </user_docs/3_installing.html#resolving-hostnames-permissions-for-the-etc-hosts-file>`_.
This may be set to string, in which case the string must be a path to a hosts file to update. If it
is set to `true`, the system's default hosts file is updated.
[project]: :class:`~riptide.config.document.project.Project`
If a project is loaded, Riptide inserts the project here. Do not manually insert a project
into the actual system configuration file.
Expand Down Expand Up @@ -143,7 +146,7 @@ def schema(cls) -> Schema:
Optional('compression'): bool,
Optional('autoexit'): int # TODO: Not used, deprecated.
},
'update_hosts_file': bool,
'update_hosts_file': Or(bool, str),
'engine': str,
'repos': [str],
Optional('project'): DocReference(Project), # Added and overwritten by system
Expand Down
24 changes: 17 additions & 7 deletions riptide/config/hosts.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Management of hosts-file entries for project services"""
import platform

from python_hosts import Hosts, HostsEntry
from python_hosts.exception import UnableToWriteHosts

from riptide.config.document.config import Config
from riptide.engine.abstract import RIPTIDE_HOST_HOSTNAME


IGNORE_LOCAL_HOSTNAMES = [
"localhost", "localhost.localdomain"
]
Expand All @@ -23,9 +24,17 @@ def update_hosts_file(system_config: Config, warning_callback=lambda msg: None):
:param system_config: System configuration
"""

if system_config["update_hosts_file"]:
if system_config["update_hosts_file"] is not False:
if "project" in system_config:
hosts = Hosts()
if isinstance(system_config["update_hosts_file"], str):
hosts = Hosts(system_config["update_hosts_file"])
else:
if platform.system() == "Darwin":
hosts = Hosts("/private/etc/hosts")
elif platform.system() == "Windows":
hosts = Hosts(r"C:\Windows\System32\Drivers\etc\hosts")
else:
hosts = Hosts()
new_entries = []
changes = False

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


def get_localhost_hosts():
Expand Down
43 changes: 0 additions & 43 deletions setup.py

This file was deleted.

0 comments on commit 0b455c7

Please sign in to comment.