Skip to content

Commit

Permalink
Build fixup
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Ballance <[email protected]>
  • Loading branch information
mballance committed Jul 25, 2024
1 parent 2213925 commit cf9b364
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 30 deletions.
49 changes: 19 additions & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ on:
jobs:
linux:
runs-on: 'ubuntu-latest'
container: quay.io/pypa/manylinux2014_x86_64
strategy:
matrix:
include:
Expand All @@ -18,38 +17,28 @@ jobs:
- pyversion: 'cp311-cp311'
- pyversion: 'cp312-cp312'
steps:
- uses: actions/checkout@v2
- name: Fetch python build dependencies
run: |
yum update -y
yum install -y glibc-static
yum install -y java-11-openjdk-devel uuid-devel libuuid-devel
py=${{ matrix.pyversion }}
/opt/python/${py}/bin/python -m pip install ivpm
- name: Fetch source dependencies
run: |
py=${{ matrix.pyversion }}
/opt/python/$py/bin/python -m ivpm update -a
./packages/python/bin/python -m pip install ninja wheel cython ivpm twine auditwheel
ls packages/python/bin
- uses: actions/checkout@v4
- name: Build packages
run: |
echo "BUILD_NUM=$GITHUB_RUN_ID" >> python/debug_mgr/__build_num__.py
./packages/python/bin/python setup.py bdist_wheel
- name: Audit Wheels
run: |
export LD_LIBRARY_PATH=`pwd`/build/lib:`pwd`/build/lib64
for whl in dist/*.whl; do
./packages/python/bin/auditwheel -v repair $whl
rm $whl
done
cp wheelhouse/*.whl dist
env:
IVPM_PYTHON: /opt/python/${{ matrix.pyversion }}/bin/python
BUILD_NUM: ${{ github.run_id }}
run: >
docker run --rm
--volume "$(pwd):/io"
--env IVPM_PYTHON
--env BUILD_NUM
--workdir /io
quay.io/pypa/manylinux2014_x86_64
/io/scripts/build_linux.sh
- name: Publish to PyPi
if: startsWith(github.ref, 'refs/heads/main')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python3 -m pip install twine
python3 -m twine upload wheelhouse/*.whl
macos:
runs-on: macos-latest
Expand Down
14 changes: 14 additions & 0 deletions scripts/build_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh -x

echo "BUILD_NUM=${BUILD_NUM}" >> python/debug_mgr/__build_num__.py
${IVPM_PYTHON} -m pip install ivpm cython
${IVPM_PYTHON} -m ivpm update -a

PYTHON=./packages/python/bin/python
${PYTHON} -m pip install twine auditwheel ninja wheel cython
${PYTHON} setup.py bdist_wheel

for whl in dist/*.whl; do
${PYTHON} -m auditwheel repair $whl
rm $whl
done
61 changes: 61 additions & 0 deletions scripts/gen_ast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import os
import sys
import platform
import subprocess

def main():
scripts_dir = os.path.dirname(os.path.abspath(__file__))
proj_dir = os.path.dirname(scripts_dir)

if os.path.isdir(os.path.join(proj_dir, "packages")):
packages_dir = os.path.join(proj_dir, "packages")
else:
packages_dir = os.path.dirname(proj_dir)

print("proj_dir: %s" % str(proj_dir), flush=True)
print("packages_dir: %s" % str(packages_dir), flush=True)

sys.path.insert(0, os.path.join(packages_dir, "pyastbuilder", "src"))

print("PYTHONPATH: %s" % str(sys.path), flush=True)

env = os.environ.copy()
ps = ";" if platform.system() == "Windows" else ":"
env["PYTHONPATH"] = ps.join(sys.path)

try:
import astbuilder
except ImportError as e:
print("Failed to import astbuilder: %s" % str(e))

cmd = [sys.executable, "-m", "astbuilder", "gen-cpp", "-name", "ast"]
cmd.extend(["-namespace", "zsp::ast", "-astdir", os.path.join(proj_dir, "ast")])
cmd.extend(["-license", os.path.join(proj_dir, "etc", "copyright.cpp")])

result = subprocess.run(
cmd,
stderr=subprocess.STDOUT,
stdout=sys.stdout,
env=env)
if result.returncode != 0:
raise Exception("Failed to run gen-cpp")

cmd = [sys.executable, "-m", "astbuilder", "gen-pyext", "-name", "ast"]
cmd.extend(["-namespace", "zsp::ast", "-astdir", os.path.join(proj_dir, "ast")])
cmd.extend(["-package", "zsp_parser.ast", "-o", "../ext"])

result = subprocess.run(
cmd,
stderr=subprocess.STDOUT,
stdout=sys.stdout,
env=env)
if result.returncode != 0:
raise Exception("Failed to run gen-cpp")

# ${PYTHON} -m astbuilder gen-cpp -name ast -namespace zsp::ast -astdir ${CMAKE_CURRENT_SOURCE_DIR}/ast -license ${CMAKE_CURRENT_SOURCE_DIR}/etc/copyright.cpp &&
# ${PYTHON} -m astbuilder gen-pyext -name ast -namespace zsp::ast -package zsp_parser.ast -astdir ${CMAKE_CURRENT_SOURCE_DIR}/ast -o ../ext
pass

if __name__ == "__main__":
main()

0 comments on commit cf9b364

Please sign in to comment.