forked from Klipper3d/klipper
-
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.
util: Fix versioning when gitdir is absent (Klipper3d#809)
The gitdir previously could be absent and produce a version of "" in spite of checks for it. Fixed. Parent directories with shlex-interpreted characters in their names could be misinterpreted. Removed shlex parsing. Packagers may want to remove the git history to slim down the package size, so add an option for using a file 'version' in the klippy directory to set version without using git. Signed-Off-By: Lucas Fink <[email protected]>
- Loading branch information
1 parent
f57c294
commit a33792f
Showing
4 changed files
with
87 additions
and
11 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 |
---|---|---|
|
@@ -3,3 +3,4 @@ out | |
*.pyc | ||
.config | ||
.config.old | ||
klippy/.version |
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,31 @@ | ||
# Packaging klipper | ||
|
||
Klipper is somewhat of a packaging anomaly among python programs, as it doesn't | ||
use setuptools to build and install. Some notes regarding how best to package it | ||
are as follows: | ||
|
||
## C modules | ||
|
||
Klipper uses a C module to handle some kinematics calculations more quickly. | ||
This module needs to be compiled at packaging time to avoid introducing a | ||
runtime dependency on a compiler. To compile the C module, run `python2 | ||
klippy/chelper/__init__.py`. | ||
|
||
## Compiling python code | ||
|
||
Many distributions have a policy of compiling all python code before packaging | ||
to improve startup time. You can do this by running `python2 -m compileall | ||
klippy`. | ||
|
||
## Versioning | ||
|
||
If you are building a package of Klipper from git, it is usual practice not to | ||
ship a .git directory, so the versioning must be handled without git. To do | ||
this, use the script shipped in `scripts/make_version.py` which should be run as | ||
follows: `python2 scripts/make_version.py YOURDISTRONAME > klippy/.version`. | ||
|
||
## Sample packaging script | ||
|
||
klipper-git is packaged for Arch Linux, and has a PKGBUILD (package build | ||
script) available at | ||
https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=klipper-git. |
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,31 @@ | ||
#!/usr/bin/env python2 | ||
# Get the version number for klippy | ||
# | ||
# Copyright (C) 2018 Lucas Fink <[email protected]> | ||
# | ||
# This file may be distributed under the terms of the GNU GPLv3 license. | ||
|
||
from __future__ import print_function | ||
|
||
import argparse | ||
import os | ||
import sys | ||
|
||
sys.path.append(os.path.join(os.path.dirname(__file__), '../klippy')) | ||
|
||
import util | ||
|
||
|
||
def main(argv): | ||
p = argparse.ArgumentParser() | ||
p.add_argument( | ||
'distroname', | ||
help='Name of distro this package is intended for' | ||
) | ||
args = p.parse_args() | ||
print(util.get_git_version(from_file=False), | ||
args.distroname.replace(' ', ''), sep='-') | ||
|
||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1:]) |