-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Consolidate all notes and changes regarding the long-overdue v0.8.0 release. - Pull in latest build.py sample, and then tweak it a bit for 'example' use. - Update some inline docs with format issues. - Expand inlind docs for update_conf()
- Loading branch information
Showing
9 changed files
with
229 additions
and
137 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env python | ||
# | ||
# KSCONF Official example app building script | ||
# | ||
# NOTE: Keep in mind that this is all very expimental and subject to change. | ||
import sys | ||
from pathlib import Path | ||
|
||
from ksconf.builder import QUIET, VERBOSE, BuildManager, default_cli | ||
from ksconf.builder.steps import clean_build, copy_files, pip_install | ||
|
||
manager = BuildManager() | ||
|
||
APP_FOLDER = "TA-my_technology" | ||
SPL_NAME = "ta_my_technology-{{version}}.tgz" | ||
SOURCE_DIR = "." | ||
|
||
REQUIREMENTS = "requirements.txt" | ||
|
||
# Files that support the build process, but don't end up in the tarball. | ||
BUILD_FILES = [ | ||
REQUIREMENTS, | ||
] | ||
|
||
COPY_FILES = [ | ||
"README.md", | ||
"bin/*.py", | ||
"default/", | ||
"metadata/*.meta", | ||
"static/", | ||
"lookups/*.csv", | ||
"appserver/", | ||
"README/*.spec", | ||
] + BUILD_FILES | ||
|
||
|
||
@manager.cache([REQUIREMENTS], ["lib/"], timeout=7200) | ||
def python_packages(step): | ||
# Reuse shared function from ksconf.build.steps | ||
pip_install(step, REQUIREMENTS, "lib", | ||
handle_dist_info="remove") | ||
|
||
|
||
def package_spl(step): | ||
top_dir = step.dist_path.parent | ||
release_path = top_dir / ".release_path" | ||
release_name = top_dir / ".release_name" | ||
step.run(sys.executable, "-m", "ksconf", "package", | ||
"--file", step.dist_path / SPL_NAME, # Path to created tarball | ||
"--app-name", APP_FOLDER, # Top-level directory name | ||
"--block-local", # VC build, no 'local' folder | ||
"--release-file", str(release_path), | ||
".") | ||
# Provide the dist file as a short name too (used by some CI/CD tools) | ||
path = release_path.read_text() | ||
short_name = Path(path).name | ||
release_name.write_text(short_name) | ||
|
||
|
||
def build(step, args): | ||
""" Build process """ | ||
# Step 1: Clean/create build folder | ||
clean_build(step) | ||
|
||
# Step 2: Copy files from source to build folder | ||
copy_files(step, COPY_FILES) | ||
|
||
# Step 3: Install Python package dependencies | ||
python_packages(step) | ||
|
||
# Step 4: Make tarball | ||
package_spl(step) | ||
|
||
|
||
if __name__ == '__main__': | ||
# Tell build manager where stuff lives | ||
manager.set_folders(SOURCE_DIR, "build", "dist") | ||
|
||
# Launch build CLI | ||
default_cli(manager, build) |
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,23 @@ | ||
|
||
Build example | ||
------------- | ||
|
||
|
||
Take a look at this example :file:`build.py` file that use the :py:mod:`ksconf.builder` module. | ||
|
||
|
||
.. literalinclude:: _static/build.py | ||
:language: python | ||
:linenos: | ||
:name: build.py | ||
|
||
|
||
Usage notes | ||
~~~~~~~~~~~ | ||
|
||
* :py:class:`~ksconf.builder.core.BuildManager` - is used to help orchestrate the build process. | ||
* ``step`` is an instance of :py:class:`~ksconf.builder.BuildStep`, which is passed as the first argument to all the of step-service functions. | ||
This class assists with logging, and directing all activities to the correct paths. | ||
* There's no interal interface for :ref:`ksconf_cmd_package` yet, hence another instance of Python is launched on line 48. | ||
This is done using the module execution mode of Python, which is a slightly more reliable way of launching ksconf from within itself. | ||
For whatever that's worth. |
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
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
Oops, something went wrong.