Skip to content

Commit

Permalink
Merge pull request #2990 from branchvincent/pyproject
Browse files Browse the repository at this point in the history
Make pyproject.toml's version dynamic
  • Loading branch information
nicolargo authored Oct 24, 2024
2 parents 604d805 + 0e40ec6 commit ff1cde4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
5 changes: 0 additions & 5 deletions docker-files/alpine.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ COPY requirements.txt docker-requirements.txt webui-requirements.txt optional-re

##############################################################################
# BUILD: Install the minimal image deps
# Minimal in Docker mean: Docker + WebUI
FROM build as buildMinimal
ARG PYTHON_VERSION

Expand Down Expand Up @@ -104,10 +103,6 @@ ARG PYTHON_VERSION
COPY ./docker-compose/glances.conf /etc/glances/glances.conf
COPY ./glances/. /app/glances/

# Copy pyproject file in order to have the version
# Note: Glances is not installed as a Pypi pkg in Docker
COPY ./pyproject.toml /app

# Copy binary and update PATH
COPY docker-bin.sh /usr/local/bin/glances
RUN chmod a+x /usr/local/bin/glances
Expand Down
5 changes: 0 additions & 5 deletions docker-files/ubuntu.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ COPY requirements.txt docker-requirements.txt webui-requirements.txt optional-re

##############################################################################
# BUILD: Install the minimal image deps
# Minimal in Docker mean: Docker + WebUI
FROM build as buildMinimal
ARG PYTHON_VERSION

Expand Down Expand Up @@ -88,10 +87,6 @@ ARG PYTHON_VERSION
COPY ./docker-compose/glances.conf /etc/glances/glances.conf
COPY ./glances/. /app/glances/

# Copy pyproject file in order to have the version
# Note: Glances is not installed as a Pypi pkg in Docker
COPY ./pyproject.toml /app

# Copy binary and update PATH
COPY docker-bin.sh /usr/local/bin/glances
RUN chmod a+x /usr/local/bin/glances
Expand Down
19 changes: 2 additions & 17 deletions glances/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,15 @@

# Import system libs
import locale
import os
import platform
import re
import signal
import sys
import tracemalloc
from importlib import metadata

# Global name
# Version is now set in the pyproject.toml file
# and should start and end with a numerical char
# Version should start and end with a numerical char
# See https://packaging.python.org/specifications/core-metadata/#version
try:
# Read the version from the metadata (when deployed with Pypi)
__version__ = metadata.version("glances")
except metadata.PackageNotFoundError:
if os.path.exists('pyproject.toml'):
# In local try to read the version in the pyproject.toml file
# Dirty but it make the job
with open('pyproject.toml', encoding='utf-8') as f:
__version__ = re.search(r"^version = ['\"]([^'\"]*)['\"]", f.read(), re.M).group(1)
else:
# Else set a unknown version
__version__ = "0.0.0+unknown"
__version__ = "4.3.0_dev02"
__apiversion__ = '4'
__author__ = 'Nicolas Hennion <[email protected]>'
__license__ = 'LGPLv3'
Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ dependencies = [
"requests; platform_system == 'Windows'",
]
description = "A cross-platform curses-based monitoring tool"
dynamic = ["version"]
keywords = ["cli", "curses", "monitoring", "system"]
license = {text = "LGPLv3"}
name = "Glances"
readme = "README.rst"
requires-python = ">=3.8"
urls.Homepage = "https://github.com/nicolargo/glances"
version = "4.3.0_dev02"

[project.optional-dependencies]
action = ["chevron"]
Expand Down Expand Up @@ -86,6 +86,9 @@ glances = "glances:main"
]
"share/man/man1" = ["docs/man/glances.1"]

[tool.setuptools.dynamic]
version = { attr = "glances.__version__" }

[tool.setuptools.packages.find]
include = ["glances*"]

Expand Down

0 comments on commit ff1cde4

Please sign in to comment.