Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

BLD Creates and test a source distribution #53

Merged
merged 23 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from 18 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
4 changes: 4 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ schedules:
- master
always: true

variables:
BUILD_COMMIT: "0.22.2.post1"

jobs:
- template: azure/posix-sdist.yml
- template: azure/windows.yml
parameters:
name: windows
Expand Down
130 changes: 130 additions & 0 deletions azure/posix-sdist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
jobs:
- job: Linux_Source_Dist
pool:
vmImage: ubuntu-16.04
variables:
NIGHTLY_BUILD_COMMIT: "master"
NIGHTLY_BUILD: "true"
JUNITXML: "test-data.xml"
TEST_DIR: "tmp_for_test"
TEST_VENV: "test_env"
MB_PYTHON_VERSION: "3.8"
steps:
- checkout: self
submodules: true
- task: UsePythonVersion@0
inputs:
versionSpec: $(MB_PYTHON_VERSION)
displayName: Set python version
- bash: |
set -e
SKIP_BUILD="false"
if [ "$BUILD_REASON" == "Schedule" ]; then
BUILD_COMMIT=$NIGHTLY_BUILD_COMMIT
if [ "$NIGHTLY_BUILD" != "true" ]; then
SKIP_BUILD="true"
fi
fi

echo "Building scikit-learn@$BUILD_COMMIT"
echo "##vso[task.setvariable variable=BUILD_COMMIT]$BUILD_COMMIT"
echo "##vso[task.setvariable variable=SKIP_BUILD]$SKIP_BUILD"
displayName: Define build env variables

- bash: |
set -e

python -m venv build_env
source build_env/bin/activate

# Need because setup.py enforces these to be installed
python -m pip install numpy scipy Cython

cd scikit-learn
git checkout $BUILD_COMMIT
python setup.py sdist
displayName: Create build venv with build dependices and build source dist

- bash: |
set -e

source build_env/bin/activate
python -m pip install twine

twine check scikit-learn/dist/*
displayName: Twine check
- bash: |
set -e

python -m venv $TEST_VENV
source $TEST_VENV/bin/activate
python --version
python -m pip install -U pip

# pyproject.toml will be released with >=0.23
if [[ "$BUILD_COMMIT" =~ ^0.22* ]]; then
python -m pip install Cython
fi

# Uses pep 517
pip install scikit-learn/dist/*.tar.gz
displayName: Create test venv and install using source dist

- bash: |
set -e
source $TEST_VENV/bin/activate

mkdir $TEST_DIR
cd $TEST_DIR

python -m pip install pytest
pytest -l --junitxml=$JUNITXML --pyargs sklearn
displayName: Runs tests

- task: PublishTestResults@2
inputs:
testResultsFiles: "$(TEST_DIR)/$(JUNITXML)"
testRunTitle: ${{ format('{0}-$(Agent.JobName)', 'Linux_Source_Dist') }}
displayName: "Publish Test Results"
condition: eq(variables['SKIP_BUILD'], 'false')

- bash: |
echo "##vso[task.prependpath]$CONDA/bin"
sudo chown -R $USER $CONDA
displayName: Add conda to PATH
condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'))

- bash: conda install -q -y anaconda-client
displayName: Install anaconda-client
condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'))

- bash: |
set -e
if [ "$BUILD_REASON" == "Schedule" ]; then
ANACONDA_ORG="scipy-wheels-nightly"
TOKEN="$SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN"
else
ANACONDA_ORG="scikit-learn-wheels-staging"
TOKEN="$SCIKIT_LEARN_STAGING_UPLOAD_TOKEN"
fi
if [ "$TOKEN" == "" ]; then
echo "##[warning] Could not find anaconda.org upload token in secret variables"
fi
echo "##vso[task.setvariable variable=TOKEN]$TOKEN"
echo "##vso[task.setvariable variable=ANACONDA_ORG]$ANACONDA_ORG"
displayName: Retrieve secret upload token
condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'))
env:
# Secret variables need to mapped to env variables explicitly:
SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN: $(SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN)
SCIKIT_LEARN_STAGING_UPLOAD_TOKEN: $(SCIKIT_LEARN_STAGING_UPLOAD_TOKEN)

- bash: |
set -e
# The --force option forces a replacement if the remote file already
# exists.
ls scikit-learn/dist/*.tar.gz
anaconda -t $TOKEN upload --force -u $ANACONDA_ORG scikit-learn/dist/*.tar.gz
echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"
displayName: Upload to anaconda.org (only if secret token is retrieved)
condition: ne(variables['TOKEN'], '')
Copy link
Collaborator

Choose a reason for hiding this comment

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

posix.xml just has condition: variables['TOKEN']

1 change: 0 additions & 1 deletion azure/posix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
vmImage: ${{ parameters.vmImage }}
variables:
REPO_DIR: "scikit-learn"
BUILD_COMMIT: "0.22.2.post1"
PLAT: "x86_64"
NP_BUILD_DEP: "numpy==1.11.0"
CYTHON_BUILD_DEP: "cython==0.29.14"
Expand Down
1 change: 0 additions & 1 deletion azure/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ jobs:
pool:
vmImage: ${{ parameters.vmImage }}
variables:
BUILD_COMMIT: "0.22.2.post1"
SKLEARN_SKIP_NETWORK_TESTS: "1"
NP_BUILD_DEP: "1.11.0"
CYTHON_BUILD_DEP: "0.29.14"
Expand Down