Skip to content

Commit 0268029

Browse files
committed
publish to PyPI as rsconnect and rsconnect-python
- update makefile to support building wheels with a different package name - add a script to rewrite the package name in CI - `uv run` is used for this so that the necessary `toml` dependency is installed without drama - matrix the distributions step - change how dev version numbers are set in build
1 parent cb014e8 commit 0268029

File tree

4 files changed

+44
-8
lines changed

4 files changed

+44
-8
lines changed

.github/workflows/main.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ jobs:
6868

6969
distributions:
7070
needs: test
71+
strategy:
72+
matrix:
73+
package_name: ["rsconnect_python", "rsconnect"]
7174
runs-on: ubuntu-latest
7275
steps:
7376
- uses: actions/checkout@v4
@@ -78,14 +81,19 @@ jobs:
7881
- uses: actions/setup-python@v4
7982
with:
8083
python-version: 3.8.x
84+
- name: Install uv # see scripts/temporary-rename
85+
uses: astral-sh/setup-uv@v6
8186
- run: pip install -e '.[test]'
8287
- run: pip freeze
8388
- run: make dist
8489
id: create_dist
90+
env:
91+
PACKAGE_NAME: ${{ matrix.package_name }}
8592
- uses: actions/upload-artifact@v4
8693
with:
8794
name: distributions
8895
path: dist/
96+
if: matrix.package_name == 'rsconnect_python'
8997
- run: pip install -vvv ${{ steps.create_dist.outputs.whl }}
9098
- run: rsconnect version
9199
- run: rsconnect --help
@@ -101,16 +109,19 @@ jobs:
101109
with:
102110
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
103111
aws-region: ${{ secrets.AWS_REGION }}
104-
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
112+
- if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.package_name == 'rsconnect_python'
105113
run: make sync-latest-to-s3
106-
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
114+
env:
115+
BDIST_WHEEL: ${{ steps.create_dist.outputs.whl }}
116+
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') && matrix.package_name == 'rsconnect_python'
107117
run: make sync-to-s3
118+
env:
119+
BDIST_WHEEL: ${{ steps.create_dist.outputs.whl }}
108120
- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
109121
uses: pypa/gh-action-pypi-publish@release/v1
110122
with:
111123
user: __token__
112124
password: ${{ secrets.PYPI_TOKEN }}
113-
114125
docs:
115126
needs: test
116127
runs-on: ubuntu-latest

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ VERSION := $(shell python -m setuptools_scm)
22
HOSTNAME := $(shell hostname)
33
S3_PREFIX := s3://rstudio-connect-downloads/connect/rsconnect-python
44

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

78
RUNNER = docker run \
89
-it --rm \
@@ -75,11 +76,12 @@ clean:
7576
./build \
7677
./dist \
7778
./htmlcov \
78-
./rsconnect_python.egg-info
79+
./rsconnect_python.egg-info \
80+
./rsconnect.egg-info
7981

8082
.PHONY: clean-stores
8183
clean-stores:
82-
@find . -name "rsconnect-python" | xargs rm -rf
84+
@find . -name "rsconnect-python" -o -name "rsconnect_python-*" -o -name "rsconnect-*" | xargs rm -rf
8385

8486
.PHONY: shell
8587
shell: RUNNER = bash -c
@@ -126,6 +128,7 @@ version:
126128
# exported as a point of reference instead.
127129
.PHONY: dist
128130
dist:
131+
./scripts/temporary-rename
129132
pip wheel --no-deps -w dist .
130133
twine check $(BDIST_WHEEL)
131134
rm -vf dist/*.egg

pyproject.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[project]
22
name = "rsconnect_python"
3-
description = "Python integration with Posit Connect"
3+
description = "The Posit Connect command-line interface."
44

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

8585
[tool.setuptools_scm]
8686
write_to = "rsconnect/version.py"
87+
# since we dirty the state by transforming the file
88+
# keep the version number consistent
89+
version_scheme = "no-guess-dev"
90+
local_scheme = "no-local-version"
8791

8892
[tool.setuptools.package-data]
8993
rsconnect = ["py.typed"]

scripts/temporary-rename

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env -S uv run --script
2+
# /// script
3+
# dependencies = ["toml"]
4+
# ///
5+
import os
6+
7+
import toml
8+
9+
if "PACKAGE_NAME" in os.environ:
10+
11+
with open("pyproject.toml", "r") as f:
12+
pyproject = toml.load(f)
13+
14+
# Override package name from pyproject.toml with environment variable
15+
pyproject["project"]["name"] = os.environ["PACKAGE_NAME"]
16+
17+
with open("pyproject.toml", "w") as f:
18+
toml.dump(pyproject, f)

0 commit comments

Comments
 (0)