This commit is contained in:
Ian Bell
2015-07-07 00:34:34 -06:00
9 changed files with 216 additions and 166 deletions

5
.gitignore vendored
View File

@@ -43,3 +43,8 @@
/dev/all_incompressibles_verbose.json
/include/all_incompressibles_JSON.h
fluids
/meta.yaml
/runner.py
/build.sh
/bld.bat
/conda/

View File

@@ -84,8 +84,8 @@ steps on a Windows machine::
conda create -n CoolProp27 python=2
conda create -n CoolProp34 python=3
conda install -n CoolProp27 cython pip pywin32 unxutils jinja2 pyyaml
conda install -n CoolProp34 cython pip pywin32 unxutils jinja2 pyyaml
conda install -n CoolProp27 cython pip pywin32 unxutils jinja2 pyyaml ndg-httpsclient
conda install -n CoolProp34 cython pip pywin32 unxutils jinja2 pyyaml ndg-httpsclient
activate CoolProp27
pip install wheel

View File

@@ -380,18 +380,24 @@ def pythonFactory(pyID, pyCFG=PythonSlaveConfig("name"), gitMode='incremental'):
fixPermissions(factory)
#
pkgs = ["requests", "jinja2", "pyyaml", "numpy", "scipy", "matplotlib", "pandas", "cython"]
if checkID(pyID, teID=100, strict=False): pkgs.extend(["unxutils","pywin32"]) # Add Windows-only dependency
if checkID(pyID, teID=100, strict=False):
pkgs.extend(["unxutils","pywin32"]) # Add Windows-only dependency
if checkID(pyID, teID=101, strict=False):
pkgs.append("ndg-httpsclient") # Add Windows-only and python2 dependency
installCMD = " ".join(["conda", "install", "-yq"]) + " " + " ".join(pkgs)
combinedCMD = " && ".join([activateCMD, installCMD])
factory.addStep(ShellCommand(command = combinedCMD, workdir = workingFolder, haltOnFailure = False))
#
installCMD = " ".join(["python", "conda_builder.py"])
installCMD = " ".join(["python", "generate_meta.yaml.py"])
combinedCMD = " && ".join([activateCMD, installCMD])
factory.addStep(ShellCommand(command = combinedCMD, workdir = workingFolder+"/conda", haltOnFailure = False))
factory.addStep(ShellCommand(command = combinedCMD, workdir = workingFolder, haltOnFailure = False))
#
installCMD = " ".join(["conda", "build", "coolprop"])
installCMD = " ".join(["python", "runner.py"])
combinedCMD = " && ".join([activateCMD, installCMD])
factory.addStep(ShellCommand(command = combinedCMD, workdir = workingFolder+"/conda", haltOnFailure = False))
factory.addStep(ShellCommand(command = combinedCMD, workdir = workingFolder+"/../..", haltOnFailure = False))
#
factory.addStep(DirectoryUpload(slavesrc='conda', masterdest=masterdestLocation, compress="bz2"))
fixPermissions(factory)
#
#installCMD = " ".join(["binstar", "upload", "--channel", "dev"])
#
@@ -932,8 +938,8 @@ relinstFolder = "../../install_root" # relative path
baseins = ['bdist_wheel', '--dist-dir', relinstFolder+'/Python']
windowsDTUslave = PythonSlaveConfig("windows-DTU-slave")
windowsDTUslave.pyact[getIDstr("windows", "32bit", 0 )] = "\"C:\\Program Files (x86)\\Miniconda32_27\\Scripts\\activate.bat\""
windowsDTUslave.pyact[getIDstr("windows", "64bit", 0 )] = "\"C:\\Program Files\\Miniconda64_27\\Scripts\\activate.bat\""
windowsDTUslave.pyact[getIDstr("windows", "32bit", 0 )] = "set \"PATH=C:\\Program Files (x86)\\Miniconda32_27\\Scripts;%PATH%\" && activate"
windowsDTUslave.pyact[getIDstr("windows", "64bit", 0 )] = "set \"PATH=C:\\Program Files\\Miniconda64_27\\Scripts;%PATH%\" && activate"
windowsDTUslave.pyenv[getIDstr("windows", 0 , "py27")] = "CoolProp27"
windowsDTUslave.pyenv[getIDstr("windows", 0 , "py33")] = "CoolProp33"
windowsDTUslave.pyenv[getIDstr("windows", 0 , "py34")] = "CoolProp34"
@@ -999,8 +1005,8 @@ for slave in pythonSlaves:
# )
# )
windowsDTUslave.pyact[getIDstr("windows", "32bit", 0 )] = "\"C:\\Program Files (x86)\\Miniconda32_27\\Scripts\\activate.bat\""
windowsDTUslave.pyact[getIDstr("windows", "64bit", 0 )] = "\"C:\\Program Files\\Miniconda64_27\\Scripts\\activate.bat\""
windowsDTUslave.pyact[getIDstr("windows", "32bit", 0 )] = "set \"PATH=C:\\Program Files (x86)\\Miniconda32_27\\Scripts;%PATH%\" && activate"
windowsDTUslave.pyact[getIDstr("windows", "64bit", 0 )] = "set \"PATH=C:\\Program Files\\Miniconda64_27\\Scripts;%PATH%\" && activate"
windowsDTUslave.pyenv[getIDstr("windows", 0 , "py27")] = "CoolProp27"
c['builders'].append(

View File

@@ -1,84 +0,0 @@
import jinja2
import os
import requests
import json
from distutils.version import LooseVersion #, StrictVersion
import codecs
""" A simple script to create a conda recipe from the PyPI release and build the package"""
template_dir = os.path.dirname(__file__)
target_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'coolprop'))
pkgs = ["numpy", "scipy", "matplotlib", "pandas", "cython"]
loader = jinja2.FileSystemLoader(template_dir)
environment = jinja2.Environment(loader=loader)
target = 'meta.yaml'
template = environment.get_template(os.path.join(template_dir,'conda_'+target+'.tpl'))
# Get the additional information from PyPI
r = requests.get('https://pypi.python.org/pypi/CoolProp/json')
if(r.ok):
item = json.loads(r.text or r.content)
version = item['info']['version']
#version = sorted(item['releases'].keys())[-1]
home = item['info']['home_page']
license = 'MIT'
summary = item['info']['summary']
for u in item['urls']:
if u['python_version'] != 'source': continue
fil = u['filename']
url = u['url']
md5 = u['md5_digest']
continue
f = codecs.open(os.path.join(target_dir,target),mode='wb',encoding='utf-8')
f.write(template.render(
version=version,
fil=fil,
url=url,
md5=md5,
pkgs=pkgs,
home = home,
license = license,
summary = summary
))
f.close()
# release = item['releases'][version]
# for d in release:
# if d['python_version'] == 'source':
# fil =
# url =
# md5 = d['md5_digest']
##tag = sorted(tags.keys())[-1]
##for tag in sorted(tags.keys()):
## print tag
## r = requests.get('https://api.github.com/repos/coolprop/coolprop/git/tags/'+tags[tag])
## if(r.ok):
## items = json.loads(r.text or r.content)
## print str(items)
##def cmp(x,y): return LooseVersion(x).__cmp__(y)
##tag = sorted(tags.keys(),cmp=cmp)[-1]
#tag = sorted(tags.keys())[-1]
##from pkg_resources import parse_version
##>>> parse_version('1.4') > parse_version('1.4-rc2')
#if tag[0]=='v': version = tag[1:]
#else: version = tag
#f = codecs.open(os.path.join(target_dir,target),mode='wb',encoding='utf-8')
##f = open(name,mode='w')
#f.write(template.render(version=version,tag=tag,pkgs=pkgs))
#f.close()

View File

@@ -1,53 +0,0 @@
package:
name: coolprop
version: {{ version }}
source:
fn: {{ fil }}
url: {{ url }}
md5: {{ md5 }}
# If this is a new build for the same version, increment the build
# number. If you do not include this key, it defaults to 0.
# number: 1
requirements:
build:
- python
- setuptools{% for pkg in pkgs %}
- {{ pkg -}}
{% endfor %}
run:
- python{% for pkg in pkgs %}
- {{ pkg -}}
{% endfor %}
test:
# Python imports
imports:
- CoolProp
#- CoolProp.GUI
#- CoolProp.Plots
- CoolProp.tests
# commands:
# You can put test commands to be run here. Use this to test that the
# entry points work.
# You can also put a file called run_test.py in the recipe that will be run
# at test time.
# requires:
# Put any additional test requirements here. For example
# - nose
about:
home: {{ home }}
license: {{ license }}
summary: {{ sumamry }}
# See
# http://docs.continuum.io/conda/build.html for
# more information about meta.yaml

View File

@@ -1 +0,0 @@
/meta.yaml

View File

@@ -1,8 +0,0 @@
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
:: Add more build steps here, if they are necessary.
:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.

View File

@@ -1,9 +0,0 @@
#!/bin/bash
$PYTHON setup.py install
# Add more build steps here, if they are necessary.
# See
# http://docs.continuum.io/conda/build.html
# for a list of environment variables that are set during the build process.

View File

@@ -0,0 +1,194 @@
import jinja2
from jinja2 import Environment
import os,sys
import requests
import json
from distutils.version import LooseVersion #, StrictVersion
import codecs
""" A simple script to create a conda recipe from the PyPI release and build the package"""
template = """
package:
name: coolprop
version: {{ version }}
{% if pypi %}
source:
fn: {{ fil }}
url: {{ url }}
md5: {{ md5 }}
{% endif %}
{% if local %}
source:
path: .
{% endif %}
# If this is a new build for the same version, increment the build
# number. If you do not include this key, it defaults to 0.
# number: 1
requirements:
build:
- python
- setuptools{% for pkg in pkgs %}
- {{ pkg -}}
{% endfor %}
run:
- python{% for pkg in pkgs %}
- {{ pkg -}}
{% endfor %}
test:
# Python imports
imports:
- CoolProp
#- CoolProp.GUI
#- CoolProp.Plots
- CoolProp.tests
# commands:
# You can put test commands to be run here. Use this to test that the
# entry points work.
# You can also put a file called run_test.py in the recipe that will be run
# at test time.
# requires:
# Put any additional test requirements here. For example
# - nose
about:
home: {{ home }}
license: {{ license }}
summary: {{ summary }}
"""
target_dir = os.path.join(os.path.dirname(__file__),'..','..')
#loader = jinja2.FileSystemLoader(template_dir)
#environment = jinja2.Environment(loader=loader)
#template = environment.get_template(os.path.join(template_dir,'conda_'+target+'.tpl'))
#
template =Environment().from_string(template)
pypi = False
local = not pypi
pkgs = ["numpy", "scipy", "matplotlib", "pandas", "cython"]
target = 'meta.yaml'
if pypi:
# Get the additional information from PyPI
r = requests.get('https://pypi.python.org/pypi/CoolProp/json')
if(r.ok):
item = json.loads(r.text or r.content)
version = item['info']['version']
#version = sorted(item['releases'].keys())[-1]
home = item['info']['home_page']
license = 'MIT'
summary = item['info']['summary']
for u in item['urls']:
if u['python_version'] != 'source': continue
fil = u['filename']
url = u['url']
md5 = u['md5_digest']
continue
if local:
coolprop_dir = os.path.abspath(os.path.join(os.path.dirname(__file__),'..','..'))
version = open(os.path.join(coolprop_dir,'.version'),'r').read().strip()
home = "http://www.coolprop.org"
license = "MIT"
summary = "Open-source thermodynamic and transport properties database"
fil = None
url = None
md5 = None
f = codecs.open(os.path.join(target_dir,target),mode='wb',encoding='utf-8')
f.write(template.render(
pypi=pypi,
local=local,
version=version,
fil=fil,
url=url,
md5=md5,
pkgs=pkgs,
home = home,
license = license,
summary = summary
))
f.close()
bat_template = """
pushd wrappers\Python
"%PYTHON%" setup.py install
if errorlevel 1 exit 1
popd
:: Add more build steps here, if they are necessary.
:: See
:: http://docs.continuum.io/conda/build.html
:: for a list of environment variables that are set during the build process.
"""
target = "bld.bat"
f = codecs.open(os.path.join(target_dir,target),mode='wb',encoding='utf-8')
f.write(bat_template)
f.close()
bsh_template = """
#!/bin/bash
pushd wrappers/Python
$PYTHON setup.py install
popd
# Add more build steps here, if they are necessary.
# See
# http://docs.continuum.io/conda/build.html
# for a list of environment variables that are set during the build process.
"""
target = "build.sh"
f = codecs.open(os.path.join(target_dir,target),mode='wb',encoding='utf-8')
f.write(bat_template)
f.close()
runner_template = """
from __future__ import print_function
import sys, shutil, subprocess, os, errno
def run_command(cmd):
'''given shell command, returns communication tuple of stdout and stderr'''
return subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
stdin=subprocess.PIPE).communicate()
subprocess.check_call('conda build .', shell = True, stdout = sys.stdout, stderr = sys.stderr)
filename = os.path.abspath(run_command('conda build --output .')[0]).decode("utf-8").strip()
tar = os.path.abspath(os.path.join(os.path.dirname(__file__),'conda','Python_conda')).strip()
try:
os.makedirs(tar)
except Exception as e:
if os.path.isdir(tar): pass
else: raise
print("Copying: "+str(filename)+" to "+str(tar))
shutil.copy(filename,tar)
sys.exit(0)
"""
target = "runner.py"
f = codecs.open(os.path.join(target_dir,target),mode='wb',encoding='utf-8')
f.write(runner_template)
f.close()
sys.exit(0)