Skip to content

Commit 8112c23

Browse files
committed
conda.recipe
closes #210
1 parent 3eb0902 commit 8112c23

File tree

6 files changed

+285
-1
lines changed

6 files changed

+285
-1
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ packages/*
1010
dist
1111
pythonnet.egg-info
1212
*.userprefs
13+
build/
14+
tools/nuget/*.exe

appveyor.yml

+55-1
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,85 @@
11
os: Windows Server 2012
22

3+
matrix:
4+
fast_finish: true
5+
36
environment:
47
global:
58
PYTHONPATH: c:\testdir
69
PYTHONWARNINGS: 'ignore:::pip.pep425tags:'
10+
CONDA_BLD_VERSION: "3.5"
11+
12+
# SDK v7.0 MSVC Express 2008's SetEnv.cmd script will fail if the
13+
# /E:ON and /V:ON options are not enabled in the batch script intepreter
14+
# See: http://stackoverflow.com/a/13751649/163740
15+
CMD_IN_ENV: "cmd /E:ON /V:ON /C .\\ci\\run_with_env.cmd"
16+
717

818
matrix:
919
# http://www.appveyor.com/docs/installed-software#python
1020
- PYTHON: "C:\\Python27"
21+
CONDA_PY: "27"
22+
CONDA_BLD: "C:\\miniconda-32"
23+
CONDA_BLD_ARCH: "32"
24+
1125
- PYTHON: "C:\\Python27-x64"
26+
CONDA_PY: "27"
27+
CONDA_BLD: "C:\\miniconda-64"
28+
CONDA_BLD_ARCH: "64"
29+
1230
- PYTHON: "C:\\Python33"
31+
CONDA_PY: "33"
32+
CONDA_BLD: "C:\\miniconda-32"
33+
CONDA_BLD_ARCH: "32"
34+
1335
- PYTHON: "C:\\Python33-x64"
36+
CONDA_PY: "33"
37+
CONDA_BLD: "C:\\miniconda-64"
38+
CONDA_BLD_ARCH: "64"
39+
1440
- PYTHON: "C:\\Python34"
41+
CONDA_PY: "34"
42+
CONDA_BLD: "C:\\miniconda-32"
43+
CONDA_BLD_ARCH: "32"
44+
1545
- PYTHON: "C:\\Python34-x64"
46+
CONDA_PY: "34"
47+
CONDA_BLD_ARCH: "64"
48+
CONDA_BLD: "C:\\miniconda-64"
49+
1650
- PYTHON: "C:\\Python35"
51+
CONDA_PY: "35"
52+
CONDA_BLD: "C:\\miniconda-32"
53+
CONDA_BLD_ARCH: "32"
54+
1755
- PYTHON: "C:\\Python35-x64"
56+
CONDA_PY: "35"
57+
CONDA_BLD: "C:\\miniconda-64"
58+
CONDA_BLD_ARCH: "64"
1859

1960
install:
61+
# install conda and deps
62+
- powershell .\ci\install.ps1
63+
- "%CONDA_BLD%\\Scripts\\conda config --set show_channel_urls true --set always_yes true --set changeps1 false"
64+
- "%CONDA_BLD%\\Scripts\\conda update -q conda"
65+
- "%CONDA_BLD%\\Scripts\\conda info -a"
66+
67+
# install for wheels
2068
- "%PYTHON%\\python.exe -m pip install --upgrade pip"
2169
- "%PYTHON%\\python.exe -m pip install wheel"
2270
- "%PYTHON%\\python.exe -m pip install six"
2371

2472
build_script:
73+
# build wheel
2574
- "%PYTHON%\\python.exe setup.py bdist_wheel"
2675

76+
# build and dist conda package
77+
- cmd: "%CMD_IN_ENV% %CONDA_BLD%\\Scripts\\conda build conda.recipe"
78+
- ps: $CONDA_PKG=(& "$env:CONDA_BLD\\Scripts\\conda" build conda.recipe --output -q)
79+
- ps: copy-item $CONDA_PKG "$env:APPVEYOR_BUILD_FOLDER\\dist\\"
80+
2781
test_script:
28-
- ps: '& "$env:PYTHON\\Scripts\\pip.exe" install --no-cache-dir --force-reinstall --ignore-installed ("dist\\" + (gci dist)[0].Name)'
82+
- ps: '& "$env:PYTHON\\Scripts\\pip.exe" install --no-cache-dir --force-reinstall --ignore-installed ("dist\\" + (gci dist\*.whl)[0].Name)'
2983
- mkdir c:\testdir
3084
- ps: copy-item (gci -path build -re -include Python.Test.dll)[0].FullName c:\testdir
3185
- "%PYTHON%\\python.exe src\\tests\\runtests.py"

ci/install.ps1

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Sample script to install Miniconda under Windows
2+
# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner, Robert McGibbon
3+
# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
4+
5+
$MINICONDA_URL = "http://repo.continuum.io/miniconda/"
6+
7+
8+
function DownloadMiniconda ($python_version, $platform_suffix) {
9+
$webclient = New-Object System.Net.WebClient
10+
$filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe"
11+
$url = $MINICONDA_URL + $filename
12+
13+
$basedir = $pwd.Path + "\"
14+
$filepath = $basedir + $filename
15+
if (Test-Path $filename) {
16+
Write-Host "Reusing" $filepath
17+
return $filepath
18+
}
19+
20+
# Download and retry up to 3 times in case of network transient errors.
21+
Write-Host "Downloading" $filename "from" $url
22+
$retry_attempts = 2
23+
for($i=0; $i -lt $retry_attempts; $i++){
24+
try {
25+
$webclient.DownloadFile($url, $filepath)
26+
break
27+
}
28+
Catch [Exception]{
29+
Start-Sleep 1
30+
}
31+
}
32+
if (Test-Path $filepath) {
33+
Write-Host "File saved at" $filepath
34+
} else {
35+
# Retry once to get the error message if any at the last try
36+
$webclient.DownloadFile($url, $filepath)
37+
}
38+
return $filepath
39+
}
40+
41+
42+
function InstallMiniconda ($python_version, $architecture, $python_home) {
43+
Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home
44+
if (Test-Path $python_home) {
45+
Write-Host $python_home "already exists, skipping."
46+
# return $false
47+
}
48+
if ($architecture -match "32") {
49+
$platform_suffix = "x86"
50+
} else {
51+
$platform_suffix = "x86_64"
52+
}
53+
54+
$filepath = DownloadMiniconda $python_version $platform_suffix
55+
Write-Host "Installing" $filepath "to" $python_home
56+
$install_log = $python_home + ".log"
57+
$args = "/S /D=$python_home"
58+
Write-Host $filepath $args
59+
Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru
60+
if (Test-Path $python_home) {
61+
Write-Host "Python $python_version ($architecture) installation complete"
62+
} else {
63+
Write-Host "Failed to install Python in $python_home"
64+
Get-Content -Path $install_log
65+
Exit 1
66+
}
67+
}
68+
69+
70+
function InstallCondaPackages ($python_home, $spec) {
71+
$conda_path = $python_home + "\Scripts\conda.exe"
72+
$args = "install --yes " + $spec
73+
Write-Host ("conda " + $args)
74+
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
75+
}
76+
77+
function UpdateConda ($python_home) {
78+
$conda_path = $python_home + "\Scripts\conda.exe"
79+
Write-Host "Updating conda..."
80+
$args = "update --yes conda"
81+
Write-Host $conda_path $args
82+
Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru
83+
}
84+
85+
86+
function main () {
87+
InstallMiniconda $env:CONDA_BLD_VERSION $env:CONDA_BLD_ARCH $env:CONDA_BLD
88+
UpdateConda $env:CONDA_BLD
89+
InstallCondaPackages $env:CONDA_BLD "conda-build jinja2 anaconda-client"
90+
}
91+
92+
main

ci/run_with_env.cmd

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
:: EXPECTED ENV VARS: PYTHON_ARCH (either x86 or x64)
2+
:: CONDA_PY (either 27, 33, 35 etc. - only major version is extracted)
3+
::
4+
::
5+
:: To build extensions for 64 bit Python 3, we need to configure environment
6+
:: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of:
7+
:: MS Windows SDK for Windows 7 and .NET Framework 4 (SDK v7.1)
8+
::
9+
:: To build extensions for 64 bit Python 2, we need to configure environment
10+
:: variables to use the MSVC 2008 C++ compilers from GRMSDKX_EN_DVD.iso of:
11+
:: MS Windows SDK for Windows 7 and .NET Framework 3.5 (SDK v7.0)
12+
::
13+
:: 32 bit builds, and 64-bit builds for 3.5 and beyond, do not require specific
14+
:: environment configurations.
15+
::
16+
:: Note: this script needs to be run with the /E:ON and /V:ON flags for the
17+
:: cmd interpreter, at least for (SDK v7.0)
18+
::
19+
:: More details at:
20+
:: https://github.com/cython/cython/wiki/64BitCythonExtensionsOnWindows
21+
:: http://stackoverflow.com/a/13751649/163740
22+
::
23+
:: Author: Phil Elson
24+
:: Original Author: Olivier Grisel (https://github.com/ogrisel/python-appveyor-demo)
25+
:: License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/
26+
::
27+
:: Notes about batch files for Python people:
28+
::
29+
:: Quotes in values are literally part of the values:
30+
:: SET FOO="bar"
31+
:: FOO is now five characters long: " b a r "
32+
:: If you don't want quotes, don't include them on the right-hand side.
33+
::
34+
:: The CALL lines at the end of this file look redundant, but if you move them
35+
:: outside of the IF clauses, they do not run properly in the SET_SDK_64==Y
36+
:: case, I don't know why.
37+
:: originally from https://github.com/pelson/Obvious-CI/blob/master/scripts/obvci_appveyor_python_build_env.cmd
38+
@ECHO OFF
39+
40+
SET COMMAND_TO_RUN=%*
41+
SET WIN_SDK_ROOT=C:\Program Files\Microsoft SDKs\Windows
42+
43+
:: Extract the major and minor versions, and allow for the minor version to be
44+
:: more than 9. This requires the version number to have two dots in it.
45+
SET MAJOR_PYTHON_VERSION=%CONDA_PY:~0,1%
46+
47+
IF "%CONDA_PY:~2,1%" == "" (
48+
:: CONDA_PY style, such as 27, 34 etc.
49+
SET MINOR_PYTHON_VERSION=%CONDA_PY:~1,1%
50+
) ELSE (
51+
IF "%CONDA_PY:~3,1%" == "." (
52+
SET MINOR_PYTHON_VERSION=%CONDA_PY:~2,1%
53+
) ELSE (
54+
SET MINOR_PYTHON_VERSION=%CONDA_PY:~2,2%
55+
)
56+
)
57+
58+
:: Based on the Python version, determine what SDK version to use, and whether
59+
:: to set the SDK for 64-bit.
60+
IF %MAJOR_PYTHON_VERSION% == 2 (
61+
SET WINDOWS_SDK_VERSION="v7.0"
62+
SET SET_SDK_64=Y
63+
) ELSE (
64+
IF %MAJOR_PYTHON_VERSION% == 3 (
65+
SET WINDOWS_SDK_VERSION="v7.1"
66+
IF %MINOR_PYTHON_VERSION% LEQ 4 (
67+
SET SET_SDK_64=Y
68+
) ELSE (
69+
SET SET_SDK_64=N
70+
)
71+
) ELSE (
72+
ECHO Unsupported Python version: "%MAJOR_PYTHON_VERSION%"
73+
EXIT /B 1
74+
)
75+
)
76+
77+
IF "%PYTHON_ARCH%"=="64" (
78+
IF %SET_SDK_64% == Y (
79+
ECHO Configuring Windows SDK %WINDOWS_SDK_VERSION% for Python %MAJOR_PYTHON_VERSION% on a 64 bit architecture
80+
SET DISTUTILS_USE_SDK=1
81+
SET MSSdk=1
82+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Setup\WindowsSdkVer.exe" -q -version:%WINDOWS_SDK_VERSION%
83+
"%WIN_SDK_ROOT%\%WINDOWS_SDK_VERSION%\Bin\SetEnv.cmd" /x64 /release
84+
ECHO Executing: %COMMAND_TO_RUN%
85+
call %COMMAND_TO_RUN% || EXIT /B 1
86+
) ELSE (
87+
ECHO Using default MSVC build environment for 64 bit architecture
88+
ECHO Executing: %COMMAND_TO_RUN%
89+
call %COMMAND_TO_RUN% || EXIT /B 1
90+
)
91+
) ELSE (
92+
ECHO Using default MSVC build environment for 32 bit architecture
93+
ECHO Executing: %COMMAND_TO_RUN%
94+
call %COMMAND_TO_RUN% || EXIT /B 1
95+
)

conda.recipe/bld.bat

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
:: build it
2+
3+
:: set path to modern MSBuild
4+
set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
5+
6+
%PYTHON% setup.py install
7+
8+
:: copy our compiled library
9+
set SRC=%RECIPE_DIR%\..
10+
set DEST=%SP_DIR%
11+
12+
:: Install step
13+
copy %SRC%\Python.Runtime.dll.config %DEST%

conda.recipe/meta.yaml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package:
2+
name: clr
3+
version: {{ environ.get('GIT_DESCRIBE_TAG', '').replace('-dev', '.dev') }}
4+
5+
build:
6+
skip: True # [not win]
7+
number: {{ environ.get('GIT_DESCRIBE_NUMBER', 0) }}
8+
{% if environ.get('GIT_DESCRIBE_NUMBER', '0') == '0' %}string: py{{ environ.get('PY_VER').replace('.', '') }}_0
9+
{% else %}string: py{{ environ.get('PY_VER').replace('.', '') }}_{{ environ.get('GIT_BUILD_STR', 'GIT_STUB') }}{% endif %}
10+
11+
source:
12+
git_url: ../
13+
14+
requirements:
15+
build:
16+
- python
17+
- setuptools
18+
19+
run:
20+
- python
21+
22+
test:
23+
imports:
24+
- clr
25+
26+
about:
27+
home: https://github.com/pythonnet/pythonnet
28+
license: ZPL

0 commit comments

Comments
 (0)