Skip to content

publish to PyPI as rsconnect and rsconnect-python #667

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

Merged
merged 1 commit into from
May 28, 2025
Merged
Show file tree
Hide file tree
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
17 changes: 14 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ jobs:

distributions:
needs: test
strategy:
matrix:
package_name: ["rsconnect_python", "rsconnect"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -78,14 +81,19 @@ jobs:
- uses: actions/setup-python@v4
with:
python-version: 3.8.x
- name: Install uv # see scripts/temporary-rename
uses: astral-sh/setup-uv@v6
- run: pip install -e '.[test]'
- run: pip freeze
- run: make dist
id: create_dist
env:
PACKAGE_NAME: ${{ matrix.package_name }}
- uses: actions/upload-artifact@v4
with:
name: distributions
path: dist/
if: matrix.package_name == 'rsconnect_python'
- run: pip install -vvv ${{ steps.create_dist.outputs.whl }}
- run: rsconnect version
- run: rsconnect --help
Expand All @@ -101,16 +109,19 @@ jobs:
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: ${{ secrets.AWS_REGION }}
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.package_name == 'rsconnect_python'
run: make sync-latest-to-s3
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
env:
BDIST_WHEEL: ${{ steps.create_dist.outputs.whl }}
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && matrix.package_name == 'rsconnect_python'
run: make sync-to-s3
env:
BDIST_WHEEL: ${{ steps.create_dist.outputs.whl }}
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}

docs:
needs: test
runs-on: ubuntu-latest
Expand Down
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ VERSION := $(shell python -m setuptools_scm)
HOSTNAME := $(shell hostname)
S3_PREFIX := s3://rstudio-connect-downloads/connect/rsconnect-python

BDIST_WHEEL := dist/rsconnect_python-$(VERSION)-py2.py3-none-any.whl
PACKAGE_NAME ?= rsconnect_python
BDIST_WHEEL := dist/$(PACKAGE_NAME)-$(VERSION)-py2.py3-none-any.whl

RUNNER = docker run \
-it --rm \
Expand Down Expand Up @@ -75,11 +76,12 @@ clean:
./build \
./dist \
./htmlcov \
./rsconnect_python.egg-info
./rsconnect_python.egg-info \
./rsconnect.egg-info

.PHONY: clean-stores
clean-stores:
@find . -name "rsconnect-python" | xargs rm -rf
@find . -name "rsconnect-python" -o -name "rsconnect_python-*" -o -name "rsconnect-*" | xargs rm -rf

.PHONY: shell
shell: RUNNER = bash -c
Expand Down Expand Up @@ -126,6 +128,7 @@ version:
# exported as a point of reference instead.
.PHONY: dist
dist:
./scripts/temporary-rename
pip wheel --no-deps -w dist .
twine check $(BDIST_WHEEL)
rm -vf dist/*.egg
Expand Down
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[project]
name = "rsconnect_python"
description = "Python integration with Posit Connect"
description = "The Posit Connect command-line interface."

authors = [{ name = "Michael Marchetti", email = "mike@posit.co" }]
authors = [{ name = "Posit, PBC", email = "rsconnect@posit.co" }]
license = { file = "LICENSE.md" }
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.8"
Expand Down Expand Up @@ -84,6 +84,10 @@ packages = ["rsconnect"]

[tool.setuptools_scm]
write_to = "rsconnect/version.py"
# since we dirty the state by transforming the file
# keep the version number consistent
version_scheme = "no-guess-dev"
local_scheme = "no-local-version"

[tool.setuptools.package-data]
rsconnect = ["py.typed"]
Expand Down
18 changes: 18 additions & 0 deletions scripts/temporary-rename
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env -S uv run --script
# /// script
# dependencies = ["toml"]
# ///
import os

import toml

if "PACKAGE_NAME" in os.environ:

with open("pyproject.toml", "r") as f:
pyproject = toml.load(f)

# Override package name from pyproject.toml with environment variable
pyproject["project"]["name"] = os.environ["PACKAGE_NAME"]

with open("pyproject.toml", "w") as f:
toml.dump(pyproject, f)
Loading