Skip to content

Commit

Permalink
More tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Webb committed Apr 19, 2021
1 parent 1b70ac4 commit 7b62696
Show file tree
Hide file tree
Showing 10 changed files with 76 additions and 39 deletions.
4 changes: 1 addition & 3 deletions manylinux/docker-compose.yml → builder/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
services:
manylinux:
build:
context: .
context: ./manylinux
args:
ARCH: ${ARCH:-x86_64}
environment:
PLAT: manylinux1_${ARCH:-x86_64}
WHICH_PYTHON: ${WHICH_PYTHON:-cp36-cp36m}
volumes:
- ..:/mnt
tmpfs:
- /tmp,exec
3 changes: 3 additions & 0 deletions manylinux/Dockerfile → builder/manylinux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ RUN rpm --import https://repo.ius.io/RPM-GPG-KEY-IUS-7 && \
yum clean all

COPY build-wheel.sh /usr/bin/build-wheel.sh

VOLUME [ "/mnt", "/tmp" ]
WORKDIR /mnt
55 changes: 55 additions & 0 deletions builder/manylinux/build-wheel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
# Adapted from https://github.com/pypa/python-manylinux-demo/blob/master/travis/build-wheels.sh

set -euo pipefail

WHICH_PYTHON=${WHICH_PYTHON:-cp36-cp36m}

function repair_wheel {
wheel="$1"
if ! auditwheel show "$wheel"; then
echo "Skipping non-platform wheel $wheel"
else
auditwheel repair "$wheel" --plat "$PLAT" -w /build/fixedwheel/
fi
}

mkdir -p /build/sdist /build/source /build/wheel /build/fixedwheel

# Build and extract sdist
/opt/python/cp36-cp36m/bin/python3 setup.py sdist -d /build/sdist

find /build

sdist=$(find /build/sdist -name '*.tar.gz' | head -n1)

if [ -z "$sdist" ] ; then
echo "couldn't find sdist!" >&2
exit 1
fi

tar -C /build/source -xvf "$sdist"

# Install development requirements
"/opt/python/${WHICH_PYTHON}/bin/pip" install -r /mnt/requirements-dev.txt

# Compile wheel
"/opt/python/${WHICH_PYTHON}/bin/pip" wheel /build/source/"$(basename "$sdist" .tar.gz)" --no-deps -w /build/wheel

# Bundle external shared libraries into the wheels
for whl in /build/wheel/*.whl; do
repair_wheel "$whl"
done

# Install packages and test
cp /mnt/renameat2_test.py /bin/renameat2_test.py
"/opt/python/${WHICH_PYTHON}/bin/pip" install renameat2 --no-index -f /build/fixedwheel
cd / && "/opt/python/${WHICH_PYTHON}/bin/python3" -m pytest /bin/renameat2_test.py

mnt_uid=$(stat -c '%u' /mnt)
mnt_gid=$(stat -c '%g' /mnt)

# Copy tested wheel over to dist
mkdir -p /mnt/dist
cp /build/fixedwheel/*.whl /mnt/dist
chown -R "$mnt_uid:$mnt_gid" /mnt/dist
3 changes: 3 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
#
import os
import sys
from importlib.metadata import version

sys.path.insert(0, os.path.abspath(".."))

release = version("renameat2")
version = ".".join(release.split(".")[:2])

# -- Project information -----------------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ except OSError as e:

## "Whiteout" a file

I'm not entirely sure why you'd need to do this, but I felt bad leaving it out of the API.

```python
from renameat2 import rename

Expand Down
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
examples.md
renameat2.rst


Indices and tables
==================

Expand Down
6 changes: 6 additions & 0 deletions docs/renameat2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ API documentation

.. automodule:: renameat2
:members:

.. toctree::
:maxdepth: 2
:caption: Contents:

examples.md
32 changes: 0 additions & 32 deletions manylinux/build-wheel.sh

This file was deleted.

4 changes: 2 additions & 2 deletions renameat2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
The most likely reason you might want to use renameat2 is to atomically swap
two files; the :func:`exchange` function is for you.
If you just want to rename things with more control than `os.rename`, and/or
possibly do some weird overlayfs stuff, check out :func:`rename`.
If you just want to rename things with more control than :py:func:`os.rename`,
and/or possibly do some weird overlayfs stuff, check out :func:`rename`.
Finally, if you really just like the interface of renameat2 as it's implemented
in the system call, :func:`renameat2` recreates it in Python.
Expand Down
5 changes: 4 additions & 1 deletion renameat2_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def test_rename_whiteout():
with open(orange_path, "w") as apple_out:
apple_out.write("orange")

renameat2.rename(apple_path, orange_path, whiteout=True)
try:
renameat2.rename(apple_path, orange_path, whiteout=True)
except:
raise RuntimeError(f"apple_path = {apple_path} orange_path = {orange_path}")

assert apple_path.is_char_device()

Expand Down

0 comments on commit 7b62696

Please sign in to comment.