Created
January 27, 2023 23:37
-
-
Save lmazuel/7a7269035afba658c76aea268ffcfe74 to your computer and use it in GitHub Desktop.
Setup.py to pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just having fun, don't take this to seriously :p | |
import sys | |
import importlib | |
def new_module(mod_name): | |
spec = importlib.machinery.ModuleSpec(mod_name,None) | |
return importlib.util.module_from_spec(spec) | |
def create_module(mod_name, object_list): | |
mod = new_module(mod_name) | |
for obj in object_list: | |
setattr(mod,obj.__name__, obj) | |
return mod | |
_SAVED_KWARGS = {} | |
def do_stuf(): | |
def setup(*args, **kwargs): | |
global _SAVED_KWARGS | |
_SAVED_KWARGS = kwargs | |
def find_packages(*args, **kwargs): | |
return "list" | |
return create_module("setuptools", [ | |
setup, | |
find_packages | |
]) | |
from setuptools import find_packages, setup | |
sys.modules['setuptools'] = do_stuf() | |
########### | |
import setup # Import the local file | |
HEADER = """[build-system] | |
requires = ["setuptools ~= 58.0"] | |
[project] | |
""" | |
print(HEADER) | |
for name, value in _SAVED_KWARGS.items(): | |
print(f"{name} = {value}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
First version does something like:
Which is not that bad for 10 minutes of hacking around