Skip to content

Conversation

@agrasth
Copy link
Contributor

@agrasth agrasth commented Nov 30, 2025

  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • The pull request is targeting the master branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....

Title

Add Poetry native mode support with full build info collection

Description

What

Implemented true native mode for Poetry when JFROG_RUN_NATIVE=true is set, allowing users to run Poetry commands directly while collecting complete build info (dependencies + artifacts).

Why

Customers using Poetry with JFrog CLI in native mode were unable to collect build info because:

  1. YAML Dependency: CLI still required .jfrog/projects/poetry.yaml even in native mode
  2. No Deployer Config: No way to specify deployer repository from pyproject.toml
  3. Wrong Repository: Artifact collection used resolver repo instead of deployer repo

Error:

[Error] Failed to extract Poetry repository configuration: project configuration file not found

Changes

buildtools/cli.go

New function - getPrimarySourceFromToml():

// Reads pyproject.toml and returns the source with priority='primary'
// Falls back to first source if no primary is defined
func getPrimarySourceFromToml() (string, bool) {
    // Parse [[tool.poetry.source]] entries
    // Return (sourceName, isPrimary)
}

Modified pythonCmd() for native mode:

  • Extract --repository / -r flag from arguments
  • Auto-detect repository from pyproject.toml if not provided
  • Pass deployer repository to build info collection
  • Clear logging for repository source

utils/buildinfo/buildinfo.go

Modified extractRepositoryConfigForProject():

// In native mode, completely ignore YAML and infer from pyproject.toml
if os.Getenv("JFROG_RUN_NATIVE") == "true" {
    return inferPoetryConfigFromToml(projectType)
}
// Traditional mode: read from YAML

New function - inferPoetryConfigFromToml():

  • Reads [[tool.poetry.source]] entries from pyproject.toml
  • Matches source URLs against configured JFrog CLI servers
  • Extracts repository name from PyPI URL
  • Returns RepositoryConfig for build info collection

New function - extractRepoNameFromPypiURL():

// Extracts "repo-name" from URLs like:
// https://server/artifactory/api/pypi/repo-name/simple

Modified function signatures:

// Now accepts deployerRepo as parameter instead of environment variable
func GetPoetryBuildInfo(workingDir string, buildConfiguration *buildUtils.BuildConfiguration, deployerRepo string) error

func collectPoetryBuildInfo(..., deployerRepo string) error

Usage

# 1. Configure credentials (one-time)
jf setup poetry --repo poetry-local --server-id myserver

# 2. Add sources to pyproject.toml
poetry source add poetry-remote https://server/artifactory/api/pypi/poetry-remote/simple --priority=supplemental
poetry source add poetry-local https://server/artifactory/api/pypi/poetry-local/simple --priority=primary

# 3. Build and publish with build info
export JFROG_RUN_NATIVE=true
jf poetry lock
jf poetry install
jf poetry build
jf poetry publish --build-name=myapp --build-number=1

# 4. Publish build info to Artifactory
jf rt bp myapp 1

Testing

Native Mode Tests

Test Case Result
Publish without -r flag (auto-detect from pyproject.toml) PASS
Publish with explicit -r flag PASS
Publish with --repository=value syntax PASS
Build command PASS
Install command PASS
No priority='primary' (uses first source) PASS
Build info with dependencies PASS (5 deps)
Build info with artifacts PASS (2 artifacts)
Poetry 2.x project format PASS

Log Output Examples

Auto-detect from pyproject.toml:

[Info] No --repository flag specified. Using 'poetry-local' from pyproject.toml (priority='primary')
[Info] Running Poetry publish.
[Info] Module 'hello-world:0.1.0' has 5 dependencies with checksums
[Info] Added 2 artifacts to build info

Explicit -r flag:

[Info] Publishing to repository: poetry-local (from --repository flag)

Fallback to first source:

[Info] No --repository flag specified. Using 'poetry-remote' from pyproject.toml (first source)

Related PRs

@agrasth agrasth force-pushed the poetry-native-mode-enhancements branch 2 times, most recently from 5d272e2 to f5d1524 Compare December 5, 2025 09:31
@agrasth agrasth force-pushed the poetry-native-mode-enhancements branch from f5d1524 to 84222a0 Compare December 9, 2025 12:24
@agrasth agrasth force-pushed the poetry-native-mode-enhancements branch from 84222a0 to fc0c93d Compare December 9, 2025 17:29
@agrasth agrasth added the safe to test Approve running integration tests on a pull request label Dec 9, 2025
@agrasth agrasth added safe to test Approve running integration tests on a pull request and removed safe to test Approve running integration tests on a pull request labels Dec 9, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2025

👍 Frogbot scanned this pull request and did not find any new security issues.


@reshmifrog reshmifrog self-requested a review December 10, 2025 06:58
@agrasth agrasth merged commit 362406f into jfrog:master Dec 10, 2025
70 of 71 checks passed
@agrasth agrasth added the improvement Automatically generated release notes label Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes safe to test Approve running integration tests on a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants