diff --git a/pyodide/setup.py b/pyodide/setup.py index 477fe2be91..b310a96b6c 100644 --- a/pyodide/setup.py +++ b/pyodide/setup.py @@ -1,11 +1,34 @@ # setup.py is getting deprecated, but we still use it, # because `tool.setuptools.ext-modules` is still experimental in pyproject.toml # and we need it to get the wheel suffix right. -from setuptools import setup, Extension, find_packages +import os +from pathlib import Path + +import tomllib +from setuptools import Extension, setup + + +REPO_FOLDER = Path(__file__).parent + + +def get_version() -> str: + if "PKG_VERSION" in os.environ: + # Inside pyodide build environment. + return os.environ["PKG_VERSION"] + return (REPO_FOLDER / "VERSION").read_text().strip() + + +# Read dependencies from pyproject.toml +def get_dependencies() -> list[str]: + pyproject_toml = REPO_FOLDER / "src" / "ifcopenshell-python" / "pyproject.toml" + pyproject_data = tomllib.loads(pyproject_toml.read_text()) + dependencies = pyproject_data["project"]["dependencies"] + return dependencies + setup( name="ifcopenshell", - version="0.8.0", + version=get_version(), description=( "IfcOpenShell is an open source (LGPL) software library " "for working with the Industry Foundation Classes (IFC) file format." @@ -13,6 +36,7 @@ setup( author="Thomas Krijnen", author_email="thomas@aecgeeks.com", url="https://ifcopenshell.org", + install_requires=get_dependencies(), packages=["ifcopenshell"], package_data={ # "*.so" is needed to include prebuilt binary extension. Otherwise it would try to build it and fail.