Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ build:precommit:
- pip3 install -r requirements-dev.txt
script:
- pre-commit run --all-files
tags:
- docker

build:test:
stage: build
Expand All @@ -33,8 +31,6 @@ build:test:
- pip3 install -r requirements-dev.txt
script:
- pytest -v
tags:
- docker

build:dist:
stage: build
Expand Down
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
- repo: https://github.com/sirosen/check-jsonschema
rev: 0.22.0
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.32.1
hooks:
- id: check-jsonschema
name: "Check schemas"
Expand All @@ -32,4 +32,4 @@ repos:
language: python
files: ^doc/openapi.yaml$
types: [yaml]
args: ["--schemafile", "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"]
args: ["--schemafile", "https://spec.openapis.org/oas/3.1/schema/2025-02-13"]
22 changes: 19 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
from setuptools import setup, find_namespace_packages
from glob import glob

from villas.controller import __version__ as version
import os
import re


def get_version():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not fully grasp why this is required. The import of the version variable seems a more elegant solution to me, and is also a common approach I've seen in other projects.

I will approve this PR, because we should migrate away from setup.py anyway, and adopt pyproject.toml instead.

here = os.path.abspath(os.path.dirname(__file__))
init_file = os.path.join(here, "villas", "controller", "__init__.py")

with open(init_file, "r") as f:
content = f.read()

match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M)
if match:
Comment on lines +15 to +16
Copy link

Copilot AI Apr 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The regex pattern may fail to match the version string if there is leading whitespace before version. Consider updating the pattern to allow optional whitespace (e.g., '^\s*version = ...') to improve robustness.

Suggested change
match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", content, re.M)
if match:
match = re.search(r"^\s*__version__ = ['\"]([^'\"]*)['\"]", content, re.M)

Copilot uses AI. Check for mistakes.
return match.group(1)

raise RuntimeError("Version not found")


with open('README.md') as f:
long_description = f.read()

setup(
name='villas-controller',
version=version,
version=get_version(),
description='A controller/orchestration API for real-time '
'power system simulators',
long_description=long_description,
Expand All @@ -20,7 +36,7 @@
keywords='simulation controller villas',
classifiers=[
'Development Status :: 3 - Alpha',
'License :: OSI Approved :: Apache Software License'
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python :: 3'
],
packages=find_namespace_packages(include=['villas.*']),
Expand Down
Empty file added villas/__init__.py
Empty file.