Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MRG+2] Fix conda deployments #300

Merged
merged 69 commits into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
6542e48
Use git url
aaronreidsmith Feb 14, 2020
1e68d97
Change windows
aaronreidsmith Feb 14, 2020
9040f5b
Remove extra curly brace
aaronreidsmith Feb 14, 2020
7a0be70
Temp changes for local testing
aaronreidsmith Feb 15, 2020
b062293
Specify python version
aaronreidsmith Feb 15, 2020
3407392
Use curly braces...
aaronreidsmith Feb 15, 2020
aa99a58
Add root path back
aaronreidsmith Feb 15, 2020
06ae23f
Add string back
aaronreidsmith Feb 15, 2020
d32b9b4
Add check step
aaronreidsmith Feb 15, 2020
2519b0a
Activate env
aaronreidsmith Feb 15, 2020
476f874
Update string
aaronreidsmith Feb 15, 2020
18c430e
Try double quotes
aaronreidsmith Feb 15, 2020
12ca1c6
Add echo
aaronreidsmith Feb 15, 2020
3bdf928
Try adding ls to mac
aaronreidsmith Feb 15, 2020
646c189
Change gitignore
aaronreidsmith Feb 15, 2020
7021c64
Try bld files?
aaronreidsmith Feb 15, 2020
3b1fd2f
Try removing ignore installed
aaronreidsmith Feb 15, 2020
09bdd8c
Use double quotes
aaronreidsmith Feb 17, 2020
16036ba
Update Conda
aaronreidsmith Feb 17, 2020
dcca62d
Add yes flag
aaronreidsmith Feb 17, 2020
df67651
Add it on mac build too...
aaronreidsmith Feb 17, 2020
e82cd68
Try dollar python
aaronreidsmith Feb 17, 2020
dccd5b4
Try dollar prefix
aaronreidsmith Feb 17, 2020
bcfbebf
Revert previous change
aaronreidsmith Feb 17, 2020
ef3f4dd
Try setup.py
aaronreidsmith Feb 17, 2020
cf52a44
Remove preprocessing on mac
aaronreidsmith Feb 17, 2020
f530062
Try setting INLCUDE and LIBRARY paths
aaronreidsmith Feb 17, 2020
95c111e
Consolidate a bunch of stuff
aaronreidsmith Feb 17, 2020
479d381
Try bld.sh
aaronreidsmith Feb 17, 2020
6be4364
Added echo statements
aaronreidsmith Feb 17, 2020
2fb05e6
Apparently it is build.sh
aaronreidsmith Feb 17, 2020
c308a78
Install dependencies
aaronreidsmith Feb 17, 2020
1fe3ed4
Try dollar python
aaronreidsmith Feb 17, 2020
32ce1b3
Add cat step
aaronreidsmith Feb 17, 2020
cc0ca76
Try removing stuff from build section
aaronreidsmith Feb 17, 2020
84033fa
Add conda render step
aaronreidsmith Feb 17, 2020
37a3faf
Use conda's versioning
aaronreidsmith Feb 17, 2020
d4ab79a
Fix render_meta
aaronreidsmith Feb 17, 2020
668d097
Try overwriting?
aaronreidsmith Feb 17, 2020
594c4d1
Remove numpy from build section
aaronreidsmith Feb 17, 2020
95edd5d
Don't use dollar python
aaronreidsmith Feb 17, 2020
1094259
Add set flags
aaronreidsmith Feb 17, 2020
da053d2
Don't use build.sh
aaronreidsmith Feb 17, 2020
8a46ede
Make build env before building...
aaronreidsmith Feb 17, 2020
5ac50d0
Try source activate
aaronreidsmith Feb 17, 2020
f124262
Try isntalling twice?
aaronreidsmith Feb 17, 2020
7e8f374
Bring windows back
aaronreidsmith Feb 17, 2020
4a9ec3f
Don't activate on unix for some reason
aaronreidsmith Feb 17, 2020
a15fcfd
Add comment
aaronreidsmith Feb 17, 2020
f51a814
Remove activate on windows
aaronreidsmith Feb 17, 2020
d906371
Try conda-build
aaronreidsmith Feb 17, 2020
3aa0a82
Add check for lib on unix
aaronreidsmith Feb 17, 2020
2f3c19e
Fix check for lib
aaronreidsmith Feb 17, 2020
8c3ec24
Try fix windows
aaronreidsmith Feb 17, 2020
7e27634
Ditch lib check
aaronreidsmith Feb 17, 2020
651e321
Ensure VERSION is created before building
aaronreidsmith Feb 17, 2020
7972910
Clarifiying comment
aaronreidsmith Feb 17, 2020
de031d4
Add lib check back in
aaronreidsmith Feb 17, 2020
5a60d47
Remove brackets
aaronreidsmith Feb 17, 2020
f6296b7
Add lib check on all three platforms
aaronreidsmith Feb 17, 2020
ac4ba81
Fix deploy variable
aaronreidsmith Feb 17, 2020
85c296e
Fix for windows
aaronreidsmith Feb 17, 2020
2d13d0c
Try which
aaronreidsmith Feb 17, 2020
1d8959c
Try 7zip on windows
aaronreidsmith Feb 17, 2020
0d7380f
Use 7z instead of 7zip
aaronreidsmith Feb 17, 2020
77b211c
Try force-local
aaronreidsmith Feb 17, 2020
3943e9a
lib -> Lib
aaronreidsmith Feb 17, 2020
cd6b1ea
Ensure lib is created before deploying
aaronreidsmith Feb 17, 2020
e711cf6
Execute file, now that we have a previous step
aaronreidsmith Feb 17, 2020
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@ ENV/
VERSION

# Since we use a Jinja Template, we only want this to be created as build time
/conda/
meta.yaml
18 changes: 16 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ jobs:
architecture: '$(architecture)'
displayName: 'Setting Python version and system architecture'

- template: build_tools/azure/conda/linux.yml
- bash: echo "##vso[task.prependpath]$CONDA/bin"
displayName: 'Adding conda to PATH'

- template: build_tools/azure/conda/common.yml
- template: build_tools/azure/conda/unix.yml
- template: build_tools/azure/conda/deploy.yml

- job: Mac
Expand All @@ -75,7 +79,13 @@ jobs:
architecture: '$(architecture)'
displayName: 'Setting Python version and system architecture'

- template: build_tools/azure/conda/mac.yml
- bash: |
echo "##vso[task.prependpath]$CONDA/bin"
sudo chown -R $USER $CONDA
displayName: 'Adding conda to PATH'

- template: build_tools/azure/conda/common.yml
- template: build_tools/azure/conda/unix.yml
- template: build_tools/azure/conda/deploy.yml

- job: Windows
Expand All @@ -100,6 +110,10 @@ jobs:
architecture: '$(architecture)'
displayName: 'Setting Python version and system architecture'

- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: 'Adding conda to PATH'

- template: build_tools/azure/conda/common.yml
- template: build_tools/azure/conda/windows.yml
- template: build_tools/azure/conda/deploy.yml

Expand Down
21 changes: 21 additions & 0 deletions build_tools/azure/conda/common.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
steps:
- script: conda update conda --yes
displayName: 'Updating Conda'

- script: conda install python=$(python.version) --yes
displayName: 'Fixing conda Python version'

- script: conda install conda-build anaconda-client --yes
displayName: 'Installing conda-build and anaconda-client'

- bash: |
mkdir conda
python -m pip install jinja2
python build_tools/azure/render_meta.py
# This line is purely for debugging
conda render --python=$(python.version) conda/
displayName: 'Rendering meta.yaml file'

- bash: make version
condition: contains(variables['Build.SourceBranch'], 'refs/tags')
displayName: 'Ensuring VERSION file is created'
3 changes: 1 addition & 2 deletions build_tools/azure/conda/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/bin/bash

# This looks like it is running `conda build` again, but it just returns the output file
output_file=$(conda-build --output --python=$(python.version) conda/)
output_file=$1

# Check our VERSION. Basically, if it contains letters, it is a pre-release. Otherwise,
# it has to match X.Y or X.Y.Z
Expand Down
7 changes: 5 additions & 2 deletions build_tools/azure/conda/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ steps:
fi
displayName: Checking for VERSION file

- bash: build_tools/azure/conda/deploy.sh
condition: and(succeeded(), eq(variables['VERSION_EXISTS'], 'true'), contains(variables['Build.SourceBranch'], 'refs/tags'))
- bash: |
# This looks like it is running `conda build` again, but it just returns the output file
output_file=$(conda-build --output --python=$(python.version) conda/)
./build_tools/azure/conda/deploy.sh $output_file
condition: and(succeeded(), eq(variables['LIB_CREATED'], 'true'), eq(variables['VERSION_EXISTS'], 'true'), contains(variables['Build.SourceBranch'], 'refs/tags'))
displayName: Deploying to conda
env:
ANACONDA_API_TOKEN: $(anacondaToken)
37 changes: 0 additions & 37 deletions build_tools/azure/conda/linux.yml

This file was deleted.

39 changes: 0 additions & 39 deletions build_tools/azure/conda/mac.yml

This file was deleted.

22 changes: 22 additions & 0 deletions build_tools/azure/conda/unix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
steps:
# A lot of our requirements don't exist on conda (scipy>1.3.3, for instance), so we pip install all of them
- bash: |
conda create --name build-env python=$(python.version) --yes
python -m pip install -r requirements.txt
displayName: 'Creating build environment'

- bash: |
source activate build-env
conda build --python=$(python.version) conda/
displayName: 'Building and testing conda distribution'

- bash: |
output_file=$(conda-build --output --python=$(python.version) conda/)
if tar -tf "$output_file" | grep "lib"; then
echo "##vso[task.setvariable variable=LIB_CREATED]true"
echo "Lib directory created properly"
else
echo "Lib directory not created"
exit 1
fi
displayName: 'Looking for lib folder'
37 changes: 12 additions & 25 deletions build_tools/azure/conda/windows.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
steps:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: 'Add conda to PATH'

- script: conda install conda-build anaconda-client --yes
displayName: 'Installing conda-build and anaconda-client'

- script: make version
displayName: 'Ensuring VERSION file is created'
condition: contains(variables['Build.SourceBranch'], 'refs/tags')

- bash: |
mkdir conda
python -m pip install jinja2
python build_tools/azure/render_meta.py
displayName: 'Rendering meta.yaml file'

# A lot of our requirements don't exist on conda (scipy>1.3.3, for instance), so we pip install all of them
# Windows is weird and fails if we try to do these as separate steps
- script: |
conda create --name build-env python=$(python.version) --yes
call activate build-env
pip install -r requirements.txt
python -m pip install -r requirements.txt
conda-build --python=$(python.version) conda/
displayName: 'Building and testing conda distribution'

# Run pmdarima.show_versions() because I don't 100% trust the conda builder
# Have to cd .. because pmdarima doesn't like importing from own dir
- bash: |
source activate build-env
cd ..
conda install --use-local pmdarima --yes
python -c "import pmdarima; pmdarima.show_versions()"
displayName: 'Testing conda installation'
output_file=$(conda-build --output --python=$(python.version) conda/)
# Windows has to use --force-local to ignore colons, and `Lib` has to be capitalized
if tar -tf "$output_file" --force-local | grep "Lib"; then
echo "##vso[task.setvariable variable=LIB_CREATED]true"
echo "Lib directory created properly"
else
echo "Lib directory not created"
exit 1
fi
displayName: 'Looking for lib folder'
31 changes: 22 additions & 9 deletions build_tools/azure/meta_template.yml.j2
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
{# This is a Jinja2 template that will render out to $ROOT/conda/meta.yaml #}
package:
name: 'pmdarima'
version: '{{ VERSION }}'
name: "pmdarima"
version: "{{ VERSION }}"

{# Path where setup.py lies from root/conda (since that is where this will be rendered) #}
source:
path: ../
git_url: ../

build:
string: 'py{{ py_version }}'
script: 'python -m pip install dist/{{ wheel }} --no-deps -vv' # [not win]
script: 'python setup.py install' # [win]
{% raw %}
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
string: py{{ CONDA_PY }}{{ environ.get('GIT_DESCRIBE_HASH', '') }}_{{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
{% endraw %}
{#
The first one here installs to the default location (which is where testing happens)
and the second one installs to $PREFIX, which is set by conda-build and is necessary
for the `lib` folder to end up in the tar.bz2
#}
script: |
python -m pip install --no-deps --ignore-installed .
python -m pip install --prefix $PREFIX --no-deps --ignore-installed .
ignore_run_exports:
- pip
- statsmodels
Expand All @@ -24,20 +33,23 @@ build:

requirements:
build:
- {{ numpy_version }}
{% raw %}
- {{ compiler('c') }}
{% endraw %}

host:
- pip
- python
{% raw %}
- python {{ PY_VER }}
{% endraw %}
{% for package in requirements %}
- {{ package }}
{% endfor %}

run:
- python
{% raw %}
- python {{ PY_VER }}
{% endraw %}
{% for package in requirements %}
- {{ package }}
{% endfor %}
Expand All @@ -48,6 +60,7 @@ test:
- pip install pytest pytest-mpl pytest-benchmark
{# Cannot use `make` in the meta.yaml file #}
- pytest --showlocals --durations=20 --pyargs pmdarima --benchmark-skip
- python -c "import pmdarima; pmdarima.show_versions()"

about:
home: https://github.com/alkaline-ml/pmdarima
Expand Down
27 changes: 11 additions & 16 deletions build_tools/azure/render_meta.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import sys
import re

from jinja2 import Environment, FileSystemLoader
from pathlib import Path
Expand Down Expand Up @@ -28,26 +28,21 @@
VERSION = '0.0.0'

# Find the requirements and versions
# conda puts a space between packages and versions, so we have to match that
requirements = []
with open(str(REQUIREMENTS_FILE.resolve())) as file:
requirements = [line.strip() for line in file.readlines()]

# We build from source on windows, otherwise, we looks for a wheel
if sys.platform != 'win32':
wheel = next(file for file in os.listdir(str(DIST_PATH.resolve()))
if file.endswith('.whl'))
else:
wheel = None

# Numpy version is used for building
numpy_version = next(package for package in requirements if 'numpy' in package)
for line in file:
requirement = line.strip()
match = re.match(r'^([A-Za-z\-0-9]+)', requirement)
_, match_end = match.span()
package = match.group(0)
version = requirement[match_end:].replace('==', '')
requirements.append(f'{package} {version}')

# Render and write the meta.yaml file to $ROOT/conda/meta.yaml
context = {
'requirements': requirements,
'numpy_version': numpy_version,
'VERSION': VERSION,
'wheel': wheel,
'py_version': '{0.major}{0.minor}'.format(sys.version_info)
'VERSION': VERSION
}

# Ensure output directory exists
Expand Down