Skip to content

Commit 54448a8

Browse files
authored
Problem: The python target regenerates setup.py
The only reason to regenerate setup.py is to update changes in project name, version and other project metadata. Some bindings may need more complex setup configuration than provided by the generator, so it makes more sense to only regenerate a separate file containing project name, version, etc. and read this file from within setup.py
1 parent 0ed412a commit 54448a8

File tree

1 file changed

+33
-18
lines changed

1 file changed

+33
-18
lines changed

zproject_python.gsl

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -243,28 +243,43 @@ endfunction
243243

244244
function generate_setup_py
245245
directory.create ("bindings/python")
246-
output "bindings/python/setup.py"
246+
output "bindings/python/_project.py"
247247
>$(project.GENERATED_WARNING_HEADER:)
248-
>from setuptools import setup
249-
>
250-
>setup(
251-
> name = "$(project.name:c)",
252-
> version = "$(project->version.major).$(project->version.minor).$(project->version.patch)",
253-
> license = "$(project.license)",
254-
> description = """Python bindings of: $(project.description)""",
248+
>NAME = "$(project.name:c)"
249+
>VERSION = "$(project->version.major).$(project->version.minor).$(project->version.patch)"
250+
>LICENSE = "$(project.license)"
251+
>DESCRIPTION = """Python bindings of: $(project.description)"""
255252
if defined (project.repository)
256-
> url = "$(project.repository)",
253+
>URL = "$(project.repository)"
254+
else
255+
>URL = ""
257256
endif
258-
> packages = ["$(project.name:c)"],
259-
> install_requires = [
260-
for project.use
261-
if count (project->dependencies.class, class.project = use.project) > 0
262-
> "$(use.project)",
263-
endif
264-
endfor
265-
> ],
266-
>)
257+
>PACKAGES = ["$(project.name:c)"]
258+
>REQUIRES = [
259+
for project.use
260+
if count (project->dependencies.class, class.project = use.project) > 0
261+
> "$(use.project)",
262+
endif
263+
endfor
264+
>]
267265
>$(project.GENERATED_WARNING_HEADER:)
266+
267+
if !file.exists ("bindings/python/setup.py")
268+
output "bindings/python/setup.py"
269+
>import os.path
270+
>from _project import NAME, VERSION, LICENSE, DESCRIPTION, URL, PACKAGES, REQUIRES
271+
>from setuptools import setup
272+
>
273+
>setup(
274+
> name = NAME,
275+
> version = VERSION,
276+
> license = LICENSE,
277+
> description = DESCRIPTION,
278+
> url = URL,
279+
> packages = PACKAGES,
280+
> install_requires = REQUIRES,
281+
>)
282+
endif
268283
endfunction
269284

270285
function generate_binding

0 commit comments

Comments
 (0)