Skip to content

Commit

Permalink
switch to setuptools_scm
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-c committed Oct 11, 2023
1 parent bab56aa commit 55e1460
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 69 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: record cwltool version
run: pip install -U setuptools wheel && pip install setuptools_scm[toml] && python setup.py --version
- name: build & test cwltool_module container
run: ./build-cwltool-docker.sh

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ value

.python-version

cwltool/_version.py

# Folder created when using make
cwltool_deps
docs/_build/
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include README.rst CODE_OF_CONDUCT.md CONTRIBUTING.md
include MANIFEST.in
include LICENSE.txt
include *requirements.txt mypy.ini tox.ini
include gittaggers.py Makefile cwltool.py
include Makefile cwltool.py
recursive-include mypy-stubs *.pyi *.py
include tests/*
include tests/cwl-conformance/cwltool-conftest.py
Expand Down
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ check-python3:
python --version 2>&1 | grep "Python 3"

dist/${MODULE}-$(VERSION).tar.gz: check-python3 $(SOURCES)
python setup.py sdist bdist_wheel
python -m build

## docs : make the docs
docs: FORCE
Expand Down Expand Up @@ -122,10 +122,10 @@ codespell-fix:

## format : check/fix all code indentation and formatting (runs black)
format:
black --exclude cwltool/schemas setup.py cwltool.py cwltool tests mypy-stubs
black --exclude cwltool/schemas --exclude cwltool/_version.py setup.py cwltool.py cwltool tests mypy-stubs

format-check:
black --diff --check --exclude cwltool/schemas setup.py cwltool.py cwltool tests mypy-stubs
black --diff --check --exclude cwltool/schemas setup.py --exclude cwltool/_version.py cwltool.py cwltool tests mypy-stubs

## pylint : run static code analysis on Python code
pylint: $(PYSOURCES)
Expand Down Expand Up @@ -202,11 +202,13 @@ release-test: check-python3 FORCE
./release-test.sh

release: release-test
git tag ${VERSION}
. testenv2/bin/activate && \
python testenv2/src/${MODULE}/setup.py sdist bdist_wheel && \
pip install build && \
python -m build testenv2/src/${PACKAGE} && \
pip install twine && \
twine upload testenv2/src/${MODULE}/dist/* && \
git tag ${VERSION} && git push --tags
twine upload testenv2/src/${PACKAGE}/dist/* && \
git push --tags

flake8: $(PYSOURCES)
flake8 $^
Expand Down
7 changes: 4 additions & 3 deletions build-cwltool-docker.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
set -ex
docker build --file=cwltool.Dockerfile --tag=quay.io/commonwl/cwltool_module --target module .
docker build --file=cwltool.Dockerfile --tag=quay.io/commonwl/cwltool .
engine=${ENGINE:-docker} # example: `ENGINE=podman ./build-cwltool-docker.sh`
${engine} build --file=cwltool.Dockerfile --tag=quay.io/commonwl/cwltool_module --target module .
${engine} build --file=cwltool.Dockerfile --tag=quay.io/commonwl/cwltool .

docker run -t -v /var/run/docker.sock:/var/run/docker.sock \
${engine} run -t -v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp:/tmp \
-v "$PWD":/tmp/cwltool \
quay.io/commonwl/cwltool_module /bin/sh -c \
Expand Down
3 changes: 2 additions & 1 deletion cwltool.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ RUN apk add --no-cache git gcc python3-dev libxml2-dev libxslt-dev libc-dev linu

WORKDIR /cwltool
COPY . .
RUN CWLTOOL_USE_MYPYC=1 MYPYPATH=mypy-stubs pip wheel --no-binary schema-salad \
RUN export SETUPTOOLS_SCM_PRETEND_VERSION_FOR_CWLTOOL=$(grep __version__ cwltool/_version.py | awk -F\' '{ print $2 }') ; \
CWLTOOL_USE_MYPYC=1 MYPYPATH=mypy-stubs pip wheel --no-binary schema-salad \
--wheel-dir=/wheels .[deps] # --verbose
RUN rm /wheels/schema_salad*
RUN pip install "black~=22.0"
Expand Down
42 changes: 0 additions & 42 deletions gittaggers.py

This file was deleted.

4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[build-system]
requires = [
"setuptools>=45",
"setuptools_scm[toml]>=8.0.4,<9",
"mypy==1.6.0", # also update mypy-requirements.txt
"types-requests",
"types-psutil",
Expand All @@ -14,6 +15,9 @@ requires = [
]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
write_to = "cwltool/_version.py"

[tool.black]
line-length = 100
target-version = [ "py38" ]
8 changes: 4 additions & 4 deletions release-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ then
rm -f testenv1/lib/python-wheels/setuptools* \
&& pip install --force-reinstall -U pip==${pipver} \
&& pip install setuptools==${setuptoolsver} wheel
pip install --no-build-isolation -rtest-requirements.txt ".${extras}"
pip install -rtest-requirements.txt ".${extras}"
#make test
pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install
# mkdir testenv1/not-${module}
Expand All @@ -68,7 +68,7 @@ rm -f lib/python-wheels/setuptools* \
# The following can fail if you haven't pushed your commits to ${repo}
pip install -e "git+${repo}@${HEAD}#egg=${package}${extras}"
pushd src/${package}
pip install -rtest-requirements.txt
pip install -rtest-requirements.txt build
make dist
#make test
cp dist/${package}*tar.gz ../../../testenv3/
Expand All @@ -88,7 +88,7 @@ rm -f lib/python-wheels/setuptools* \
&& pip install --force-reinstall -U pip==${pipver} \
&& pip install setuptools==${setuptoolsver} wheel
package_tar=$(find . -name "${package}*tar.gz")
pip install "-r${DIR}/test-requirements.txt" udocker
pip install "-r${DIR}/test-requirements.txt" udocker build
pip install "${package_tar}${extras}"
udocker install
mkdir out
Expand All @@ -97,7 +97,7 @@ pushd out/${package}*
make dist
make test
pip install "-r${DIR}/mypy-requirements.txt"
make mypy
make mypyc
pip uninstall -y ${package} || true; pip uninstall -y ${package} || true; make install
mkdir ../not-${module}
pushd ../not-${module}
Expand Down
14 changes: 2 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import os
import sys
import warnings
from typing import Type

import setuptools.command.egg_info as egg_info_cmd
from setuptools import setup

if os.name == "nt":
Expand All @@ -25,13 +23,6 @@
SETUP_DIR = os.path.dirname(__file__)
README = os.path.join(SETUP_DIR, "README.rst")

try:
import gittaggers

Tagger: Type[egg_info_cmd.egg_info] = gittaggers.EggInfoFromGit
except ImportError:
Tagger = egg_info_cmd.egg_info

NEEDS_PYTEST = {"pytest", "test", "ptr"}.intersection(sys.argv)
PYTEST_RUNNER = ["pytest-runner", "pytest-cov"] if NEEDS_PYTEST else []
USE_MYPYC = False
Expand Down Expand Up @@ -94,7 +85,6 @@

setup(
name="cwltool",
version="3.1",
description="Common workflow language reference implementation",
long_description=open(README).read(),
long_description_content_type="text/x-rst",
Expand Down Expand Up @@ -130,7 +120,8 @@
"deps": ["galaxy-tool-util >= 22.1.2, <23", "galaxy-util <23"],
},
python_requires=">=3.8, <4",
setup_requires=PYTEST_RUNNER,
use_scm_version=True,
setup_requires=PYTEST_RUNNER + ["setuptools_scm>=8.0.4,<9"],
test_suite="tests",
tests_require=[
"bagit >= 1.6.4, < 1.9",
Expand All @@ -142,7 +133,6 @@
],
entry_points={"console_scripts": ["cwltool=cwltool.main:run"]},
zip_safe=True,
cmdclass={"egg_info": Tagger},
classifiers=[
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
Expand Down

0 comments on commit 55e1460

Please sign in to comment.