Skip to content

Commit ffda5a6

Browse files
author
Alex Hagerman
committed
Updated CircleCI settings for full build, test and deployment to pypi test server.
1 parent 5d52fa9 commit ffda5a6

8 files changed

+272
-17
lines changed

.circleci/config.yml

+81-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,100 @@
11
version: 2
22
jobs:
33
build:
4-
docker:
5-
- image: docker/compose:1.22.0
6-
4+
machine: true
75
steps:
86
- checkout
9-
- setup_remote_docker
7+
- run:
8+
name: Start containers
9+
command: |
10+
docker-compose up -d
11+
12+
- run:
13+
name: Build x86_x64 wheels
14+
command: |
15+
docker exec project_pymssql_x86_x64_1 ./io/dev/build_manylinux_wheels.sh
1016
1117
- run:
12-
name: folder listing for debugging
13-
command: ls -al
18+
name: Build i686 wheels
19+
command: |
20+
docker exec project_pymssql_i686_1 ./io/dev/build_manylinux_wheels.sh
1421
1522
- run:
16-
name: Build docker-compose containers
23+
name: Stop containers
1724
command: |
18-
docker-compose build
25+
docker-compose down
26+
27+
- persist_to_workspace:
28+
root: /home/circleci/project
29+
paths: .
30+
31+
32+
test:
33+
machine: true
34+
steps:
35+
- attach_workspace:
36+
at: /home/circleci/project
37+
38+
- run:
39+
name: List directories to see if they persist across machine executors
40+
command: |
41+
ls -la
1942
2043
- run:
2144
name: Start containers
2245
command: |
2346
docker-compose up -d
2447
2548
- run:
26-
name: Show dists
49+
name: Test x86_x64 wheels
2750
command: |
28-
ls dists/
51+
docker exec project_pymssql_x86_x64_1 ./io/dev/test_manylinux_wheels.sh
52+
53+
- run:
54+
name: Test i686 wheels
55+
command: |
56+
docker exec project_pymssql_i686_1 ./io/dev/test_manylinux_wheels.sh
57+
58+
- run:
59+
name: Stop containers
60+
command: |
61+
docker-compose down
62+
63+
- store_test_results:
64+
path: results/
65+
66+
- store_artifacts:
67+
path: dist/
68+
69+
deploy:
70+
docker:
71+
- image: circleci/python:3.6
72+
73+
steps:
74+
- attach_workspace:
75+
at: /home/circleci/project
76+
77+
- run:
78+
name: upload to pypi
79+
command: |
80+
if [[ -v $CIRCLE_TAG ]]; then
81+
echo $CIRCLE_TAG
82+
python3 -m venv venv
83+
. venv/bin/activate
84+
pip3 install twine
85+
twine upload -u $TEST_PYPI_USERNAME -p $TEST_PYPI_PASSWORD --repository testpypi dist/*
86+
else
87+
echo "Not a tagged release $CIRCLE_TAG"
88+
fi
2989
90+
workflows:
91+
version: 2
92+
build_test_deploy:
93+
jobs:
94+
- build
95+
- test:
96+
requires:
97+
- build
98+
- deploy:
99+
requires:
100+
- test

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ docs/_build
1414
SQLAlchemy-*/
1515
SQLAlchemy-*.tar.gz
1616
freetds/
17+
.idea/

.pypirc

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[distutils]
2+
index-servers =
3+
pypi
4+
warehouse
5+
testpypi
6+
7+
[pypi]
8+
repository: https://pypi.python.org/pypi
9+
10+
[warehouse]
11+
repository: https://upload.pypi.io/legacy/
12+
13+
[testpypi]
14+
repository: https://test.pypi.org/legacy/

dev/build_manylinux_wheels.sh

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/bin/bash
2+
# Need to build linux wheel using manylinux
3+
#
4+
# https://github.com/pypa/manylinux
5+
# https://github.com/pypa/python-manylinux-demo
6+
# https://www.python.org/dev/peps/pep-0513/
7+
#
8+
# You may need to make the build script executable
9+
# chmod +x /dev/build_wheels.sh
10+
#
11+
# Standard manylinux docker containers provided by pypa. For more information see the links above.
12+
# docker pull quay.io/pypa/manylinux1_x86_64
13+
# docker pull quay.io/pypa/manylinux1_i686
14+
#
15+
# The next set of instructions will let you run the container interactively
16+
# Provide a container name so it is easier to reference later
17+
# sudo docker run --name manylinux_x86_x64 -it -d --rm -v `pwd`:/io quay.io/pypa/manylinux1_x86_64
18+
# docker ps
19+
#
20+
# Use the docker exec command to interact with our container
21+
# docker exec -it manylinux_x86_x64 ls
22+
# docker exec -it manylinux_x86_x64 ./io/dev/build_wheels.sh
23+
#
24+
# Stop the conatiner when done
25+
# docker stop manylinux_x86_x64
26+
#
27+
# These docker commands will run, build the wheel, attempt to install and then finally upload
28+
# docker run --name manylinux_x86_x64 --rm -v `pwd`:/io quay.io/pypa/manylinux1_x86_64 /io/dev/build_wheels.sh
29+
# docker run --name manylinux_i686 --rm -v `pwd`:/io quay.io/pypa/manylinux1_i686 /io/dev/build_wheels.sh
30+
#
31+
# https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
32+
set -e -x
33+
34+
# Remove freetds package distributed with the repo if present.
35+
rm -rf /io/freetds0.95
36+
37+
# Install freetds and use in build. Yum channel shows version 0.91. Retrieving latest stable release for builds.
38+
export PYMSSQL_BUILD_WITH_BUNDLED_FREETDS=1
39+
40+
rm -rf /io/freetds
41+
mkdir /io/freetds
42+
curl -sS ftp://ftp.freetds.org/pub/freetds/stable/freetds-patched.tar.gz > freetds.tar.gz
43+
tar -zxvf freetds.tar.gz -C /io/freetds --strip-components=1
44+
45+
export CFLAGS="-fPIC" # for the 64 bits version
46+
47+
pushd /io/freetds
48+
./configure --enable-msdblib \
49+
--prefix=/usr --sysconfdir=/etc/freetds --with-tdsver=7.1 \
50+
--disable-apps --disable-server --disable-pool --disable-odbc \
51+
--with-openssl=no --with-gnutls=no
52+
53+
make install
54+
popd
55+
56+
57+
#Make wheelhouse directory if it doesn't exist yet
58+
mkdir /io/wheelhouse
59+
60+
# Install Python dependencies and compile wheels
61+
for PYBIN in /opt/python/*/bin; do
62+
"${PYBIN}/pip" install --upgrade pip setuptools
63+
"${PYBIN}/pip" install pytest SQLAlchemy Sphinx sphinx-rtd-theme Cython wheel
64+
"${PYBIN}/pip" wheel /io/ -w /io/wheelhouse/
65+
done
66+
67+
# Verify the wheels and move from *-linux_* to -manylinux_*
68+
for whl in /io/wheelhouse/*.whl; do
69+
auditwheel repair "$whl" -w /io/wheelhouse/
70+
done
71+
72+
# Remove non manylinux wheels
73+
find /io/wheelhouse/ -type f ! -name '*manylinux*' -delete
74+
75+
# Create .tar.gz dist if it doesn't exists.
76+
if [ ! -f /io/dist/*tar.gz* ]; then
77+
mkdir /io/dist
78+
pushd /io/
79+
/opt/python/cp36-cp36m/bin/python setup.py sdist
80+
popd
81+
fi
82+
83+
# Move wheels to dist for install and upload
84+
mv /io/wheelhouse/* /io/dist/
85+
86+
# Remove wheel and egg directory for next container build (i686 vs x86_x64)
87+
rm -rf /io/wheelhouse/ /io/.eggs/ /io/pymssql.egg-info/
88+
89+
# Cleanup FreeTDS directories
90+
rm -rf /io/freetds/ # /io/misc/ /io/include/ /io/doc/ /io/samples/ /io/vms/ /io/wins32/
91+
92+
echo "Done building wheels."

dev/test_manylinux_wheels.sh

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
# Need to test the wheels that where build with build_manylinux_wheels.sh
3+
4+
# Rename test template file for CI
5+
mv /io/tests/tests.cfg.tpl /io/tests/tests.cfg
6+
7+
# Setup xml results folder for CI if it does not exist
8+
if [ ! -d /io/results ]; then
9+
mkdir /io/results
10+
fi
11+
12+
13+
# Install Python dependencies and compile wheels
14+
for PYBIN in /opt/python/*/bin; do
15+
"${PYBIN}/pip" install pytest SQLAlchemy Sphinx sphinx-rtd-theme Cython wheel
16+
done
17+
18+
# Install the wheels that were built. Need to be able to connect to mssql and to run the pytest suite after install
19+
for PYBIN in /opt/python/*/bin/; do
20+
"${PYBIN}/pip" install pymssql --no-index -f /io/dist
21+
"${PYBIN}/python" -c "import pymssql; pymssql.__version__;"
22+
export TEST_PY="$(${PYBIN}/python -c 'import platform; major, minor, patch = platform.python_version_tuple(); print(major+minor+patch)')"
23+
"${PYBIN}pytest" /io --junitxml=/io/results/${TEST_PY}_test_results.xml
24+
done
25+
26+
27+
## Run SQL Alchemy Tests
28+
#pushd /io
29+
#for PYBIN in /opt/python/*/bin/; do
30+
# PYV=`python -c "import sys;t='{v[0]}'.format(v=list(sys.version_info[:1]));sys.stdout.write(t)";`
31+
# if [ $PYV == '2' ]; then
32+
# pip install mock
33+
# fi
34+
# "${PYBIN}/pip" install nose
35+
# "${PYBIN}python" tests/run_sqlalchemy_tests.py
36+
#done
37+
#popd

docker-compose.yml

+15-2
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,35 @@ services:
1414
vpcbr:
1515
ipv4_address: 10.5.0.5
1616

17-
pymssql:
17+
pymssql_x86_x64:
1818
image: quay.io/pypa/manylinux1_x86_64
1919
depends_on:
2020
- sqlserver
2121
volumes:
2222
- .:/io
2323
command:
24-
./io/dev/build_wheels.sh
24+
tail -f /dev/null
2525
networks:
2626
vpcbr:
2727
ipv4_address: 10.5.0.6
2828

29+
pymssql_i686:
30+
image: quay.io/pypa/manylinux1_i686
31+
depends_on:
32+
- sqlserver
33+
volumes:
34+
- .:/io
35+
command:
36+
tail -f /dev/null
37+
networks:
38+
vpcbr:
39+
ipv4_address: 10.5.0.7
40+
2941
networks:
3042
vpcbr:
3143
driver: bridge
3244
ipam:
3345
config:
3446
- subnet: 10.5.0.0/16
3547
gateway: 10.5.0.1
48+

tests/run_sqlalchemy_tests.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
#!/usr/bin/env python
2-
3-
import ConfigParser
1+
try:
2+
import ConfigParser
3+
except ImportError:
4+
import configparser as ConfigParser
45
import os
56
import sys
67
import tarfile
78
import urllib
89

9-
SQLALCHEMY_VERSION = "1.0.11"
10+
SQLALCHEMY_VERSION = "1.2.11"
1011
SQLALCHEMY_DIR = "SQLAlchemy-%s" % SQLALCHEMY_VERSION
1112
SQLALCHEMY_TAR_GZ = "%s.tar.gz" % SQLALCHEMY_DIR
12-
SQLALCHEMY_TAR_GZ_URL = "http://pypi.python.org/packages/source/S/SQLAlchemy/%s" % SQLALCHEMY_TAR_GZ
13+
SQLALCHEMY_TAR_GZ_URL = "https://pypi.python.org/packages/source/S/SQLAlchemy/%s" % SQLALCHEMY_TAR_GZ
1314

1415

1516
def download_sqlalchemy_tarball():

tests/tests.cfg.tpl

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# in order for the tests to work correctly, the value for server
2+
# SHOULD NOT appear in any freetds.conf file.
3+
#
4+
# Ideally, the test DB server would be a non-default instance which allows full
5+
# tests of the instance and port parameters.
6+
7+
8+
[DEFAULT]
9+
server = sqlserver
10+
username = sa
11+
password = YourStrong!Passw0rd
12+
database = tempdb
13+
port = 1433
14+
ipaddress = 10.5.0.5
15+
# Instance isn't working with docker even though select @@servicename returns MSSQLSERVER
16+
# instance = MSSQLSERVER
17+
18+
# this shows all options need to run all tests
19+
[AllTestsWillRun]
20+
server = mydbserver
21+
ipaddress = 192.168.1.1
22+
username = foouser
23+
password = somepass
24+
database = testdb
25+
port = 1435
26+
instance = testinst

0 commit comments

Comments
 (0)