mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 07:18:31 +01:00
Merge pull request #1148 from efiop/master
Build osx packages on older versions
This commit is contained in:
+7
-7
@@ -16,9 +16,13 @@ python:
|
||||
# version, that causes fpm to crash.
|
||||
matrix:
|
||||
include:
|
||||
# 3.7 needs Xenial image because of https://github.com/travis-ci/travis-ci/issues/9069
|
||||
- python: "3.7"
|
||||
dist: xenial
|
||||
sudo: true
|
||||
- if: type = cron OR tag is present
|
||||
os: osx
|
||||
osx_image: xcode9.3
|
||||
osx_image: xcode7.3
|
||||
language: ruby
|
||||
rvm: 2.4.0
|
||||
env:
|
||||
@@ -27,7 +31,7 @@ matrix:
|
||||
- PATH="$PYENV_ROOT/bin:$PATH"
|
||||
- if: type = cron OR tag is present
|
||||
os: osx
|
||||
osx_image: xcode9.3
|
||||
osx_image: xcode7.3
|
||||
language: ruby
|
||||
rvm: 2.4.0
|
||||
env:
|
||||
@@ -36,17 +40,13 @@ matrix:
|
||||
- PATH="$PYENV_ROOT/bin:$PATH"
|
||||
- if: type = cron OR tag is present
|
||||
os: osx
|
||||
osx_image: xcode9.3
|
||||
osx_image: xcode7.3
|
||||
language: ruby
|
||||
rvm: 2.4.0
|
||||
env:
|
||||
- PYTHON_VER=3.5.0
|
||||
- PYENV_ROOT="$HOME/.pyenv"
|
||||
- PATH="$PYENV_ROOT/bin:$PATH"
|
||||
# 3.7 needs Xenial image because of https://github.com/travis-ci/travis-ci/issues/9069
|
||||
- python: "3.7"
|
||||
dist: xenial
|
||||
sudo: true
|
||||
before_install:
|
||||
- bash ./scripts/ci/before_install.sh
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import platform
|
||||
from cffi import FFI
|
||||
|
||||
|
||||
WINDOWS_SRC = """
|
||||
int reflink(char *src, char *dst)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
"""
|
||||
|
||||
DARWIN_SRC = """
|
||||
#include <AvailabilityMacros.h>
|
||||
/* NOTE: sys/clonefile.h is available since OS X 10.12 */
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
|
||||
#include <sys/clonefile.h> /* for clonefile(2) */
|
||||
#include <errno.h>
|
||||
int reflink(char *src, char *dst)
|
||||
{
|
||||
return clonefile(src, dst, 0);
|
||||
}
|
||||
#else
|
||||
int reflink(char *src, char *dst)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
"""
|
||||
|
||||
LINUX_SRC = """
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <linux/fs.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
int reflink(char *src, char *dst)
|
||||
{
|
||||
int ret = -1;
|
||||
#ifdef FICLONE
|
||||
int src_fd = -1;
|
||||
int dst_fd = -1;
|
||||
|
||||
src_fd = open(src, O_RDONLY);
|
||||
if (src_fd < 0)
|
||||
return ret;
|
||||
|
||||
dst_fd = open(dst, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
|
||||
if (src_fd < 0) {
|
||||
close(src_fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = ioctl(dst_fd, FICLONE, src_fd);
|
||||
if (ret != 0)
|
||||
unlink(dst);
|
||||
|
||||
out:
|
||||
if (src_fd >= 0)
|
||||
close(src_fd);
|
||||
if (dst_fd >= 0)
|
||||
close(dst_fd);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
"""
|
||||
|
||||
ffibuilder = FFI()
|
||||
|
||||
ffibuilder.cdef("""
|
||||
int reflink(char *src, char *dst);
|
||||
""")
|
||||
|
||||
system = platform.system()
|
||||
if system == 'Windows':
|
||||
src = WINDOWS_SRC
|
||||
elif system == 'Linux':
|
||||
src = LINUX_SRC
|
||||
elif system == 'Darwin':
|
||||
src = DARWIN_SRC
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
ffibuilder.set_source("reflink", src)
|
||||
|
||||
if __file__ == '__main__':
|
||||
ffibuilder.compile(verbose=True)
|
||||
+9
-2
@@ -1,6 +1,5 @@
|
||||
import os
|
||||
import ctypes
|
||||
import reflink
|
||||
|
||||
if os.name == 'nt':
|
||||
import ntfsutils.hardlink as winlink
|
||||
@@ -36,7 +35,15 @@ class System(object):
|
||||
|
||||
@staticmethod
|
||||
def reflink(source, link_name):
|
||||
return reflink.reflink(source, link_name)
|
||||
from dvc.reflink import reflink
|
||||
from dvc.exceptions import DvcException
|
||||
|
||||
ret = reflink(source, link_name)
|
||||
if ret != 0:
|
||||
raise DvcException("Failed to reflink '{}' -> '{}' returned "
|
||||
"non-zero code '{}'".format(source,
|
||||
link_name,
|
||||
ret))
|
||||
|
||||
# FIXME
|
||||
# Temporary fix while waiting for the PR to be merged and released:
|
||||
|
||||
+1
-1
@@ -18,9 +18,9 @@ pyasn1>=0.4.1
|
||||
schema>=0.6.7
|
||||
paramiko>=2.4.1
|
||||
jsonpath-rw==1.4.0
|
||||
reflink==0.2.0
|
||||
requests>=2.18.4
|
||||
wheel>=0.31.1
|
||||
futures>=3.2.0; python_version == "2.7"
|
||||
grandalf==0.6
|
||||
asciicanvas==0.0.3
|
||||
cffi
|
||||
|
||||
Reference in New Issue
Block a user