Fix installing in 'venv' and datetime tests on Windows (#472)

* Add failing test

* Complete formatting

* Fix commands execution

* Fix commands execution for Linux

* Extract virtual environment creation/removing into separate functions

* Complete error messages

* Complete examples building

* Use 'venv' independent path

* Call script by dotted path instead of 'source' call

* Add Travis CI script

* Rename variable: 'exec_prefix' -> 'base_prefix'

* Add AppVeyor script

* Remove Rust test

* Complete shell script mode

* Complete path to powershell script

* Use 'pushd'/'popd' instead of 'cd'

* Complete powershell script

* Complete shell script

* Fix setup

* Use 'tox-venv' plugin for 'venv' stdlib module support

* Remove additional 'venv' testing

* Use global environment instead of calling 'set'

* Use 'tox' for AppVeyor, extract commands into 'setup' & 'test' scripts

* Add updating of 'pip' & 'setuptools'

* Add moving in/back from examples directories

* Complete 'pip'/'setuptools' updating

* Complete requirements

* Complete 'word-count' example configuration

* Simplify 'setup' script

* Complete 'rustapi_module' example tests

* Revert formatting

* Complete examples configuration

* Remove redundant annotations

* Add entry in changelog
This commit is contained in:
Azat Ibrakov 2019-05-12 16:20:17 +03:00 committed by Yuji Kanagawa
parent eeeee236fd
commit 134c129edc
12 changed files with 74 additions and 22 deletions

View File

@ -49,7 +49,7 @@ before_install:
- source ./ci/travis/setup.sh
install:
- pip install setuptools-rust pytest pytest-benchmark tox
- pip install setuptools-rust pytest pytest-benchmark tox tox-venv
script:
- ./ci/travis/test.sh

View File

@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* Fixed issues with `pymethods` crashing on doc comments containing double quotes.
* `PySet::new` and `PyFrozenSet::new` now return `PyResult<&Py[Frozen]Set>`; exceptions are raised if
the items are not hashable.
* Fixed building using `venv` on Windows.
## [0.6.0] - 2018-03-28

View File

@ -1,25 +1,24 @@
version: 0.2.{build}
environment:
TARGET: x86_64-pc-windows-msvc
RUST_BACKTRACE: 1
matrix:
- PYTHON: "C:/Python35-x64"
- PYTHON: "C:/Python36-x64"
install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "python --version"
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.msi"
- start /wait msiexec /i rust-nightly-%TARGET%.msi INSTALLDIR="%CD%\rust-nightly-%TARGET%" /quiet /qn /norestart
- python -V
- ps: .\ci\appveyor\setup.ps1
- call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall.bat" amd64
- set PATH=%PATH%;%CD%/rust-nightly-%TARGET%/bin
- rustc -V
- cargo -V
- set RUST_BACKTRACE=1
build_script:
- cargo build --verbose
before_test:
- python -m pip install -U pip setuptools
- pip install setuptools-rust pytest pytest-benchmark tox tox-venv
test_script:
- cargo test --verbose
- pip install setuptools-rust pytest pytest-benchmark
- cd examples/word-count && python setup.py install && pytest -v tests
- ps: .\ci\appveyor\test.ps1

View File

@ -503,7 +503,7 @@ if PYPY:
else:
print(sysconfig.get_config_var('Py_ENABLE_SHARED'))
print(sysconfig.get_config_var('LDVERSION') or sysconfig.get_config_var('py_version_short'))
print(sys.exec_prefix)
print(sys.base_prefix)
print(platform.python_implementation())
"#;
let out = run_python_script(interpreter, script)?;
@ -531,10 +531,10 @@ fn configure(interpreter_version: &PythonVersion, lines: Vec<String>) -> Result<
interpreter_version
));
let libpath: &str = &lines[1];
let enable_shared: &str = &lines[2];
let ld_version: &str = &lines[3];
let exec_prefix: &str = &lines[4];
let libpath = &lines[1];
let enable_shared = &lines[2];
let ld_version = &lines[3];
let base_prefix = &lines[4];
let is_extension_module = env::var_os("CARGO_FEATURE_EXTENSION_MODULE").is_some();
if !is_extension_module || cfg!(target_os = "windows") {
@ -545,7 +545,7 @@ fn configure(interpreter_version: &PythonVersion, lines: Vec<String>) -> Result<
if libpath != "None" {
println!("cargo:rustc-link-search=native={}", libpath);
} else if cfg!(target_os = "windows") {
println!("cargo:rustc-link-search=native={}\\libs", exec_prefix);
println!("cargo:rustc-link-search=native={}\\libs", base_prefix);
}
}

8
ci/appveyor/setup.ps1 Normal file
View File

@ -0,0 +1,8 @@
$env:PATH="$env:PYTHON;$env:PYTHON\\Scripts;$env:PATH"
Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.msi"
Start-Process -FilePath "msiexec.exe" -ArgumentList "/i rust-nightly-$env:TARGET.msi INSTALLDIR=`"$((Get-Location).Path)\rust-nightly-$env:TARGET`" /quiet /qn /norestart" -Wait
$env:PATH="$env:PATH;$((Get-Location).Path)/rust-nightly-$env:TARGET/bin"
$pythonLocation = Invoke-Expression "python -c `"import sys; print(sys.base_prefix)`""
$env:LIBPATH = "$env:LIBPATH; $( Join-Path $pythonLocation "libs" )"

22
ci/appveyor/test.ps1 Normal file
View File

@ -0,0 +1,22 @@
Set-PSDebug -trace 2
function Invoke-Call
{
param ([scriptblock]$ScriptBlock)
& @ScriptBlock
if ($LastExitCode -ne 0)
{
exit $LastExitCode
}
}
Invoke-Call { cargo test --verbose }
$examplesDirectory = "examples"
foreach ($example in Get-ChildItem $examplesDirectory)
{
Push-Location $( Join-Path $examplesDirectory $example )
Invoke-Call { tox -c "tox.ini" -e py }
Pop-Location
}

View File

@ -16,9 +16,11 @@ if [ "$TRAVIS_JOB_NAME" = "Minimum nightly" ]; then
fi
for example_dir in examples/*; do
cd $example_dir
if [[ $FEATURES == *"pypy"* ]]; then
tox -c "$example_dir/tox.ini" -e pypy3
tox -c "tox.ini" -e pypy3
else
tox -c "$example_dir/tox.ini" -e py
tox -c "tox.ini" -e py
fi
cd -
done

View File

@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools_rust>=0.10.2", "toml"]
requires = ["setuptools>=41.0.0", "wheel", "setuptools_rust>=0.10.2", "toml"]
build-backend = "setuptools.build_meta"

View File

@ -1,3 +1,4 @@
pip>=19.1
hypothesis>=3.55
pytest>=3.5.0
setuptools-rust>=0.10.2

View File

@ -45,6 +45,22 @@ except Exception:
MAX_MICROSECONDS = int(pdt.timedelta.max.total_seconds() * 1e6)
MIN_MICROSECONDS = int(pdt.timedelta.min.total_seconds() * 1e6)
IS_X86 = platform.architecture()[0] == '32bit'
IS_WINDOWS = sys.platform == 'win32'
if IS_WINDOWS:
if IS_X86:
MIN_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(86400)
MAX_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(32536789199)
else:
MIN_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(0)
MAX_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(32536799999)
else:
if IS_X86:
MIN_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(-2147483648)
MAX_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(2147483647)
else:
MIN_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(-62135510400)
MAX_DATETIME_FROM_TIMESTAMP = pdt.datetime.fromtimestamp(253402300799)
PYPY = platform.python_implementation() == "PyPy"
HAS_FOLD = getattr(pdt.datetime, "fold", False)
@ -83,7 +99,8 @@ def test_invalid_date_fails():
rdt.make_date(2017, 2, 30)
@given(d=st.dates())
@given(d=st.dates(MIN_DATETIME_FROM_TIMESTAMP.date(),
MAX_DATETIME_FROM_TIMESTAMP.date()))
def test_date_from_timestamp(d):
if PYPY and d < pdt.date(1900, 1, 1):
pytest.xfail("get_timestamp will raise on PyPy with dates before 1900")
@ -222,7 +239,8 @@ def test_datetime_typeerror():
rdt.make_datetime("2011", 1, 1, 0, 0, 0, 0)
@given(dt=st.datetimes())
@given(dt=st.datetimes(MIN_DATETIME_FROM_TIMESTAMP,
MAX_DATETIME_FROM_TIMESTAMP))
def test_datetime_from_timestamp(dt):
if PYPY and dt < pdt.datetime(1900, 1, 1):
pytest.xfail("get_timestamp will raise on PyPy with dates before 1900")

View File

@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools-rust", "toml"]
requires = ["setuptools>=41.0.0", "wheel", "setuptools_rust>=0.10.2", "toml"]
build-backend = "setuptools.build_meta"

View File

@ -1,3 +1,4 @@
pip>=19.1
pytest>=3.5.0
setuptools-rust>=0.10.2
pytest-benchmark>=3.1.1