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

Read and install setup_requires from setup.cfg instead of hard-coding build requirements in workflow #19

Closed
wants to merge 3 commits into from
Closed
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
32 changes: 31 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ env:
# PURE: true
# NOARCH: true

STEP_GET_BUILD_REQUIREMENTS: |
SETUP_REQUIRES=$(python -c '\
import configparser as p
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using setuptools.dist.Distribution here, e.g.

from setuptools.dist import Distribution
dist = Distribution()
dist.parse_config_files()
dist.setup_requires

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nice, that is better. There will be possible env markers in the output like package; python_version < '3.8', but actually that should be handled by passing to pip with pip install -r instead of pip install - that will actually evaluate the requirements and install the appropriate packages. So instead of storing an environment variable to pass to pip, this should become

python -c 'from setuptools.dist import Distribution
dist = Distribution()
dist.parse_config_files()
print("\n".join(dist.setup_requires))' | pip install -r /dev/stdin

c = p.ConfigParser(inline_comment_prefixes=";")
c.read("setup.cfg")
requirements = c.get("options", "setup_requires").splitlines()
if "setuptools_scm" in requirements: # Just until we stop using the git version
requirements.remove("setuptools_scm")
print(*[s.replace(" ", "") for s in requirements if s])')
echo "::set-env name=SETUP_REQUIRES::$SETUP_REQUIRES"


jobs:
build:
name: Build
Expand Down Expand Up @@ -75,9 +87,15 @@ jobs:
python-version: ${{ matrix.python }}
architecture: ${{ matrix.arch }}

- name: Get Build Requirements
run: ${{ env.STEP_GET_BUILD_REQUIREMENTS }}

- name: Install Build Tools
run: |
python -m pip install --upgrade pip setuptools wheel
if [ ! -z "$SETUP_REQUIRES" ]; then
pip install $SETUP_REQUIRES
fi
pip install -U git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5

- name: Source Distribution
Expand Down Expand Up @@ -122,6 +140,9 @@ jobs:
source .miniconda/etc/profile.d/conda.sh
conda activate py${{ matrix.python }}
conda install -c cbillington setuptools_conda
if [ ! -z "$SETUP_REQUIRES" ]; then
conda install $SETUP_REQUIRES
fi
pip install -U git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5
if [ $NOARCH == true ]; then
python setup.py dist_conda --noarch
Expand Down Expand Up @@ -158,12 +179,21 @@ jobs:
git fetch --prune --unshallow
git tag -d $(git tag --points-at HEAD)

- name: Install Python
if: env.PURE == 'false'
uses: actions/setup-python@v2

- name: Get Build Requirements
if: env.PURE == 'false'
run: ${{ env.STEP_GET_BUILD_REQUIREMENTS }}

- name: Build Manylinux Wheels
if: env.PURE == 'false'
uses: RalfG/python-wheels-manylinux-build@v0.2.2-manylinux2010_x86_64
with:
python-versions: ${{ matrix.python }}
build-requirements: git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5
build-requirements: git+https://github.com/pypa/setuptools_scm.git@8e6aa2b5 ${{ env.SETUP_REQUIRES }}
pip-wheel-args: '--no-deps --no-build-isolation'

- name: Upload Artifact
if: env.PURE == 'false'
Expand Down