forked from mesonbuild/meson-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR mesonbuild#177 Signed-off-by: Filipe Laíns <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Filipe Laíns <[email protected]>
- Loading branch information
1 parent
bfdc549
commit 71c6a3a
Showing
8 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!python | ||
|
||
print('hello!') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include <stdio.h> | ||
|
||
int main() { | ||
printf("hello!"); | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
def foo(): | ||
return 'bar' | ||
|
||
|
||
if __name__ == '__main__': | ||
print('foo?', foo()) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import argparse | ||
import os | ||
|
||
|
||
def write_version_info(path): | ||
# A real project would call something to generate this | ||
dummy_version = '1.0.0' | ||
dummy_hash = '013j2fiejqea' | ||
if os.environ.get('MESON_DIST_ROOT'): | ||
path = os.path.join(os.environ.get('MESON_DIST_ROOT'), path) | ||
with open(path, 'w') as file: | ||
file.write(f'__version__="{dummy_version}"\n') | ||
file.write( | ||
f'__git_version__="{dummy_hash}"\n' | ||
) | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'-o', '--outfile', type=str, help='Path to write version info to' | ||
) | ||
args = parser.parse_args() | ||
|
||
if not args.outfile.endswith('.py'): | ||
raise ValueError( | ||
f'Output file must be a Python file. ' | ||
f'Got: {args.outfile} as filename instead' | ||
) | ||
|
||
write_version_info(args.outfile) | ||
|
||
|
||
main() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
project( | ||
'executable-bit', 'c', | ||
version: '1.0.0', | ||
) | ||
|
||
py_mod = import('python') | ||
fs = import('fs') | ||
py = py_mod.find_installation() | ||
|
||
executable( | ||
'example', 'example.c', | ||
install: true, | ||
) | ||
|
||
install_data( | ||
'example-script.py', | ||
rename: 'example-script', | ||
install_dir: get_option('bindir'), | ||
) | ||
|
||
py.install_sources('executable_module.py') | ||
|
||
version_gen = files('generate_version.py') | ||
|
||
if fs.exists('_version_meson.py') | ||
py.install_sources('_version_meson.py') | ||
else | ||
custom_target('write_version_file', | ||
output: '_version_meson.py', | ||
command: [ | ||
py, version_gen, '-o', '@OUTPUT@' | ||
], | ||
build_by_default: true, | ||
build_always_stale: true, | ||
install: true, | ||
install_dir: py.get_install_dir(pure: false) | ||
) | ||
meson.add_dist_script(py, version_gen, '-o', '_version_meson.py') | ||
endif |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[build-system] | ||
build-backend = 'mesonpy' | ||
requires = ['meson-python'] |
This file contains 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