Skip to content

Commit

Permalink
Update xcookie
Browse files Browse the repository at this point in the history
  • Loading branch information
Erotemic committed Apr 27, 2024
1 parent 839d56f commit 943a8d6
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 24 deletions.
31 changes: 21 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
- name: Typecheck with mypy
run: |-
python -m pip install mypy
pip install -r requirements/runtime.txt
mypy --install-types --non-interactive ./line_profiler
mypy ./line_profiler
build_and_test_sdist:
Expand Down Expand Up @@ -80,7 +81,7 @@ jobs:
# Get path to installed package
MOD_DPATH=$(python -c "import line_profiler, os; print(os.path.dirname(line_profiler.__file__))")
echo "MOD_DPATH = $MOD_DPATH"
python -m pytest --verbose --cov={self.mod_name} $MOD_DPATH ../tests
python -m pytest --verbose --cov=line_profiler $MOD_DPATH ../tests
cd ..
- name: Test full loose sdist
run: |-
Expand All @@ -95,7 +96,7 @@ jobs:
# Get path to installed package
MOD_DPATH=$(python -c "import line_profiler, os; print(os.path.dirname(line_profiler.__file__))")
echo "MOD_DPATH = $MOD_DPATH"
python -m pytest --verbose --cov={self.mod_name} $MOD_DPATH ../tests
python -m pytest --verbose --cov=line_profiler $MOD_DPATH ../tests
cd ..
- uses: actions/[email protected]
name: Upload sdist artifact
Expand Down Expand Up @@ -138,7 +139,7 @@ jobs:
with:
platforms: all
- name: Build binary wheels
uses: pypa/cibuildwheel@v2.16.5
uses: pypa/cibuildwheel@v2.17.0
with:
output-dir: wheelhouse
config-file: pyproject.toml
Expand Down Expand Up @@ -185,6 +186,7 @@ jobs:
# environment.
##
name: ${{ matrix.python-version }} on ${{ matrix.os }}, arch=${{ matrix.arch }} with ${{ matrix.install-extras }}
if: "! startsWith(github.event.ref, 'refs/heads/release')"
runs-on: ${{ matrix.os }}
needs:
- build_binpy_wheels
Expand All @@ -200,7 +202,7 @@ jobs:
arch: auto
- python-version: '3.6'
install-extras: tests-strict,runtime-strict
os: macOS-latest
os: macos-13
arch: auto
- python-version: '3.6'
install-extras: tests-strict,runtime-strict
Expand Down Expand Up @@ -342,6 +344,9 @@ jobs:
pip install tomli pkginfo
export WHEEL_FPATH=$(python -c "import pathlib; print(str(sorted(pathlib.Path('wheelhouse').glob('line_profiler*.whl'))[-1]).replace(chr(92), chr(47)))")
export MOD_VERSION=$(python -c "from pkginfo import Wheel; print(Wheel('$WHEEL_FPATH').version)")
echo "$WHEEL_FPATH=WHEEL_FPATH"
echo "$INSTALL_EXTRAS=INSTALL_EXTRAS"
echo "$MOD_VERSION=MOD_VERSION"
pip install --prefer-binary "line_profiler[$INSTALL_EXTRAS]==$MOD_VERSION" -f wheelhouse
echo "Install finished."
- name: Test wheel ${{ matrix.install-extras }}
Expand All @@ -359,14 +364,15 @@ jobs:
ls -altr
# Get the path to the installed package and run the tests
export MOD_DPATH=$(python -c "import line_profiler, os; print(os.path.dirname(line_profiler.__file__))")
export MOD_NAME=line_profiler
echo "
---
MOD_DPATH = $MOD_DPATH
---
running the pytest command inside the workspace
---
"
python -m pytest --verbose -p pytester -p no:doctest --xdoctest --cov-config ../pyproject.toml --cov-report term --cov="line_profiler" "$MOD_DPATH" ../tests
python -m pytest --verbose -p pytester -p no:doctest --xdoctest --cov-config ../pyproject.toml --cov-report term --durations=100 --cov="$MOD_NAME" "$MOD_DPATH" ../tests
echo "pytest command finished, moving the coverage file to the repo root"
ls -al
# Move coverage file to a new name
Expand Down Expand Up @@ -399,9 +405,8 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && ! startsWith(github.event.ref, 'refs/tags') && ! startsWith(github.event.ref, 'refs/heads/release')
needs:
- build_and_test_sdist
- build_binpy_wheels
- test_binpy_wheels
- build_and_test_sdist
steps:
- name: Checkout source
uses: actions/[email protected]
Expand Down Expand Up @@ -474,9 +479,8 @@ jobs:
runs-on: ubuntu-latest
if: github.event_name == 'push' && (startsWith(github.event.ref, 'refs/tags') || startsWith(github.event.ref, 'refs/heads/release'))
needs:
- build_and_test_sdist
- build_binpy_wheels
- test_binpy_wheels
- build_and_test_sdist
steps:
- name: Checkout source
uses: actions/[email protected]
Expand Down Expand Up @@ -564,6 +568,12 @@ jobs:
shell: bash
run: ls -la wheelhouse
- run: 'echo "Automatic Release Notes. TODO: improve" > ${{ github.workspace }}-CHANGELOG.txt'
- name: Tag Release Commit
if: (startsWith(github.event.ref, 'refs/heads/release'))
run: |-
export VERSION=$(python -c "import setup; print(setup.VERSION)")
git tag "v$VERSION"
git push origin "v$VERSION"
- uses: softprops/action-gh-release@v1
name: Create Release
id: create_release
Expand All @@ -572,8 +582,9 @@ jobs:
with:
body_path: ${{ github.workspace }}-CHANGELOG.txt
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
name: Release ${{ github.ref }}
body: Automatic Release
generate_release_notes: true
draft: true
prerelease: false
files: |-
Expand Down
31 changes: 26 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
### For gitlab
The user will need to enable the repo on their readthedocs account:
https://readthedocs.org/dashboard/import/manual/?
To enable the read-the-docs go to https://readthedocs.org/dashboard/ and login
Make sure you have a .readthedocs.yml file
The user will need to enable the repo on their readthedocs account:
https://readthedocs.org/dashboard/import/manual/?
Click import project: (for github you can select, but gitlab you need to import manually)
Enter the following information:
Set the Repository NAME: line_profiler
Set the Repository URL: https://github.com/pyutils/line_profiler
Make sure you have a .readthedocs.yml file
For gitlab you also need to setup an integrations. Navigate to:
https://readthedocs.org/dashboard/line-profiler/integrations/create/
Expand Down Expand Up @@ -184,6 +184,16 @@ def visit_Assign(self, node):

autodoc_inherit_docstrings = False

# Hack for geowatch, todo configure
autosummary_mock_imports = [
'geowatch.utils.lightning_ext._jsonargparse_ext_ge_4_24_and_lt_4_xx',
'geowatch.utils.lightning_ext._jsonargparse_ext_ge_4_22_and_lt_4_24',
'geowatch.utils.lightning_ext._jsonargparse_ext_ge_4_21_and_lt_4_22',
'geowatch.tasks.fusion.datamodules.temporal_sampling.affinity_sampling',
'geowatch.tasks.depth_pcd.model',
'geowatch.tasks.cold.export_change_map',
]

autodoc_member_order = 'bysource'
autoclass_content = 'both'
# autodoc_mock_imports = ['torch', 'torchvision', 'visdom']
Expand Down Expand Up @@ -496,6 +506,17 @@ def text_art(lines):
new_lines.extend(lines[1:])
return new_lines

# @self.register_section(tag='TODO', alias=['.. todo::'])
# def todo_section(lines):
# """
# Fixup todo sections
# """
# import xdev
# xdev.embed()
# import ubelt as ub
# print('lines = {}'.format(ub.urepr(lines, nl=1)))
# return new_lines

@self.register_section(tag='Ignore')
def ignore(lines):
return []
Expand Down
93 changes: 84 additions & 9 deletions publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ Args:
If True, sign the packages with a GPG key specified by `GPG_KEYID`.
defaults to auto.
DO_OTS (bool) :
If True, make an opentimestamp for the package and signature (if
available)
DO_UPLOAD (bool) :
If True, upload the packages to the pypi server specified by
`TWINE_REPOSITORY_URL`.
Expand Down Expand Up @@ -138,18 +142,29 @@ DO_UPLOAD=${DO_UPLOAD:=$ARG_1}
DO_TAG=${DO_TAG:=$ARG_1}

DO_GPG=${DO_GPG:="auto"}
# Verify that we want to build
if [ "$DO_GPG" == "auto" ]; then
DO_GPG="True"
fi

DO_OTS=${DO_OTS:="auto"}
if [ "$DO_OTS" == "auto" ]; then
# Do opentimestamp if it is available
# python -m pip install opentimestamps-client
if type ots ; then
DO_OTS="True"
else
DO_OTS="False"
fi
fi

DO_BUILD=${DO_BUILD:="auto"}
# Verify that we want to build
if [ "$DO_BUILD" == "auto" ]; then
DO_BUILD="True"
fi

DO_GPG=$(normalize_boolean "$DO_GPG")
DO_OTS=$(normalize_boolean "$DO_OTS")
DO_BUILD=$(normalize_boolean "$DO_BUILD")
DO_UPLOAD=$(normalize_boolean "$DO_UPLOAD")
DO_TAG=$(normalize_boolean "$DO_TAG")
Expand Down Expand Up @@ -237,6 +252,7 @@ GPG_KEYID = '$GPG_KEYID'
DO_UPLOAD=${DO_UPLOAD}
DO_TAG=${DO_TAG}
DO_GPG=${DO_GPG}
DO_OTS=${DO_OTS}
DO_BUILD=${DO_BUILD}
MODE_LIST_STR=${MODE_LIST_STR}
"
Expand Down Expand Up @@ -375,7 +391,7 @@ ls_array(){
}


WHEEL_PATHS=()
WHEEL_FPATHS=()
for _MODE in "${MODE_LIST[@]}"
do
if [[ "$_MODE" == "sdist" ]]; then
Expand All @@ -393,32 +409,32 @@ do
for new_item in "${_NEW_WHEEL_PATHS[@]}"
do
if [[ "$new_item" != "" ]]; then
WHEEL_PATHS+=("$new_item")
WHEEL_FPATHS+=("$new_item")
fi
done
done

# Dedup the paths
readarray -t WHEEL_PATHS < <(printf '%s\n' "${WHEEL_PATHS[@]}" | sort -u)
readarray -t WHEEL_FPATHS < <(printf '%s\n' "${WHEEL_FPATHS[@]}" | sort -u)

WHEEL_PATHS_STR=$(printf '"%s" ' "${WHEEL_PATHS[@]}")
WHEEL_PATHS_STR=$(printf '"%s" ' "${WHEEL_FPATHS[@]}")
echo "WHEEL_PATHS_STR = $WHEEL_PATHS_STR"

echo "
MODE=$MODE
VERSION='$VERSION'
WHEEL_PATHS='$WHEEL_PATHS_STR'
WHEEL_FPATHS='$WHEEL_PATHS_STR'
"



WHEEL_SIGNATURE_FPATHS=()
if [ "$DO_GPG" == "True" ]; then

echo "
=== <GPG SIGN> ===
"

for WHEEL_FPATH in "${WHEEL_PATHS[@]}"
for WHEEL_FPATH in "${WHEEL_FPATHS[@]}"
do
echo "WHEEL_FPATH = $WHEEL_FPATH"
check_variable WHEEL_FPATH
Expand All @@ -439,6 +455,8 @@ if [ "$DO_GPG" == "True" ]; then

echo "Verifying wheels"
$GPG_EXECUTABLE --verify "$WHEEL_FPATH".asc "$WHEEL_FPATH" || { echo 'could not verify wheels' ; exit 1; }

WHEEL_SIGNATURE_FPATHS+=("$WHEEL_FPATH".asc)
done
echo "
=== <END GPG SIGN> ===
Expand All @@ -448,6 +466,27 @@ else
fi



if [ "$DO_OTS" == "True" ]; then

echo "
=== <OTS SIGN> ===
"
if [ "$DO_GPG" == "True" ]; then
# Stamp the wheels and the signatures
ots stamp "${WHEEL_FPATHS[@]}" "${WHEEL_SIGNATURE_FPATHS[@]}"
else
# Stamp only the wheels
ots stamp "${WHEEL_FPATHS[@]}"
fi
echo "
=== <END OTS SIGN> ===
"
else
echo "DO_OTS=False, Skipping OTS sign"
fi


if [[ "$DO_TAG" == "True" ]]; then
TAG_NAME="v${VERSION}"
# if we messed up we can delete the tag
Expand All @@ -467,7 +506,7 @@ if [[ "$DO_UPLOAD" == "True" ]]; then
check_variable TWINE_USERNAME
check_variable TWINE_PASSWORD "hide"

for WHEEL_FPATH in "${WHEEL_PATHS[@]}"
for WHEEL_FPATH in "${WHEEL_FPATHS[@]}"
do
twine upload --username "$TWINE_USERNAME" "--password=$TWINE_PASSWORD" \
--repository-url "$TWINE_REPOSITORY_URL" \
Expand Down Expand Up @@ -496,3 +535,39 @@ else
!!! FINISH: DRY RUN !!!
"""
fi

__devel__='
# Checking to see how easy it is to upload packages to gitlab.
# This logic should go in the CI script, not sure if it belongs here.
export HOST=https://gitlab.kitware.com
export GROUP_NAME=computer-vision
export PROJECT_NAME=geowatch
PROJECT_VERSION=$(geowatch --version)
echo "$PROJECT_VERSION"
load_secrets
export PRIVATE_GITLAB_TOKEN=$(git_token_for "$HOST")
TMP_DIR=$(mktemp -d -t ci-XXXXXXXXXX)
curl --header "PRIVATE-TOKEN: $PRIVATE_GITLAB_TOKEN" "$HOST/api/v4/groups" > "$TMP_DIR/all_group_info"
GROUP_ID=$(cat "$TMP_DIR/all_group_info" | jq ". | map(select(.name==\"$GROUP_NAME\")) | .[0].id")
echo "GROUP_ID = $GROUP_ID"
curl --header "PRIVATE-TOKEN: $PRIVATE_GITLAB_TOKEN" "$HOST/api/v4/groups/$GROUP_ID" > "$TMP_DIR/group_info"
PROJ_ID=$(cat "$TMP_DIR/group_info" | jq ".projects | map(select(.name==\"$PROJECT_NAME\")) | .[0].id")
echo "PROJ_ID = $PROJ_ID"
ls_array DIST_FPATHS "dist/*"
for FPATH in "${DIST_FPATHS[@]}"
do
FNAME=$(basename $FPATH)
echo $FNAME
curl --header "PRIVATE-TOKEN: $PRIVATE_GITLAB_TOKEN" \
--upload-file $FPATH \
"https://gitlab.kitware.com/api/v4/projects/$PROJ_ID/packages/generic/$PROJECT_NAME/$PROJECT_VERSION/$FNAME"
done
'

0 comments on commit 943a8d6

Please sign in to comment.