From a5b7b9422b4e716cdd6f9550f1325f969b6770f4 Mon Sep 17 00:00:00 2001 From: gregoire kubler <gregoire.kubler@proton.me> Date: Mon, 6 May 2024 14:15:37 +0200 Subject: [PATCH] fix: setup.py now functions with name from pyproject.toml + fixed script .ps1 for aidge core --- ...ildwheel_build_deps_before_build_wheel.ps1 | 10 +++---- pyproject.toml | 28 +++++++++++-------- setup.py | 13 ++++----- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.gitlab/ci/cibuildwheel_build_deps_before_build_wheel.ps1 b/.gitlab/ci/cibuildwheel_build_deps_before_build_wheel.ps1 index 704f43000..af9cabc50 100644 --- a/.gitlab/ci/cibuildwheel_build_deps_before_build_wheel.ps1 +++ b/.gitlab/ci/cibuildwheel_build_deps_before_build_wheel.ps1 @@ -1,11 +1,11 @@ -if ($env:AIDGE_DEPENDENCIES.Length -split " " -eq 0) { + +if ($($env:AIDGE_DEPENDENCIES -split " ").Length -eq 0) { Write-Host "- No dependencies provided for current repsitory" New-Item -ItemType Directory -Force -Path ".\build" | Out-Null Remove-Item -Path ".\build\*" -Recurse -Force } else { - Write-Host "Retrieving given dependencies to build current package : $($deps -join ',')" - foreach ($dep in $env:AIDGE_DEPENDENCIES -split " ") { - + Write-Host "Retrieving given dependencies to build current package : $env:AIDGE_DEPENDENCIES" + foreach ($dep in $($env:AIDGE_DEPENDENCIES -split " ")) { Write-Host "Retrieving : $dep" $dep_path = Get-ChildItem -Path "/host/home/" -Directory -Filter $dep -Recurse | Where-Object { $_.FullName -notmatch 'install' -and @@ -23,7 +23,7 @@ if ($env:AIDGE_DEPENDENCIES.Length -split " " -eq 0) { New-Item -Path ".\build" -ItemType Directory -Force | Out-Null Get-ChildItem -Path ".\build" -File | Remove-Item -Force pip install . -Verbose - } else {Â + } else { throw "$dep not found, aborting." } } diff --git a/pyproject.toml b/pyproject.toml index c7659cf76..e7f7f3c55 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,15 +12,28 @@ classifiers = [ dynamic = ["version"] # defined in tool.setuptools_scm [build-system] -requires = ["setuptools>=68", "setuptools-scm", "cmake"] +requires = [ + "setuptools>=64", + "setuptools_scm[toml]==7.1.0", + "cmake", + "toml" +] build-backend = "setuptools.build_meta" +##################################################### +# SETUPTOOLS +[tool.setuptools] +##################################################### +# SETUPTOOLS_SCM +[tool.setuptools_scm] +write_to = "aidge_core/_version.py" + ##################################################### # CIBUILDWHEEL [tool.cibuildwheel] build-frontend = "build" -############## AIDGE DEPENDENCIES DECLARATION +### AIDGE DEPENDENCIES DECLARATION # aidge_core do not rely on any aidge dependency, hence this string is empty [tool.cibuildwheel.linux.environment] # AIDGE_DEPENDENCIES = "" # format => "dep_1 dep_2 ... dep_n" @@ -29,22 +42,13 @@ build-frontend = "build" [tool.cibuildwheel.linux] before-build = [ - 'echo "dependencies to retrieve : ${AIDGE_DEPENDENCIES}"', "bash .gitlab/ci/cibuildwheel_build_deps_before_build_wheel.sh ${AIDGE_DEPENDENCIES}" ] [tool.cibuildwheel.windows] before-build = [ - 'Write-Host "dependencies to retrieve : $env:{AIDGE_DEPENDENCIES}"', - ".\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1" + "powershell -File .\\.gitlab\\ci\\cibuildwheel_build_deps_before_build_wheel.ps1" ] -##################################################### -# SETUPTOOLS -[tool.setuptools] -# packages=["aidge_core", "export"] - -[tool.setuptools_scm] -version_file = "_version.py" ##################################################### # PYLINT diff --git a/setup.py b/setup.py index c4c672574..5dd0754ee 100644 --- a/setup.py +++ b/setup.py @@ -9,19 +9,18 @@ import multiprocessing from math import ceil +import toml + from setuptools import setup, Extension from setuptools import find_packages from setuptools.command.build_ext import build_ext - def get_project_name() -> str: - return open(pathlib.Path().absolute() / "project_name.txt", "r").read() - + with open(pathlib.Path().absolute() / "pyproject.toml", "r") as file : + project_toml = toml.load(file) + print(f"project_name = {project_toml["project"]["name"]}") + return project_toml["project"]["name"] -def get_project_version() -> str: - aidge_root = pathlib.Path().absolute() - version = open(aidge_root / "version.txt", "r").read().strip() - return version class CMakeExtension(Extension): -- GitLab