Make pyproject.toml PEP 621 compliant

- converted tool.poetry to PEP 621 (default behavior for poetry)
- converted setup.py to PEP 621 (recommended by setuptools)
- use pyproject.toml instead of version.txt
- use importlib instead of version.txt
- use PEP 621 dependency format in flatpak build scripts
- added tomli as a dev dependency (used in build scripts)
- removed version.txt (no longer used)
- cleaned up dependencies

- version is still in desktop/setup.py (unclear on how snapcraft uses it)
- poetry lockfiles need to be rebuilt
This commit is contained in:
Timothy Cyrus 2025-03-13 18:38:11 -04:00
parent 2cee0508d1
commit 5e89cdcbc4
12 changed files with 197 additions and 175 deletions

View file

@ -1,7 +1,6 @@
#!/usr/bin/env python3
from setuptools.command.build import build
import sys
import os
import sys
import inspect
import click
import shutil
@ -10,6 +9,11 @@ import uuid
import xml.etree.ElementTree as ET
from glob import glob
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
root = os.path.dirname(
os.path.dirname(
os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
@ -165,17 +169,13 @@ def wix_build_components_xml(root, data):
return component_ids
def msi_package(build_path, msi_path, product_update_code):
def msi_package(build_path, msi_path, product_update_code, version):
print(f"> Build the WiX file")
version_filename = os.path.join(
build_path, "lib", "onionshare_cli", "resources", "version.txt"
)
with open(version_filename) as f:
version = f.read().strip()
# change a version like 2.6.dev1 to just 2.6, for cx_Freeze's sake
last_digit = version[-1]
if version.endswith(f".dev{last_digit}"):
version = version[0:-5]
# change a version like 2.6.dev1 to just 2.6, for cx_Freeze's sake
last_digit = version[-1]
if version.endswith(f".dev{last_digit}"):
version = version[0:-5]
data = {
"id": "TARGETDIR",
@ -428,16 +428,18 @@ def codesign(path):
@click.argument("path")
def package(path):
"""Build the MSI package"""
version_filename = os.path.join(
root, "cli", "onionshare_cli", "resources", "version.txt"
pyproject_filename = os.path.join(
root, "cli", "pyproject.toml"
)
with open(version_filename) as f:
version = f.read().strip()
with open(pyproject_filename, "rb") as f:
pyproject = tomllib.load(f)
version = pyproject['project']['version']
msi_package(
path,
os.path.join(desktop_dir, "dist", f"OnionShare-win64-{version}.msi"),
"ed7f9243-3528-4b4a-b85c-9943982e75eb",
version
)