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

Commit b66b691

Browse files
authored
BLD Creates and test a source distribution
2 parents 1ae7842 + 8a93a6d commit b66b691

File tree

4 files changed

+132
-2
lines changed

4 files changed

+132
-2
lines changed

azure-pipelines.yml

+2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ schedules:
88
always: true
99

1010
variables:
11+
BUILD_COMMIT: "0.23.0rc1"
1112
MANYLINUX_URL: "https://pypi.python.org/simple"
1213

1314
jobs:
15+
- template: azure/posix-sdist.yml
1416
- template: azure/windows.yml
1517
parameters:
1618
name: windows

azure/posix-sdist.yml

+130
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
jobs:
2+
- job: Linux_Source_Dist
3+
pool:
4+
vmImage: ubuntu-16.04
5+
variables:
6+
NIGHTLY_BUILD_COMMIT: "master"
7+
NIGHTLY_BUILD: "true"
8+
JUNITXML: "test-data.xml"
9+
TEST_DIR: "tmp_for_test"
10+
TEST_VENV: "test_env"
11+
MB_PYTHON_VERSION: "3.8"
12+
steps:
13+
- checkout: self
14+
submodules: true
15+
- task: UsePythonVersion@0
16+
inputs:
17+
versionSpec: $(MB_PYTHON_VERSION)
18+
displayName: Set python version
19+
- bash: |
20+
set -e
21+
SKIP_BUILD="false"
22+
if [ "$BUILD_REASON" == "Schedule" ]; then
23+
BUILD_COMMIT=$NIGHTLY_BUILD_COMMIT
24+
if [ "$NIGHTLY_BUILD" != "true" ]; then
25+
SKIP_BUILD="true"
26+
fi
27+
fi
28+
29+
echo "Building scikit-learn@$BUILD_COMMIT"
30+
echo "##vso[task.setvariable variable=BUILD_COMMIT]$BUILD_COMMIT"
31+
echo "##vso[task.setvariable variable=SKIP_BUILD]$SKIP_BUILD"
32+
displayName: Define build env variables
33+
34+
- bash: |
35+
set -e
36+
37+
python -m venv build_env
38+
source build_env/bin/activate
39+
40+
# Need because setup.py enforces these to be installed
41+
python -m pip install numpy scipy Cython
42+
43+
cd scikit-learn
44+
git checkout $BUILD_COMMIT
45+
python setup.py sdist
46+
displayName: Create build venv with build dependices and build source dist
47+
48+
- bash: |
49+
set -e
50+
51+
source build_env/bin/activate
52+
python -m pip install twine
53+
54+
twine check scikit-learn/dist/*
55+
displayName: Twine check
56+
- bash: |
57+
set -e
58+
59+
python -m venv $TEST_VENV
60+
source $TEST_VENV/bin/activate
61+
python --version
62+
python -m pip install -U pip
63+
64+
# pyproject.toml will be released with >=0.23
65+
if [[ "$BUILD_COMMIT" =~ ^0.22* ]]; then
66+
python -m pip install Cython
67+
fi
68+
69+
# Uses pep 517
70+
pip install scikit-learn/dist/*.tar.gz
71+
displayName: Create test venv and install using source dist
72+
73+
- bash: |
74+
set -e
75+
source $TEST_VENV/bin/activate
76+
77+
mkdir $TEST_DIR
78+
cd $TEST_DIR
79+
80+
python -m pip install pytest
81+
pytest -l --junitxml=$JUNITXML --pyargs sklearn
82+
displayName: Runs tests
83+
84+
- task: PublishTestResults@2
85+
inputs:
86+
testResultsFiles: "$(TEST_DIR)/$(JUNITXML)"
87+
testRunTitle: ${{ format('{0}-$(Agent.JobName)', 'Linux_Source_Dist') }}
88+
displayName: "Publish Test Results"
89+
condition: eq(variables['SKIP_BUILD'], 'false')
90+
91+
- bash: |
92+
set -e
93+
if [ "$BUILD_REASON" == "Schedule" ]; then
94+
ANACONDA_ORG="scipy-wheels-nightly"
95+
TOKEN="$SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN"
96+
else
97+
ANACONDA_ORG="scikit-learn-wheels-staging"
98+
TOKEN="$SCIKIT_LEARN_STAGING_UPLOAD_TOKEN"
99+
fi
100+
if [ "$TOKEN" == "" ]; then
101+
echo "##[warning] Could not find anaconda.org upload token in secret variables"
102+
fi
103+
echo "##vso[task.setvariable variable=TOKEN]$TOKEN"
104+
echo "##vso[task.setvariable variable=ANACONDA_ORG]$ANACONDA_ORG"
105+
displayName: Retrieve secret upload token
106+
condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'), variables['SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN'], variables['SCIKIT_LEARN_STAGING_UPLOAD_TOKEN'])
107+
env:
108+
# Secret variables need to mapped to env variables explicitly:
109+
SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN: $(SCIKIT_LEARN_NIGHTLY_UPLOAD_TOKEN)
110+
SCIKIT_LEARN_STAGING_UPLOAD_TOKEN: $(SCIKIT_LEARN_STAGING_UPLOAD_TOKEN)
111+
112+
- bash: |
113+
echo "##vso[task.prependpath]$CONDA/bin"
114+
sudo chown -R $USER $CONDA
115+
displayName: Add conda to PATH
116+
condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'), variables['TOKEN'])
117+
118+
- bash: conda install -q -y anaconda-client
119+
displayName: Install anaconda-client
120+
condition: and(succeeded(), eq(variables['SKIP_BUILD'], 'false'), ne(variables['Build.Reason'], 'PullRequest'), variables['TOKEN'])
121+
122+
- bash: |
123+
set -e
124+
# The --force option forces a replacement if the remote file already
125+
# exists.
126+
ls scikit-learn/dist/*.tar.gz
127+
anaconda -t $TOKEN upload --force -u $ANACONDA_ORG scikit-learn/dist/*.tar.gz
128+
echo "PyPI-style index: https://pypi.anaconda.org/$ANACONDA_ORG/simple"
129+
displayName: Upload to anaconda.org (only if secret token is retrieved)
130+
condition: variables['TOKEN']

azure/posix.yml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ jobs:
99
vmImage: ${{ parameters.vmImage }}
1010
variables:
1111
REPO_DIR: "scikit-learn"
12-
BUILD_COMMIT: "0.23.0rc1"
1312
PLAT: "x86_64"
1413
NP_BUILD_DEP: "numpy==1.13.3"
1514
CYTHON_BUILD_DEP: "cython==0.29.14"

azure/windows.yml

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ jobs:
88
pool:
99
vmImage: ${{ parameters.vmImage }}
1010
variables:
11-
BUILD_COMMIT: "0.23.0rc1"
1211
SKLEARN_SKIP_NETWORK_TESTS: "1"
1312
NP_BUILD_DEP: "1.13.3"
1413
CYTHON_BUILD_DEP: "0.29.14"

0 commit comments

Comments
 (0)