Replies: 1 comment
-
That helped me to solve my problem. pyproject.toml [tool.poetry]
name = "frinx-services-python-workers"
version = "0.0.0"
description = ""
authors = ["Jozef Volak <[email protected]>"]
readme = "README.md"
packages = [ {include = 'frinx_worker'} ]
[tool.poetry.dependencies]
python = "^3.10"
frinx-inventory-worker = {git = "ssh://[email protected]/FRINXio/frinx-services-python-workers.git", rev = "common_package", subdirectory = "inventory/python"}
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
[tool.poetry.build]
script = "build_script.py" repository structure ├── frinx_worker
│ └── __init__.py
├── inventory
│ └── python
│ ├── frinx_worker
│ │ ├── __init__.py
│ │ └── inventory
│ │ ├── __init__.py
│ │ └── operations.py
│ ├── poetry.lock
│ ├── pyproject.toml
│ ├── README.md
├── build_script.py
├── poetry.lock
├── pyproject.toml
├── README.md build_script.sh import subprocess
import re
REV_PATTERN = r'rev\s*=\s*"([^"]+)"'
PYPROJECT_PATH = "pyproject.toml"
def _get_branch() -> str:
try:
output = subprocess.check_output(['git', 'branch', '--show-current'], stderr=subprocess.STDOUT, text=True)
current_branch = output.strip()
print("Current Git Branch:", current_branch)
return current_branch
except subprocess.CalledProcessError:
print("Error: Not a Git repository or no current branch found.")
except FileNotFoundError:
print("Error: Git command not found. Please ensure Git is installed.")
def _replace_placeholder(current_branch: str) -> None:
with open(PYPROJECT_PATH, 'r') as file:
file_contents = file.read()
updated_contents = re.sub(REV_PATTERN, f'rev = "{current_branch}"', file_contents)
with open(PYPROJECT_PATH, 'w') as file:
file.write(updated_contents)
print(f"Frinx worker packages revision replaced with '{current_branch}' in '{PYPROJECT_PATH}'")
def main():
_replace_placeholder(_get_branch())
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey
I'm working on creating a package that consists of several sub-packages. In the root of my repository, I have a pyproject.toml file, and each sub-package also has its own pyproject.toml. The concept is straightforward: I want to provide the option to install all sub-modules from the repository as a single package or select only specific ones. However, I've encountered an issue with the resulting package structure, which leads to changes in the import paths. Is there a way to resolve this problem, or is it not possible?
Structure of repository:
Inventory package structure
Root package structure
Beta Was this translation helpful? Give feedback.
All reactions