Skip to content

Removed dev dependencies for deb and rpm #463

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

Merged
merged 4 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 24 additions & 11 deletions build_scripts/debian/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ fi
local_repo=$1

sudo apt-get update
# required to run the 'make install'
sudo apt-get install -y zlib1g-dev

# the ',,' makes environment variable lower case in Bash 4+
if [ "${MSSQL_CLI_OFFICIAL_BUILD,,}" != "true" ]
Expand Down Expand Up @@ -39,34 +41,47 @@ rm -rf $source_dir/../debian_output
[ -d $local_repo/privates ] && cp $local_repo/privates/*.whl $tmp_pkg_dir

# Build Python from source and include
python_dir=$(mktemp -d)
python_archive=$(mktemp)
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive

# A copy of Python is created for build dependencies only
python_dir=$(mktemp -d)
python_dir_build=$(mktemp -d)
tar -xvzf $python_archive -C $python_dir
tar -xvzf $python_archive -C $python_dir_build
echo "Python dir is $python_dir"
echo "Python build dir is $python_dir_build"

# clean any previous make files
make clean || echo "Nothing to clean"

$python_dir/*/configure --srcdir $python_dir/* --prefix $source_dir/python_env
make
# required to run the 'make install'
sudo apt-get install -y zlib1g-dev
make install

# Set env var to ensure build.py uses the python we built from source.
export CUSTOM_PYTHON=$source_dir/python_env/bin/python3
export CUSTOM_PIP=$source_dir/python_env/bin/pip3
$python_dir_build/*/configure --srcdir $python_dir_build/* --prefix $source_dir/python_build
make
make install

# Download dependencies needed to run build stage
# upgrade pip
$source_dir/python_env/bin/python3 -m pip install --upgrade pip
$source_dir/python_env/bin/python3 -m pip install -r $source_dir/requirements-dev.txt
$source_dir/python_build/bin/python3 -m pip install --upgrade pip

# Download dependencies needed to run build stage
$source_dir/python_build/bin/python3 -m pip install -r $source_dir/requirements-dev.txt

# Set env var to ensure build.py uses the python we built from source.
export CUSTOM_PYTHON=$source_dir/python_build/bin/python3
export CUSTOM_PIP=$source_dir/python_build/bin/pip3

# Build mssql-cli wheel from source.
cd $source_dir
$source_dir/python_env/bin/python3 $source_dir/build.py build
$source_dir/python_build/bin/python3 $source_dir/build.py build
cd -

# Remove python build version after build completes
rm -rf $source_dir/python_build

# Install mssql-cli wheel.
dist_dir=$source_dir/dist

Expand All @@ -86,6 +101,4 @@ cp -r $cli_debian_dir_tmp/* $source_dir/debian
cd $source_dir
dpkg-buildpackage -us -uc
cp $deb_file $source_dir/../debian_output
# Create a second copy for latest dev version to be used by homepage.
cp $deb_file $source_dir/../debian_output/mssql-cli-dev-latest.deb
echo "The archive has also been outputted to $source_dir/../debian_output"
2 changes: 0 additions & 2 deletions build_scripts/rpm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,4 @@ rpmbuild -v -bb --clean ${REPO_PATH}/build_scripts/rpm/mssql-cli.spec
# Copy build artifact to output dir.
mkdir ${REPO_PATH}/../rpm_output
cp ~/rpmbuild/RPMS/x86_64/*.rpm ${REPO_PATH}/../rpm_output
# Create a second copy for latest dev version to be used by homepage.
cp ~/rpmbuild/RPMS/x86_64/*.rpm ${REPO_PATH}/../rpm_output/mssql-cli-dev-latest.rpm
echo "The archive has also been outputted to ${REPO_PATH}/../rpm_output"
44 changes: 29 additions & 15 deletions build_scripts/rpm/mssql-cli.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@
%define dist .el7
%endif

%define name mssql-cli
%define release 1%{?dist}
%define time_stamp %(date +%y%m%d%H%M)
%define base_version 1.0.0
%define python_dir %{_builddir}/python_env
%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
%define cli_lib_dir %{_libdir}/mssql-cli
%define repo_path %{getenv:REPO_PATH}
%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD}
%define name mssql-cli
%define release 1%{?dist}
%define time_stamp %(date +%y%m%d%H%M)
%define base_version 1.0.0
%define python_dir %{_builddir}/python_env
%define python_build_src /root/python_build_src
%define python_build /root/python_build
%define python_url https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
%define cli_lib_dir %{_libdir}/mssql-cli
%define repo_path %{getenv:REPO_PATH}
%define official_build %{getenv:MSSQL_CLI_OFFICIAL_BUILD}

# the ',,' makes environment variable lower case in Bash 4+
%if "%{official_build}" != "true"
Expand Down Expand Up @@ -48,10 +50,14 @@ Requires: libunwind, libicu, less
%prep
# Clean previous build directory.
rm -rf %{_builddir}/*
rm -rf %{python_build_src}

# Download, Extract Python3
mkdir %{python_build_src}
python_archive=$(mktemp)
wget https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz -qO $python_archive
tar -xvzf $python_archive -C %{_builddir}
tar -xvzf $python_archive -C %{python_build_src}

%build
# clean any previous make files
Expand All @@ -62,15 +68,23 @@ make clean || echo "Nothing to clean"
make
make install

# Install Python dependencies for build
# A copy of Python is created for build dependencies only
%{python_build_src}/*/configure --srcdir %{python_build_src}/* --prefix %{python_build}
make
make install

# Update pip
%{python_dir}/bin/pip3 install --upgrade pip
%{python_dir}/bin/pip3 install -r %{repo_path}/requirements-dev.txt
%{python_build}/bin/pip3 install --upgrade pip

# Build mssql-cli wheel from source.
export CUSTOM_PYTHON=%{python_dir}/bin/python3
export CUSTOM_PIP=%{python_dir}/bin/pip3
# Install Python dependencies and build from source
export CUSTOM_PYTHON=%{python_build}/bin/python3
export CUSTOM_PIP=%{python_build}/bin/pip3
%{python_build}/bin/pip3 install -r %{repo_path}/requirements-dev.txt
%{python_build}/bin/python3 %{repo_path}/build.py build

%{python_dir}/bin/python3 %{repo_path}/build.py build
# Remove python build version after build completes
rm -rf %{python_build}

%install
# Install mssql-cli
Expand Down