Skip to content

Commit

Permalink
Merge pull request #747 from Backblaze/linux-static
Browse files Browse the repository at this point in the history
Static binary for Linux
  • Loading branch information
mlech-reef committed Sep 12, 2021
2 parents 99cd2f3 + 8820f17 commit 2cf782e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-16.04, macos-10.15, windows-2019]
os: [ubuntu-latest, macos-10.15, windows-2019]
steps:
- uses: actions/checkout@v2
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-16.04, macos-10.15, windows-2019]
os: [ubuntu-latest, macos-10.15, windows-2019]
steps:
- uses: actions/checkout@v2
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
* Download instruction in README.md (wording suggested by https://github.com/philh7456)
* Make Linux binary statically linked

## [3.0.1] - 2021-08-09

Expand Down
17 changes: 12 additions & 5 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@

PY_PATHS = ['b2', 'test', 'noxfile.py', 'setup.py']

SYSTEM = platform.system().lower()

REQUIREMENTS_FORMAT = ['yapf==0.27']
REQUIREMENTS_LINT = ['yapf==0.27', 'pyflakes==2.2.0', 'pytest==6.1.1', 'liccheck==0.4.7']
REQUIREMENTS_TEST = ['pytest==6.1.1', 'pytest-cov==2.10.1']
REQUIREMENTS_BUILD = ['setuptools>=20.2']
REQUIREMENTS_BUNDLE = ['pyinstaller']
if SYSTEM == 'linux':
REQUIREMENTS_BUNDLE.extend(['patchelf-wrapper', 'staticx'])

OSX_BUNDLE_IDENTIFIER = 'com.backblaze.b2'
OSX_BUNDLE_ENTITLEMENTS = 'contrib/macos/entitlements.plist'
Expand Down Expand Up @@ -177,24 +182,26 @@ def build(session):
@nox.session(python=PYTHON_DEFAULT_VERSION)
def bundle(session):
"""Bundle the distribution."""
session.install('pyinstaller')
session.install(*REQUIREMENTS_BUNDLE)
session.run('rm', '-rf', 'build', 'dist', 'b2.egg-info', external=True)
install_myself(session)

system = platform.system().lower()

if system == 'darwin':
if SYSTEM == 'darwin':
session.posargs.extend(['--osx-bundle-identifier', OSX_BUNDLE_IDENTIFIER])

session.run('pyinstaller', '--onefile', *session.posargs, 'b2.spec')

if SYSTEM == 'linux':
session.run('staticx', '--no-compress', '--loglevel', 'INFO', 'dist/b2', 'dist/b2-static')
session.run('mv', '-f', 'dist/b2-static', 'dist/b2', external=True)

# Set outputs for GitHub Actions
if CI:
asset_path = glob('dist/*')[0]
print('::set-output name=asset_path::', asset_path, sep='')

name, ext = os.path.splitext(os.path.basename(asset_path))
asset_name = '{}-{}{}'.format(name, system, ext)
asset_name = '{}-{}{}'.format(name, SYSTEM, ext)
print('::set-output name=asset_name::', asset_name, sep='')


Expand Down

0 comments on commit 2cf782e

Please sign in to comment.