Skip to content

Commit 70c1fab

Browse files
committed
Fix Python package publishing
1 parent ff2e3ea commit 70c1fab

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ PULUMI_MISSING_DOCS_ERROR := false
1717
# Override during CI using `make [TARGET] PROVIDER_VERSION=""` or by setting a PROVIDER_VERSION environment variable
1818
# Local & branch builds will just used this fixed default version unless specified
1919
PROVIDER_VERSION ?= 0.1.0-alpha.0+dev
20+
PYTHON_IMPORT_PACKAGE := pulumi_logfire
21+
PYTHON_PYPI_PACKAGE := pydantic-pulumi-logfire
2022

2123
# Check version doesn't start with a "v" - this is a common mistake
2224
ifeq ($(shell echo $(PROVIDER_VERSION) | cut -c1),v)
@@ -145,6 +147,10 @@ build_python: .make/build_python
145147
$(GEN_ENVS) $(WORKING_DIR)/bin/$(CODEGEN) python --out sdk/python/
146148
printf "module fake_python_module // Exclude this directory from Go tools\n\ngo 1.17\n" > sdk/python/go.mod
147149
cp README.md sdk/python/
150+
# Keep the Python import path stable while publishing under a unique PyPI project name.
151+
sed -i.bak 's/name = "$(PYTHON_IMPORT_PACKAGE)"/name = "$(PYTHON_PYPI_PACKAGE)"/' sdk/python/pyproject.toml
152+
rm sdk/python/pyproject.toml.bak
153+
perl -0pi -e 's| pep440_version_string = importlib.metadata.version\(root_package\)\n| try:\n pep440_version_string = importlib.metadata.version(root_package)\n except importlib.metadata.PackageNotFoundError:\n pep440_version_string = importlib.metadata.version("$(PYTHON_PYPI_PACKAGE)")\n|' sdk/python/$(PYTHON_IMPORT_PACKAGE)/_utilities.py
148154
@touch $@
149155
.make/build_python: .make/generate_python
150156
cd sdk/python/ && \

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ yarn add @pydantic/pulumi-logfire
2525
To use from Python, install using `pip`:
2626

2727
```bash
28-
pip install pulumi_logfire
28+
pip install pydantic-pulumi-logfire
2929
```
3030

31+
Import it in code as `pulumi_logfire`.
32+
3133
### Go
3234

3335
To use from Go, use `go get` to grab the latest version of the library:
3436

3537
```bash
36-
go get github.com/pydantic/pulumi-logfire/sdk/go/...
38+
go get github.com/pydantic/pulumi-logfire/sdk
3739
```
3840

3941
## Configuration

sdk/python/README.md

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/python/pulumi_logfire/_utilities.py

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)