Skip to content
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

Migrate from setup.py to pyproject.toml #1929

Merged
merged 29 commits into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9d15c48
Migrate from setup.py to pyproject.toml.
Kami Aug 2, 2023
fe4772c
Utilize build package for creating sdist (.tar.gz) and wheel (.whl) r…
Kami Aug 3, 2023
6e0a42c
Update development docs to utilize pytest instead of old and deprecated
Kami Aug 3, 2023
14f049b
Remove more-itertools tests dependency which should not be needed any…
Kami Aug 4, 2023
6b7ae62
Clarify that build package is used for creating release artifacts.
Kami Aug 4, 2023
cb25312
Add changelog entries.
Kami Aug 4, 2023
b1b3149
Fix changelog formatting.
Kami Aug 4, 2023
5efa745
Merge branch 'trunk' into migrate_from_setuppy_to_pyproject_toml
Kami Aug 4, 2023
033938d
Merge branch 'trunk' into migrate_from_setuppy_to_pyproject_toml
Kami Aug 4, 2023
935f0d3
Redirect setup.py --version stderr to /dev/null to supress non-fatal
Kami Aug 6, 2023
023d32e
Merge branch 'trunk' into migrate_from_setuppy_to_pyproject_toml
Kami Aug 6, 2023
e6c7ab9
Remove unused imports, add a comment on why setup.py file is still
Kami Aug 6, 2023
8a0f870
Update year header in the license file.
Kami Aug 6, 2023
f30849f
Update year in the copyright notice in the docs.
Kami Aug 6, 2023
797f003
Remove some shellcheck warnings, make dist scripts more robust.
Kami Aug 6, 2023
3a2f1ef
Use valid and normalized version specific for __version__ for dev
Kami Aug 6, 2023
5db7cc4
Use bash shell instead of sh.
Kami Aug 6, 2023
4a60dec
More shellcheck violation fixes.
Kami Aug 6, 2023
8d19e4b
Shell check violation fixes in the sign script.
Kami Aug 6, 2023
fcf253d
Fix shellcheck violations in the verify checksums script.
Kami Aug 6, 2023
062567c
Also run shellcheck on CI (for now only fixed scripts in dist/
Kami Aug 6, 2023
9f258b7
Remove old contrib script which is not needed anymore.
Kami Aug 6, 2023
672bc4a
Fix shellcheck violations in the pre-commit script.
Kami Aug 6, 2023
8b19a27
Also run shellcheck on contrib scripts on the CI.
Kami Aug 6, 2023
8e73fde
Merge branch 'migrate_from_setuppy_to_pyproject_toml' of github.com:k…
Kami Aug 6, 2023
249fc3e
Add changelog entry.
Kami Aug 6, 2023
926a26d
Update dist install check scripts to not invoke setup.py directly
Kami Aug 6, 2023
274f41a
Add a comment on known pyproject homepage field related issue.
Kami Aug 6, 2023
0750a08
Explicitly set content type for readme file in pyproject.toml.
Kami Aug 6, 2023
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
6 changes: 5 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,11 @@ jobs:
run: |
pip install -r requirements-ci.txt
- name: Run Checks
- name: Run shellcheck
run: |
shellcheck dist/*.sh contrib/*.sh
- name: Run Python Checks
run: |
tox -e black-check,isort-check,pyupgrade,checks,import-timings,lint,pylint
Expand Down
18 changes: 17 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,22 @@ Other
2016.
[Tomaz Muraus - @Kami]

- Packaging related metadata has been migrated from ``setup.py`` to
``pyproject.yaml`` file.
(GITHUB-1929)
[Tomaz Muraus - @Kami]

- Deprecated and unsafe ``setup.py test`` convenience alias for running tests
using pytest has been removed in favor of running pytest directly.
(GITHUB-1929)
[Tomaz Muraus - @Kami]

- Script for building release artifacts has been updated to utilize ``build``
Python package to build release artifacts (sdist + wheel) in an isolated
environment.
(GITHUB-1929)
[Tomaz Muraus - @Kami]

Changes in Apache Libcloud 3.7.0
--------------------------------

Expand All @@ -126,7 +142,7 @@ Compute

- [CloudSigma] Update API URLs for US locations.
(GITHUB-1781)
[Mohsen Hassani - @ mohsen-hassani-cs]
[Mohsen Hassani - @mohsen-hassani-cs]

- [GCP] Fix OAuth2 desktop client login.
(GITHUB-1806, GITHUB-1807)
Expand Down
23 changes: 7 additions & 16 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
global-exclude *.py[cod]
global-exclude .pytest_cache
include LICENSE
include NOTICE
include example_*.py
Expand All @@ -8,21 +10,10 @@ include pyproject.toml
include requirements-tests.txt
include requirements-lint.txt
include libcloud/data/pricing.json
prune libcloud/test/secrets.py
prune requirements-rtd.txt
include demos/*
include scripts/check_file_names.sh
include libcloud/test/*.py
include libcloud/test/pricing_test.json
include libcloud/test/secrets.py-dist
include libcloud/test/common/*.py
include libcloud/test/compute/*.py
include libcloud/test/storage/*.py
include libcloud/test/loadbalancer/*.py
include libcloud/test/dns/*.py
include libcloud/test/common/fixtures/*/*
include libcloud/test/compute/fixtures/*/*
include libcloud/test/compute/fixtures/*/*/*
include libcloud/test/storage/fixtures/*/*
include libcloud/test/loadbalancer/fixtures/*/*
include libcloud/test/dns/fixtures/*/*
recursive-exclude libcloud/test secrets.py
prune libcloud/test/secrets.py
prune requirements-rtd.txt
prune dist
prune build
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Apache Libcloud
Copyright (c) 2010-2020 The Apache Software Foundation
Copyright (c) 2010-2023 The Apache Software Foundation

This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
Expand Down
65 changes: 0 additions & 65 deletions contrib/migrate_paths.sh

This file was deleted.

7 changes: 5 additions & 2 deletions contrib/pre-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
set -e

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

for file in "${array[@]}"
do
echo "Processing: ${file}"
if [[ ${file} =~ "libcloud/test/" ]]; then
flake8 --max-line-length=160 ${file}
flake8 --max-line-length=160 "${file}"
else
flake8 ${file}
flake8 "${file}"
fi
done
22 changes: 15 additions & 7 deletions dist/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
Expand All @@ -13,15 +13,23 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

cd ..
pushd "${SCRIPT_DIR}/../"

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

cd dist
pushd "${SCRIPT_DIR}"

echo "Uploading packages"
ls *$VERSION*.tar.gz *$VERSION*.whl *$VERSION*.tar.gz.asc
# shellcheck disable=SC2086
ls ./*$VERSION*.tar.gz ./*$VERSION*.whl ./*$VERSION*.tar.gz.asc
# shellcheck disable=SC2086
twine upload ./*$VERSION*.tar.gz ./*$VERSION*.whl ./*$VERSION*.tar.gz.asc

twine upload *$VERSION*.tar.gz *$VERSION*.whl *$VERSION*.tar.gz.asc
popd
20 changes: 12 additions & 8 deletions dist/release.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
Expand All @@ -13,9 +13,10 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)

user=""
case "$1" in
-u)
Expand All @@ -30,12 +31,15 @@ if test -z "${user}"; then
exit 1
fi

cd ..
pushd "${SCRIPT_DIR}/../"

python -m build

popd

python setup.py sdist --formats=bztar,zip,gztar
python setup.py bdist_wheel
pushd "${SCRIPT_DIR}"

cd dist
./hash.py ./*.tar.gz ./*.whl
./sign.sh -u "${user}" ./*.tar.gz ./*.whl

./hash.py *.tar.bz2 *.tar.gz *.zip *.whl
./sign.sh -u ${user} *.tar.bz2 *.tar.gz *.zip *.whl
popd
13 changes: 8 additions & 5 deletions dist/sign.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
Expand All @@ -18,6 +18,7 @@
#
# USAGE: sign.sh -u user file1 file2 ...
#
set -e

user=""
case "$1" in
Expand All @@ -32,8 +33,8 @@ allfiles=$*



gpg="`which gpg 2> /dev/null | head -1`"
pgp="`which pgp 2> /dev/null | head -1`"
gpg=$(which gpg 2> /dev/null | head -1)
pgp=$(which pgp 2> /dev/null | head -1)

echo "---------------------------------------------------------------------"
echo ""
Expand All @@ -48,7 +49,8 @@ if test -x "${pgp}"; then
for file in ${allfiles}; do
if test -f "${file}"; then
echo "pgp: creating asc signature file for ${file} ..."
${pgp} -sba ${file} ${args}
# shellcheck disable=SC2086
"${pgp}" -sba "${file}" ${args}
fi
done
# no pgp found - check for gpg
Expand All @@ -61,7 +63,8 @@ elif test -x "${gpg}"; then
for file in ${allfiles}; do
if test -f "${file}"; then
echo "gpg: creating asc signature file for ${file} ..."
${gpg} --armor ${args} --detach-sign ${file}
# shellcheck disable=SC2086
"${gpg}" --armor ${args} --detach-sign "${file}"
fi
done
else
Expand Down
11 changes: 7 additions & 4 deletions dist/verify_checksums.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VERSION=$1

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

Expand Down Expand Up @@ -70,7 +70,8 @@ do
file_name="${VERSION}${extension}"

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

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

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

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

if [ ${sha512sum_apache} != ${sha512sum_pypi} ]; then
echo "[ERROR] SHA512 sum for file ${file_name} doesn\'t match"
if [ "${sha512sum_apache}" != "${sha512sum_pypi}" ]; then
echo "[ERROR] SHA512 sum for file ${file_name} doesn't match"
echo ""
echo "${file_name_apache}: ${sha512sum_apache}"
echo "${file_name_pypi}: ${sha512sum_pypi}"
Expand Down
25 changes: 16 additions & 9 deletions docs/committer_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -97,24 +97,27 @@ preparing a release.

.. note::

It's important that you have the latest versions of ``setuptools``, ``wheel``
and ``pip`` installed to ensure the generated wheel files contain correct
metadata.
It's important that you have the latest versions of ``build`` package
installed to ensure the generated wheel files contain correct metadata.

We have a script that runs the required setup.py commands and then hashes
and signs the files. You will need the latest version of ``pip`` and the ``wheel``
package. To run it:
We have a script that runs the required commands and then hashes and signs the
files. You will need the latest version of ``build`` package.

To run it:

.. sourcecode:: bash

# Install build dependencies
pip install -e ".[build]"

cd dist
./release.sh -u <yourusername>@apache.org

``-u`` argument will be used to find a key with a matching email address in
your local GPG database.

This should result in a set of
``apache-libcloud-${VERSION}.{tar.bz2,tar.gz,zip,whl}{,asc,md5,sha1}`` files that
``apache-libcloud-${VERSION}.{tar.gz,whl}{,asc,md5,sha1}`` files that
are suitable to be uploaded for a release.

Copy the artifacts in another directory, unpack one of them and test it with ``tox``.
Expand Down Expand Up @@ -173,11 +176,15 @@ key.
7. Publishing package to PyPi
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We have a script that runs uploads the signed Python source files to PyPi. It uses twine, so ensure
you have twine available in your path `which twine` before running. Twine can be downloaded from https://pypi.python.org/pypi/twine
We have a script that runs uploads the signed Python source files to PyPi. It
uses twine, so ensure you have twine available in your path `which twine`
before running. Twine can be downloaded from https://pypi.python.org/pypi/twine

.. sourcecode:: bash

# Install publish dependencies
pip install -e ".[publish]"

cd dist
./deploy.sh

Expand Down
Loading