You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by ro...@apache.org on 2020/12/29 13:39:20 UTC
[buildstream] 06/17: meson: Make sure importing from the source
tree still works
This is an automated email from the ASF dual-hosted git repository.
root pushed a commit to branch sam/meson
in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit f8764fde0a86fb982b8270312fd4b02cc714f3e1
Author: Sam Thursfield <sa...@codethink.co.uk>
AuthorDate: Thu Dec 14 17:39:43 2017 +0000
meson: Make sure importing from the source tree still works
It's annoying and confusing to find that `import buildstream` fails when
you happen to be in a certain directory. This was happening because we
were importing the version number from a module generated by the Meson
build instructions. We can use a placeholder when running from the source
tree though.
This is also needed so that we can generate the man pages at build time,
because this requires being able to import buildstream.
The only catch is that when buildstream is imported from the current
directory, the version number is simply returned as '(uninstalled)' now.
---
buildstream/__init__.py | 6 +++++-
buildstream/meson.build | 8 ++++----
buildstream/utils.py | 7 ++++++-
buildstream/{config.py.in => version.py.in} | 0
4 files changed, 15 insertions(+), 6 deletions(-)
diff --git a/buildstream/__init__.py b/buildstream/__init__.py
index c49a88f..4b3b94b 100644
--- a/buildstream/__init__.py
+++ b/buildstream/__init__.py
@@ -25,4 +25,8 @@ from .source import Source, SourceError, Consistency
from .element import Element, ElementError, Scope
from .buildelement import BuildElement
from .scriptelement import ScriptElement
-from .config import VERSION
+
+try:
+ from .version import VERSION
+except ImportError:
+ VERSION = '(uninstalled)'
diff --git a/buildstream/meson.build b/buildstream/meson.build
index 2bd4a23..7c34ec3 100644
--- a/buildstream/meson.build
+++ b/buildstream/meson.build
@@ -36,13 +36,13 @@ sources = [
'_yaml.py',
]
-config = configure_file(
- input: 'config.py.in',
- output: 'config.py',
+version = configure_file(
+ input: 'version.py.in',
+ output: 'version.py',
configuration: cdata)
install_data(
- sources + [config],
+ sources + [version],
install_dir: join_paths(python_site_packages_dir, 'buildstream'))
main = configure_file(
diff --git a/buildstream/utils.py b/buildstream/utils.py
index d263bf7..41d38f8 100644
--- a/buildstream/utils.py
+++ b/buildstream/utils.py
@@ -38,12 +38,17 @@ from contextlib import contextmanager
import psutil
-from . import VERSION
from . import _signals
from . import _yaml
from ._exceptions import ProgramNotFoundError
+try:
+ from .version import VERSION
+except ImportError:
+ VERSION = '(uninstalled)'
+
+
class FileListResult():
"""An object which stores the result of one of the operations
which run on a list of files.
diff --git a/buildstream/config.py.in b/buildstream/version.py.in
similarity index 100%
rename from buildstream/config.py.in
rename to buildstream/version.py.in