Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Wheels #988

Merged
merged 2 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
name: macOS

on:
push: {}

jobs:
build:
name: py-${{ matrix.py.ver }} libgit2-${{ matrix.libgit2}}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
libgit2: ['maint/v0.99']
py:
- ver: '3.6'
release: '3.6.8' # last Python.org binary release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR here's a way to select the concrete "patch" version intelligently: https://github.com/amol-/dukpy/blob/54699a3/.travis.yml#L56-L109

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I need to select the last version available as a binary release from Python.org, not the latest patch version though. I don’t understand why they’re not built automatically, but they’re not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, re-reading, it does that, yes! Not sure it’s a big deal for us atm - we’re not typically using cutting edge CPython features

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Sometimes they release 3.6.8 for Linux, but stop at 3.6.6 for macOS. so this is something that my script accounts for. But yes, it shouldn't matter much. OTOH when you do exit-checks after the build but before publishing the artifacts, it may make sense to run tests on the recent version.

/me needs to find time and contribute that to cimultibuild...

- ver: '3.7'
release: '3.7.7'
- ver: '3.8'
release: '3.8.2'
env:
HOMEBREW_CACHE: ${{ github.workspace }}/.cache/brew
CCACHE_DIR: ${{ github.workspace }}/.cache/ccache
CCACHE_COMPRESS: 1
PIP_CACHE_DIR: ${{ github.workspace }}/.cache/pip
steps:
- name: checkout pygit2
uses: actions/checkout@v2
with:
path: pygit2

- name: checkout libgit2
uses: actions/checkout@v2
with:
repository: libgit2/libgit2
path: libgit2
ref: ${{ matrix.libgit2 }}

- id: cache
uses: actions/[email protected]
with:
path: .cache
key: cache-libgit2.${{ matrix.libgit2 }}-py.${{ matrix.py.release }}
restore-keys: |
cache-

- name: setup python
run: |
mkdir -p .cache/python/ .cache/pip/
PKG="python-${{ matrix.py.release }}-macosx10.9.pkg"
URL="https://www.python.org/ftp/python/${{ matrix.py.release }}/$PKG"
wget --no-verbose -P .cache/python -N "$URL"
sudo installer -pkg ".cache/python/$PKG" -target /
export PATH=/Library/Frameworks/Python.framework/Versions/${{ matrix.py.ver }}/bin:$PATH
echo "::add-path::/Library/Frameworks/Python.framework/Versions/${{ matrix.py.ver }}/bin"
which python3
python3 -VV
test "$(python3 -V)" = "Python ${{ matrix.py.release }}"

- name: setup
run: |
mkdir -p .cache/brew/ .cache/ccache/
brew install ccache pkg-config
python3 -m venv venv/
echo "::add-path::${{ github.workspace }}/venv/bin:/usr/local/opt/ccache/libexec"
venv/bin/pip3 install delocate pytest

- name: build libgit2
id: libgit2
working-directory: libgit2
env:
PKG_CONFIG_PATH: /dev/null
run: |
mkdir env/
cmake . \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/libgit2/env \
-DBUILD_EXAMPLES=NO \
-DBUILD_CLAR=NO \
-DUSE_SSH=NO
cmake --build . --target install
VERSION=$(PKG_CONFIG_PATH=$(pwd) pkg-config --modversion libgit2)
echo "::set-output name=version::$VERSION"

- name: build pygit2
id: pygit2
working-directory: pygit2
env:
LIBGIT2: "${{ github.workspace }}/libgit2/env"
LDFLAGS: "-Wl,-rpath,'${{ github.workspace }}/libgit2/env/lib'"
run: |
python3 setup.py bdist_wheel
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FTR the recommended way of doing this is something like pip wheel --no-deps -w dist .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same outcome though afaik?

delocate-listdeps dist/pygit2-*macosx*.whl
delocate-wheel -v -w dist/fixed-wheels/ dist/pygit2-*macosx*.whl
WHEEL=$(basename dist/fixed-wheels/*.whl)
echo "::set-output name=wheel::$WHEEL"
delocate-listdeps dist/fixed-wheels/$WHEEL

- name: pygit2 tests
working-directory: pygit2
run: |
mv pygit2 pygit2~
mv ../libgit2/env ../libgit2/env~
pip3 install dist/fixed-wheels/pygit2-*.whl
mkdir -p testresults/
pytest -v test/ --junitxml=testresults/testresults.xml

- name: save test results
uses: actions/upload-artifact@v1
if: always()
with:
name: "test-results-py_${{ matrix.py.ver }}-libgit2_${{ steps.libgit2.outputs.version }}"
path: pygit2/testresults/

- name: save wheel
uses: actions/upload-artifact@v1
with:
name: "macOS-wheel-py_${{ matrix.py.ver }}-libgit2_${{ steps.libgit2.outputs.version }}"
path: pygit2/dist/fixed-wheels/
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ implements Git plumbing. Pygit2 works with Python 3.5 - 3.8 and PyPy 3.5
.. image:: https://ci.appveyor.com/api/projects/status/edmwc0dctk5nacx0/branch/master?svg=true
:target: https://ci.appveyor.com/project/jdavid/pygit2/branch/master

.. image:: https://github.com/libgit2/pygit2/workflows/macOS/badge.svg
:target: https://github.com/libgit2/pygit2/actions?query=workflow%3AmacOS

Links
=====================================

Expand Down
2 changes: 1 addition & 1 deletion test/test_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ def _check_worktree(worktree):
# Confirm the name attribute matches the specified name
assert worktree.name == worktree_name
# Confirm the path attribute points to the correct path
assert os.path.realpath(worktree.path) == worktree_dir
assert os.path.realpath(worktree.path) == os.path.realpath(worktree_dir)
# The "gitdir" in a worktree should be a file with a reference to
# the actual gitdir. Let's make sure that the path exists and is a
# file.
Expand Down