Skip to content

Commit 1e8f472

Browse files
committed
Update code for 2.0.5 release
Mostly done by ecederstrand (#1529)
1 parent fd9d2cc commit 1e8f472

14 files changed

+133
-84
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ tests/TestListTravis.sh
99
*nogit*
1010
Makefile
1111
set_env.sh
12+
venv
13+
__pycache__
1214

1315
# editors
16+
.idea
1417
.vscode

devtools/builder/build_all.sh

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,61 @@
1-
#!/bin/sh
2-
3-
# Must be in pytraj root folder
4-
5-
# add cpptraj folder
6-
python -c "import auditwheel" || exit 1
1+
#!/usr/bin/env bash
2+
set -e
73

84
function main(){
9-
# this function will be run in the end of this script
5+
# Must be in pytraj root folder
6+
107
devtools/mkrelease
118
clone_or_update_cpptraj
12-
pip_linux
9+
10+
# osx
11+
build_libcpptraj_osx
1312
pip_osx
14-
conda_linux
1513
conda_osx
14+
15+
# linux
16+
build_libcpptraj_linux
17+
pip_linux
18+
conda_linux
1619
}
1720

1821

22+
function create_venv(){
23+
if [ ! -d /tmp/pytraj_venv ]; then
24+
# We need to place the venv outside the checkout so it does not get wiped out by 'git clean'
25+
python3 -m venv /tmp/pytraj_venv
26+
/tmp/pytraj_venv/bin/python -m pip install -U pip setuptools wheel
27+
/tmp/pytraj_venv/bin/python -m pip install auditwheel numpy Cython
28+
fi
29+
}
30+
1931
function clone_or_update_cpptraj(){
2032
if [ ! -d cpptraj ]; then
2133
git clone https://github.com/amber-md/cpptraj
2234
else
23-
(cd cpptraj && git pull && git clean -fdx .)
35+
# (cd cpptraj && git pull && git clean -fdx .)
36+
echo "bla bla"
2437
fi
2538
}
2639

2740

2841
function pip_linux(){
29-
sh devtools/builder/run_docker_build_wheels_linux.sh
42+
devtools/builder/run_docker_build_wheels_linux.sh
3043
}
3144

3245

33-
function pip_osx(){
34-
(cd cpptraj && git clean -fdx .)
46+
function build_libcpptraj_osx(){
47+
# (cd cpptraj && git clean -fdx .)
3548
export CPPTRAJHOME=`pwd`/cpptraj
3649
python scripts/install_libcpptraj.py
50+
}
51+
52+
53+
function build_libcpptraj_linux(){
54+
bash devtools/builder/run_docker_build_libcpptraj_linux.sh
55+
}
56+
57+
58+
function pip_osx(){
3759
(cd dist && python ../scripts/build_wheel.py pytraj*.tar.gz)
3860
}
3961

@@ -44,10 +66,11 @@ function conda_linux(){
4466

4567

4668
function conda_osx(){
47-
for pyver in 2.7 3.7 3.5 3.6; do
69+
# for pyver in 3.5 3.6 3.7 3.8; do
70+
for pyver in 3.8; do
4871
conda build devtools/conda-recipe/pytraj --py $pyver
4972
tarfile=`conda build devtools/conda-recipe/pytraj --py $pyver --output`
50-
73+
5174
build_dir=dist/conda/osx-64
5275
if [ ! -d $build_dir ]; then
5376
mkdir -p $build_dir

devtools/builder/run_docker_build_conda_linux.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env bash
2+
set -e
23

34
FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/../../"; pwd;)
4-
# DOCKER_IMAGE=hainm/pytraj-build-box:2019-03 # centos-5; does not have python 3.7
5-
DOCKER_IMAGE=condaforge/linux-anvil # Miniconda only has python 3.7 on centos >= 6
5+
# DOCKER_IMAGE=hainm/pytraj-build-box:2020-04-24 # centos-7
6+
DOCKER_IMAGE=hainm/pytraj-build-box:2019-03
67

78
docker info
89
cat << EOF | docker run -i \
@@ -12,11 +13,12 @@ cat << EOF | docker run -i \
1213
bash || exit $?
1314
1415
set -x
16+
set -e
1517
cd /feedstock_root/
1618
1719
export PATH=\$HOME/miniconda3/bin:\$PATH
1820
19-
for pyver in 3.7 2.7 3.5 3.6; do
21+
for pyver in 3.5 3.6 3.7 3.8; do
2022
conda build devtools/conda-recipe/pytraj --py \$pyver
2123
tarfile=\`conda build devtools/conda-recipe/pytraj --py \$pyver --output\`
2224
echo "\$tarfile"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/../../"; pwd;)
5+
DOCKER_IMAGE=hainm/pytraj-build-box:2019-03
6+
7+
docker info
8+
cat << EOF | docker run -i \
9+
-v ${FEEDSTOCK_ROOT}:/feedstock_root \
10+
-a stdin -a stdout -a stderr \
11+
${DOCKER_IMAGE}\
12+
bash || exit $?
13+
14+
set -x
15+
set -e
16+
cd /feedstock_root/
17+
18+
if [ ! -d cpptraj ]; then
19+
python scripts/install_libcpptraj.py github -openmp
20+
else
21+
# (cd cpptraj && git pull && git clean -fdx .)
22+
python scripts/install_libcpptraj.py -openmp
23+
fi
24+
EOF
Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env bash
2+
# Assume libcpptraj.so is already built
3+
set -e
24

35
FEEDSTOCK_ROOT=$(cd "$(dirname "$0")/../../"; pwd;)
46
DOCKER_IMAGE=hainm/pytraj-build-box:2019-03
@@ -11,23 +13,18 @@ cat << EOF | docker run -i \
1113
bash || exit $?
1214
1315
set -x
16+
set -e
1417
cd /feedstock_root/
1518
16-
export python=/opt/python/cp36-cp36m/bin/python
19+
export PATH="/opt/python/cp38-cp38/bin:\$PATH"
1720
1821
if [ ! -d dist ]; then
19-
\$python ./devtools/mkrelease
20-
fi
21-
22-
if [ ! -d cpptraj ]; then
23-
\$python scripts/install_libcpptraj.py github -openmp
24-
else
25-
# (cd cpptraj && git pull && git clean -fdx .)
26-
\$python scripts/install_libcpptraj.py -openmp
22+
devtools/mkrelease
2723
fi
2824
25+
ls -la dist
2926
cd dist
30-
\$python ../scripts/build_wheel.py pytraj*gz --manylinux-docker
27+
python ../scripts/build_wheel.py ./pytraj*gz --manylinux-docker --py 3.5 3.6 3.7 3.8
3128
32-
cd ..
29+
rm -rf scripts/__pycache__
3330
EOF

devtools/builder/upload.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env bash
2+
set -e
13

24
function main(){
35
upload_pip

devtools/ci/install_ambertools.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,5 @@ conda install ambertools=17 -c http://ambermd.org/downloads/ambertools/conda/ -y
33
python_ver=$(python -c 'import sys; print(".".join(map(str, sys.version_info[:2])))')
44
echo "python_ver" $python_ver
55

6-
rm -rf $HOME/miniconda3/envs/$myenv/lib/python$python_ver/site-packages/pytraj
7-
rm -rf $HOME/miniconda3/envs/$myenv/lib/python$python_ver/site-packages/pytraj-2.0.0-py3.6.egg-info
6+
rm -rf $HOME/miniconda3/envs/$myenv/lib/python$python_ver/site-packages/pytraj*
87
rm $HOME/miniconda3/envs/$myenv/lib/libcpptraj*

devtools/ci/test_setup_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_install_libcpptraj_if_having_cpptraj_folder_here():
9898

9999
def test_install_to_amberhome():
100100
fn = './fake_amberhome'
101-
python_path = '{}/lib/python3.6/site-packages/'.format(fn)
101+
python_path = '{}/lib/python3.8/site-packages/'.format(fn)
102102
mkdir_cmd = 'mkdir -p {}'.format(python_path)
103103
subprocess.check_call(mkdir_cmd, shell=True)
104104
full_name = os.path.abspath(fn)

devtools/conda-recipe/pytraj/build.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,12 @@ pyver=`python -c "import sys; print('.'.join(str(x) for x in sys.version_info[:2
55
pyver2=`python -c "import sys; print(''.join(str(x) for x in sys.version_info[:2]))"`
66

77
# FIXME: why hard code the version here?
8-
version='2.0.4'
8+
version='2.0.5'
99

1010
if [ "$isosx" = "True" ]; then
11-
whlfile=pytraj-$version-cp$pyver2-cp${pyver2}m-macosx_*_x86_64.whl
11+
whlfile=pytraj-$version-cp$pyver2-cp${pyver2}*-macosx_*_x86_64.whl
1212
else
13-
if [ "$pyver2" = "27" ]; then
14-
whlfile=pytraj-$version-cp$pyver2-cp${pyver2}mu-manylinux1_x86_64.whl
15-
else
16-
whlfile=pytraj-$version-cp$pyver2-cp${pyver2}m-manylinux1_x86_64.whl
17-
fi
13+
whlfile=pytraj-$version-cp$pyver2-cp${pyver2}*-manylinux1_x86_64.whl
1814
fi
1915

2016
wheel unpack `ls $RECIPE_DIR/../../../dist/wheelhouse/$whlfile`

devtools/conda-recipe/pytraj/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% set name = "pytraj" %}
2-
{% set version = "2.0.4" %} #
2+
{% set version = "2.0.5" %}
33

44
package:
55
name: {{ name }}

scripts/build_wheel.py

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,33 @@ class PipBuilder(object):
3232
Build wheel package from conda package?
3333
'''
3434
REQUIRED_PACKAGES = ['auditwheel']
35-
SUPPORTED_VERSIONS = ['2.7mu', '2.7', '3.7', '3.5', '3.6']
35+
SUPPORTED_VERSIONS = {
36+
'3.5': 'cp35-cp35m',
37+
'3.6': 'cp36-cp36m',
38+
'3.7': 'cp37-cp37m',
39+
'3.8': 'cp38-cp38',
40+
}
3641

3742
if sys.platform.startswith('darwin'):
3843
REQUIRED_PACKAGES.append('conda_build')
39-
SUPPORTED_VERSIONS.remove('2.7mu')
4044

41-
MANY_LINUX_PYTHONS = dict((py_version,
42-
'/opt/python/cp{py}-cp{py}m/bin/python'.format(
43-
py=py_version.replace('.', '')))
44-
for py_version in SUPPORTED_VERSIONS)
45-
# wide-unicode (to be compatible with miniconda/anaconda python)
46-
if '2.7mu' in MANY_LINUX_PYTHONS:
47-
MANY_LINUX_PYTHONS['2.7mu'] = '/opt/python/cp27-cp27mu/bin/python'
45+
MANY_LINUX_PYTHONS = {
46+
py_version: '/opt/python/{tag}/bin/python'.format(tag=tag)
47+
for py_version, tag in SUPPORTED_VERSIONS.items()
48+
}
4849

4950
def __init__(self,
5051
tarfile,
5152
pytraj_home,
5253
python_versions,
5354
use_manylinux=False,
54-
cpptraj_dir=''):
55+
cpptraj_dir='',
56+
validate_only=False):
5557
self.libcpptraj = '' # will be updated later
5658
self.is_osx = sys.platform.startswith('darwin')
5759
self.python_versions = python_versions
5860
self.use_manylinux = use_manylinux
61+
self.validate_only = validate_only
5962
if cpptraj_dir:
6063
self.cpptraj_dir = os.path.abspath(cpptraj_dir)
6164
else:
@@ -78,10 +81,13 @@ def __init__(self,
7881
def run(self):
7982
self.check_cpptraj_and_required_libs()
8083
for python_version in self.python_versions:
81-
self.initialize_env(python_version)
82-
self.build_original_wheel(python_version)
83-
self.repair_wheel(python_version)
84-
self.validate_install(python_version)
84+
if self.validate_only:
85+
self.validate_install(python_version)
86+
else:
87+
self.initialize_env(python_version)
88+
self.build_original_wheel(python_version)
89+
self.repair_wheel(python_version)
90+
self.validate_install(python_version)
8591

8692
def initialize_env(self, python_version):
8793
if not self.use_manylinux:
@@ -157,7 +163,7 @@ def validate_install(self, py_version):
157163
env = 'pytraj' + py_version
158164
# e.g: change 2.7 to 27
159165
print('Testing pytraj build')
160-
whl_file = self._get_wheel_file(py_version, folder='wheelhouse')
166+
whl_file = os.path.abspath(self._get_wheel_file(py_version, folder='wheelhouse'))
161167
print('Testing wheel file {}'.format(whl_file))
162168
try:
163169
subprocess.check_call(
@@ -228,27 +234,32 @@ def check_cpptraj_and_required_libs(self):
228234
parser.add_argument(
229235
'--py',
230236
default=None,
231-
help='Python version. Default: build all versions (2.7, 3.4, 3.5)')
237+
nargs='+',
238+
help='Python version (e.g. 2.7 or 3.8). Default: build all supported versions')
232239
parser.add_argument(
233240
'--cpptraj-dir', default='', help='cpptraj dir, optional')
234241
parser.add_argument(
235242
'--manylinux-docker',
236243
action='store_true',
237244
help='If specified, use Python versions from manylinux')
245+
parser.add_argument(
246+
'--validate-only',
247+
action='store_true',
248+
help='Only validate the exisint repaired wheel')
238249
args = parser.parse_args()
239250

240251
tarfile = os.path.abspath(args.tarfile)
241-
python_versions = PipBuilder.SUPPORTED_VERSIONS if args.py is None else [
242-
args.py,
243-
]
252+
python_versions = args.py or list(PipBuilder.SUPPORTED_VERSIONS.keys())
253+
print(f"Building package for python: {python_versions}")
244254
# pytraj tar file
245255
pytraj_home = os.path.dirname(__file__).strip('scripts')
246256
builder = PipBuilder(
247257
tarfile=tarfile,
248258
pytraj_home=pytraj_home,
249259
python_versions=python_versions,
250260
use_manylinux=args.manylinux_docker,
251-
cpptraj_dir=args.cpptraj_dir)
261+
cpptraj_dir=args.cpptraj_dir,
262+
validate_only=args.validate_only)
252263
builder.run()
253264
# builder.libcpptraj = '../cpptraj/lib/libcpptraj.dylib'
254265
# builder.validate_install('3.5')

scripts/cythonize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env python
12
import os
23
import sys
34
import Cython

scripts/install_libcpptraj.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -165,32 +165,18 @@ def install_libcpptraj(compiler='', build_flag='', n_cpus=4):
165165
except OSError:
166166
pass
167167

168-
if sys.platform.startswith('win'):
169-
_install_libcpptraj_win_msys2()
170-
else:
171-
cxx_overwrite = ''
172-
173-
# We don't need this anymore?
174-
# if IS_OSX:
175-
# if ((compiler == 'clang' or 'clang' in os.getenv('CXX', '')) or
176-
# (os.getenv('CXX') and is_clang(os.getenv('CXX')))):
177-
# # cxx_overwrite = 'CXX="clang++ -stdlib=libstdc++"'
178-
print('cxx_overwrite flag', cxx_overwrite)
168+
cm = 'bash configure {build_flag} {compiler}'.format(
169+
build_flag=build_flag,
170+
compiler=compiler)
179171

180-
cm = 'bash configure {build_flag} {compiler} {cxx_overwrite}'.format(
181-
build_flag=build_flag,
182-
compiler=compiler,
183-
cxx_overwrite=cxx_overwrite)
172+
print('configure command: ', cm)
173+
subprocess.check_call(cm, shell=True)
184174

185-
print('configure command: ', cm)
186-
# do not use subprocess to avoid split cxx_overwrite command
187-
os.system(cm)
188-
189-
if IS_OSX:
190-
add_cpptraj_cxx_to_config('config.h', CPPTRAJ_CXX)
175+
if IS_OSX:
176+
add_cpptraj_cxx_to_config('config.h', CPPTRAJ_CXX)
191177

192-
subprocess.check_call('make libcpptraj -j{}'.format(n_cpus).split())
193-
os.chdir(cwd)
178+
subprocess.check_call('make libcpptraj -j{}'.format(n_cpus).split())
179+
os.chdir(cwd)
194180

195181

196182
def parse_args():

0 commit comments

Comments
 (0)