{"id":17115232,"url":"https://github.com/sundarnagarajan/setupext","last_synced_at":"2026-05-01T10:32:35.506Z","repository":{"id":57465981,"uuid":"54010586","full_name":"sundarnagarajan/setupext","owner":"sundarnagarajan","description":"A python module with utility functions to ease creation of python setup (installation) scripts","archived":false,"fork":false,"pushed_at":"2016-03-27T01:26:44.000Z","size":54,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T06:51:26.908Z","etag":null,"topics":["css","distutils","python","wrapper"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sundarnagarajan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-GPLv3.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-16T07:37:14.000Z","updated_at":"2022-01-05T16:00:02.000Z","dependencies_parsed_at":"2022-08-31T03:20:53.525Z","dependency_job_id":null,"html_url":"https://github.com/sundarnagarajan/setupext","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sundarnagarajan/setupext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sundarnagarajan%2Fsetupext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sundarnagarajan%2Fsetupext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sundarnagarajan%2Fsetupext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sundarnagarajan%2Fsetupext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sundarnagarajan","download_url":"https://codeload.github.com/sundarnagarajan/setupext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sundarnagarajan%2Fsetupext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32494270,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css","distutils","python","wrapper"],"created_at":"2024-10-14T17:22:24.959Z","updated_at":"2026-05-01T10:32:35.490Z","avatar_url":"https://github.com/sundarnagarajan.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# setupext\nThis module contains utility methods for easing writing python installation scripts (setup.py).\n\nBuilding C extensions: See setupext/doc/setup-sample.py\n- Specify location of C sources\n- Specify shared library name\n- Specify specific C source files to be compiled\n\nBundle additional files with package - using get_dir_tree()\n- Include and INSTALL C sources under python module directory\n- Include README, LICENSE ando ther files under python module directory\n\nAdd a LIST of shell commands or python callables to execute at different stages of installation:\n- build\n- build_clib\n- build_ext\n- build_py\n- build_scripts\n- install_data\n- install_lib\n- install_headers\n\nBy setting values in setupext.config, a LIST of shell commands and/or python code (callables) can be run before or after each ofthese stages.  Note that you need to include this package within your package if you want\nto use the trigger functionality.\n\nTo only use get_dir_tree(), just copy that function into your setup.py\n\n\n# ASSUMPTIONS AND PACKAGE LAYOUT\nThis setup.py assumes following layout.\ntoplevel --\u003e python package name\n\n~~~~\n\tThis directory\n\t├── setup.py - this file\n\t├── setupext.py - required in this directory\n\t├── LICENSE - typical for github etc but not required\n\t│       Hard-link to a file under data_dirX to keep at top level\n\t│       and also install the same file\n\t│\n\t├── README.rst - typical for github etc but not requiredt\n\t│       Hard-link to a file under data_dirX to keep at top level\n\t│       and also install the same file\n\t│\n\t└── toplevel - python package name\n\t    ├── toplevel.__init__.py\n\t    ├── toplevel.module1.py\n\t    ├── toplevel.module2py\n\t    │\n\t    ├── subpkg1\n\t    │   ├── subpkg1.module1.py\n\t    │   ├── subpkg1.__init__.py\n\t    │   └── subpkg1.module2.py\n\t    │\n\t    ├── data_dir1 - e.g. c_files\n\t    │   ├── data_dir1_file1\n\t    │   ├── data_dir1_file2\n\t    │   └── data_dir1_file3\n\t    │\n\t    └── data_dir2 - e.g. doc\n\t        ├── data_dir2_file1 - e.g. LICENSE\n\t        └── data_dir2_file2 - e.g. README.rst\n~~~~\n\n\nIf your layout is different, you may need to make changes to the following:\n- Under PACKAGE DATA:\n- Set toplevel to module (dir) under which:\n    - C Extension shared lib if any will be installed\n    - Additional data if any (data_dirs) will be installed\n- Setting packages\n\n- Under ADDITIONAL keyword args to setup()\n- Add py_modules=[] to ADDL_KWARGS\n\n- Under C EXTENSION DETAILS - IFF your package includes a C extension:\n    - Setting libpath\n    - Setting c_src_list\n    - Setting ext_modules\n\n\n# C EXTENSION DETAILS\nPut the C files in a dir under toplevel so that the C files can also be installed using data_dirs (see ADDITIONAL DATA FILES)\n\nFor simple cases with a single extension, you should only need to set:\n\n    c_dir--\u003estr: directory\n    libname--\u003estr: shared library filename without '.so'\n    c_src_files--\u003elist of str: C source filenames within c_dir\n\n# ADDITIONAL DATA FILES\nI use package_dir and package_data to specify installing additional files that are:\n- Files in directories under toplevel\n- Wouldn't be AUTOMATICALLY included or installed because of:\n    - py_modules directive\n    - packages=find_packages() directive\n    - C source required for an extension\nExamples:\n- Ship and INSTALL C source under the module directory\n- Ship and INSTALL any other files - e.g:\n    - Documentation\n    - LICENSE\n\nWith this method, we get following features:\n- Do NOT require MANIFEST.in\n- Do NOT require include_package_data directive\n- No code required in setupext.CustomInstallData class\n\nPreparatory steps:\n- If package includes a C-source extension:\n        - Put C source in a dir under toplevel\n        - Set c_dir above to the name of the dir UNDER toplevel\n\n- Create other directories with data under toplevel\n- If you want files in TOP-LEVEL (above toplevel) included, HARD LINK those FILES to directories under toplevel - e.g.:\n    - LICENSE\n    - README.rst\n- Alternatively, hard-link these files FROM the directory under toplevel to the top-level so that these files can be visible at top level (e.g. in github)\n\n- set data_dirs to LIST of directories under toplevel that you want to include\n\n\n\n# CUSTOM STEPS\nTo add a LIST of shell commands or python callables to execute at different steps during installation, modify setupext.config as follows:\n\n    - setupext.config is a DICT with keys representing installation steps\n    - The steps supported are in setupext.known_steps (list of str)\n    - Each element of setupext.config is itself a DICT with following keys:\n        - 'pre': dict\n        - 'post': dict\n\n        'pre' and 'post' dicts can optionally contain the following keys:\n            cmdlist--\u003elist\n                each element must be one of:\n                    str: A shell command to execute with subprocess.call\n                        The command is executed with shell=True\n                        No additional cmdline parameters are added\n                    callable: Will be called with following parameters\n                        args=(caller): caller is instance of calling class\n                            Typically instance of distutils.cmd.Command\n                        pre_post=x: x in ['pre', 'post']\n                        callable can retrieve step name using\n                            args[0].get_command_name()\n                if cmdlist is not set or is [] or None, the corresponding\n                    pre / post dict is ignored\n\n                see pydoc setupext.run_in_order\n\n            show_output--\u003eboolean: Display stdout of shell commands\n                ignored for callables\n                Default: true\n\n            show_err--\u003eboolean: Display stderr of shell commands (on stderr)\n                ignored for callables\n                Default: true\n\n            ignore_err--\u003eboolean: Continue to next element of cmdlist if\n                shell command or callable raises an exception or\n                shell command returns a non-zero return code\n\n                Default is stop processing cmdlist (False)\n\n            show_output, show_err and ignore_err apply to ALL elements\n                of cmdlist\n\n        cmdlist under 'pre' key is executed BEFORE the corresponding\n            installation step\n\n        cmdlist under 'post' key is executed AFTER the corresponding\n            installation step\n\n        callables must be defined at time of executing setup.py\n\n        Note that cmdlist will be executed ONLY IF corresponding\n        step is executed - e.g.:\n            - if byte-compiling is disabled, install_lib won't run\n            - If package doesn't define a C extension, build_ext  won't run\n\n# EXAMPLE:\nAssume you want to do the following:\n    - Run shell_command_1 and callable_1 BEFORE\n        installation build (step: build) begins\n    - Ignore and hide errors running command at build.pre step\n        but show outputs\n    - Run shell_command_2 after build_ext step is completed\n## Steps:\n\n~~~~ {.sourceCode .python}\n# Set to True to get DEBUG on stderr when each step is called\n# Debug messages will appear even if you do not setup custom commands\n# to execute for the step\nsetupext.trace_triggers = False\n\n# Set shell_command_1, shell_command_2\n# shell_command_1 Will return a non-zero return code\nshell_command_1 = 'echo \"Starting build\"; uname --nosuchoption'\nshell_command_2 = 'echo \"build_ext completed\"'\n\n# define a callable\ndef mycallable(*args, **kwargs):\n    sys.stderr.write('%s %s\\n' % (\n        args[0].get_command_name(),\n        kwargs.get('pre_post', 'Unknown')\n    ))\n\n# Now setup setupext.config\nsetupext.config['build']['pre']['cmdlist'] = [shell_command_1, mycallable]\nsetupext.config['build']['post']['ignore_err'] = True\nsetupext.config['build']['post']['show_err'] = False\n# shell_command_1 will produce stderr output and return non-zero code\n# but stderr will be suppressed and mycallable will still be executed\n\nsetupext.config['build_ext']['post']['cmdlist'] = [shell_command_2]\n# stderr if any from shell_command_2 will be shown (on stderr)\n~~~~\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsundarnagarajan%2Fsetupext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsundarnagarajan%2Fsetupext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsundarnagarajan%2Fsetupext/lists"}