Skip to content

Commit 17ea217

Browse files
authored
Merge pull request #1929 from Kami/migrate_from_setuppy_to_pyproject_toml
Migrate from setup.py to pyproject.toml
2 parents e76621a + 0750a08 commit 17ea217

20 files changed

+223
-408
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,11 @@ jobs:
195195
run: |
196196
pip install -r requirements-ci.txt
197197
198-
- name: Run Checks
198+
- name: Run shellcheck
199+
run: |
200+
shellcheck dist/*.sh contrib/*.sh
201+
202+
- name: Run Python Checks
199203
run: |
200204
tox -e black-check,isort-check,pyupgrade,checks,import-timings,lint,pylint
201205

CHANGES.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,22 @@ Other
108108
2016.
109109
[Tomaz Muraus - @Kami]
110110

111+
- Packaging related metadata has been migrated from ``setup.py`` to
112+
``pyproject.yaml`` file.
113+
(GITHUB-1929)
114+
[Tomaz Muraus - @Kami]
115+
116+
- Deprecated and unsafe ``setup.py test`` convenience alias for running tests
117+
using pytest has been removed in favor of running pytest directly.
118+
(GITHUB-1929)
119+
[Tomaz Muraus - @Kami]
120+
121+
- Script for building release artifacts has been updated to utilize ``build``
122+
Python package to build release artifacts (sdist + wheel) in an isolated
123+
environment.
124+
(GITHUB-1929)
125+
[Tomaz Muraus - @Kami]
126+
111127
Changes in Apache Libcloud 3.7.0
112128
--------------------------------
113129

@@ -126,7 +142,7 @@ Compute
126142

127143
- [CloudSigma] Update API URLs for US locations.
128144
(GITHUB-1781)
129-
[Mohsen Hassani - @ mohsen-hassani-cs]
145+
[Mohsen Hassani - @mohsen-hassani-cs]
130146

131147
- [GCP] Fix OAuth2 desktop client login.
132148
(GITHUB-1806, GITHUB-1807)

MANIFEST.in

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
global-exclude *.py[cod]
2+
global-exclude .pytest_cache
13
include LICENSE
24
include NOTICE
35
include example_*.py
@@ -8,21 +10,10 @@ include pyproject.toml
810
include requirements-tests.txt
911
include requirements-lint.txt
1012
include libcloud/data/pricing.json
11-
prune libcloud/test/secrets.py
12-
prune requirements-rtd.txt
1313
include demos/*
1414
include scripts/check_file_names.sh
15-
include libcloud/test/*.py
16-
include libcloud/test/pricing_test.json
17-
include libcloud/test/secrets.py-dist
18-
include libcloud/test/common/*.py
19-
include libcloud/test/compute/*.py
20-
include libcloud/test/storage/*.py
21-
include libcloud/test/loadbalancer/*.py
22-
include libcloud/test/dns/*.py
23-
include libcloud/test/common/fixtures/*/*
24-
include libcloud/test/compute/fixtures/*/*
25-
include libcloud/test/compute/fixtures/*/*/*
26-
include libcloud/test/storage/fixtures/*/*
27-
include libcloud/test/loadbalancer/fixtures/*/*
28-
include libcloud/test/dns/fixtures/*/*
15+
recursive-exclude libcloud/test secrets.py
16+
prune libcloud/test/secrets.py
17+
prune requirements-rtd.txt
18+
prune dist
19+
prune build

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Apache Libcloud
2-
Copyright (c) 2010-2020 The Apache Software Foundation
2+
Copyright (c) 2010-2023 The Apache Software Foundation
33

44
This product includes software developed at
55
The Apache Software Foundation (http://www.apache.org/).

contrib/migrate_paths.sh

Lines changed: 0 additions & 65 deletions
This file was deleted.

contrib/pre-commit.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@
1515
# KIND, either express or implied. See the License for the
1616
# specific language governing permissions and limitations
1717
# under the License.
18+
set -e
1819

1920
files=$(git diff --cached --name-status | grep -v ^D | awk '$1 $2 { print $2}' | grep -e .py$)
21+
# shellcheck disable=SC2206
2022
array=(${files/// })
2123

2224
for file in "${array[@]}"
2325
do
26+
echo "Processing: ${file}"
2427
if [[ ${file} =~ "libcloud/test/" ]]; then
25-
flake8 --max-line-length=160 ${file}
28+
flake8 --max-line-length=160 "${file}"
2629
else
27-
flake8 ${file}
30+
flake8 "${file}"
2831
fi
2932
done

dist/deploy.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Licensed to the Apache Software Foundation (ASF) under one or more
33
# contributor license agreements. See the NOTICE file distributed with
44
# this work for additional information regarding copyright ownership.
@@ -13,15 +13,23 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
#
16+
set -e
17+
18+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
1719

18-
cd ..
20+
pushd "${SCRIPT_DIR}/../"
1921

20-
VERSION=`python setup.py --version`
22+
# We redirect stderr to /dev/null since sometimes setuptools may print pyproject
23+
# related warning
24+
VERSION=$(python setup.py --version 2> /dev/null)
25+
popd
2126

22-
cd dist
27+
pushd "${SCRIPT_DIR}"
2328

2429
echo "Uploading packages"
25-
ls *$VERSION*.tar.gz *$VERSION*.whl *$VERSION*.tar.gz.asc
30+
# shellcheck disable=SC2086
31+
ls ./*$VERSION*.tar.gz ./*$VERSION*.whl ./*$VERSION*.tar.gz.asc
32+
# shellcheck disable=SC2086
33+
twine upload ./*$VERSION*.tar.gz ./*$VERSION*.whl ./*$VERSION*.tar.gz.asc
2634

27-
twine upload *$VERSION*.tar.gz *$VERSION*.whl *$VERSION*.tar.gz.asc
35+
popd

dist/release.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Licensed to the Apache Software Foundation (ASF) under one or more
33
# contributor license agreements. See the NOTICE file distributed with
44
# this work for additional information regarding copyright ownership.
@@ -13,9 +13,10 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
1716
set -e
1817

18+
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
19+
1920
user=""
2021
case "$1" in
2122
-u)
@@ -30,12 +31,15 @@ if test -z "${user}"; then
3031
exit 1
3132
fi
3233

33-
cd ..
34+
pushd "${SCRIPT_DIR}/../"
35+
36+
python -m build
37+
38+
popd
3439

35-
python setup.py sdist --formats=bztar,zip,gztar
36-
python setup.py bdist_wheel
40+
pushd "${SCRIPT_DIR}"
3741

38-
cd dist
42+
./hash.py ./*.tar.gz ./*.whl
43+
./sign.sh -u "${user}" ./*.tar.gz ./*.whl
3944

40-
./hash.py *.tar.bz2 *.tar.gz *.zip *.whl
41-
./sign.sh -u ${user} *.tar.bz2 *.tar.gz *.zip *.whl
45+
popd

dist/sign.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Licensed to the Apache Software Foundation (ASF) under one or more
33
# contributor license agreements. See the NOTICE file distributed with
44
# this work for additional information regarding copyright ownership.
@@ -18,6 +18,7 @@
1818
#
1919
# USAGE: sign.sh -u user file1 file2 ...
2020
#
21+
set -e
2122

2223
user=""
2324
case "$1" in
@@ -32,8 +33,8 @@ allfiles=$*
3233

3334

3435

35-
gpg="`which gpg 2> /dev/null | head -1`"
36-
pgp="`which pgp 2> /dev/null | head -1`"
36+
gpg=$(which gpg 2> /dev/null | head -1)
37+
pgp=$(which pgp 2> /dev/null | head -1)
3738

3839
echo "---------------------------------------------------------------------"
3940
echo ""
@@ -48,7 +49,8 @@ if test -x "${pgp}"; then
4849
for file in ${allfiles}; do
4950
if test -f "${file}"; then
5051
echo "pgp: creating asc signature file for ${file} ..."
51-
${pgp} -sba ${file} ${args}
52+
# shellcheck disable=SC2086
53+
"${pgp}" -sba "${file}" ${args}
5254
fi
5355
done
5456
# no pgp found - check for gpg
@@ -61,7 +63,8 @@ elif test -x "${gpg}"; then
6163
for file in ${allfiles}; do
6264
if test -f "${file}"; then
6365
echo "gpg: creating asc signature file for ${file} ..."
64-
${gpg} --armor ${args} --detach-sign ${file}
66+
# shellcheck disable=SC2086
67+
"${gpg}" --armor ${args} --detach-sign "${file}"
6568
fi
6669
done
6770
else

dist/verify_checksums.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ VERSION=$1
2121

2222
if [ ! "${VERSION}" ]; then
2323
echo "Usage: ${0} <version name>"
24-
echo "For example: ${0} apache-libcloud-3.4.0"
24+
echo "For example: ${0} apache-libcloud-3.7.0"
2525
exit 1
2626
fi
2727

@@ -70,7 +70,8 @@ do
7070
file_name="${VERSION}${extension}"
7171

7272
if [ "${extension}" = "-py2.py3-none-any.whl" ]; then
73-
file_name=$(echo ${file_name} | sed "s/apache-libcloud/apache_libcloud/g")
73+
# shellcheck disable=SC2001
74+
file_name=$(echo "${file_name}" | sed "s/apache-libcloud/apache_libcloud/g")
7475
fi
7576

7677
apache_url="${APACHE_MIRROR_URL}/${file_name}"
@@ -97,6 +98,7 @@ do
9798
echo "Downloading file from Apache mirror..."
9899
wget --quiet "${apache_url}" -O "${file_path_apache}"
99100

101+
# shellcheck disable=SC2181
100102
if [ $? -ne 0 ]; then
101103
echo "[ERR] Failed to download file: ${apache_url}"
102104
exit 2
@@ -105,6 +107,7 @@ do
105107
echo "Downloading file from PyPi mirror..."
106108
wget --quiet "${pypi_url}" -O "${file_path_pypi}"
107109

110+
# shellcheck disable=SC2181
108111
if [ $? -ne 0 ]; then
109112
echo "[ERR] Failed to download file: ${pypi_url}"
110113
exit 2
@@ -113,8 +116,8 @@ do
113116
sha512sum_apache=$(sha512sum "${file_path_apache}" | awk '{ print $1 }')
114117
sha512sum_pypi=$(sha512sum "${file_path_pypi}"| awk '{ print $1 }')
115118

116-
if [ ${sha512sum_apache} != ${sha512sum_pypi} ]; then
117-
echo "[ERROR] SHA512 sum for file ${file_name} doesn\'t match"
119+
if [ "${sha512sum_apache}" != "${sha512sum_pypi}" ]; then
120+
echo "[ERROR] SHA512 sum for file ${file_name} doesn't match"
118121
echo ""
119122
echo "${file_name_apache}: ${sha512sum_apache}"
120123
echo "${file_name_pypi}: ${sha512sum_pypi}"

0 commit comments

Comments
 (0)