Skip to content

test: add local VCS helper package; VCS entries for environment and requirements testbeds - #1163

Merged
jkowalleck merged 2 commits into
CycloneDX:mainfrom
pinsara23:tests/pipenv-local-vcs
Dec 1, 2026
Merged

jkowalleck merged 2 commits into
CycloneDX:mainfrom
pinsara23:tests/pipenv-local-vcs

Conversation

@pinsara23

@pinsara23 pinsara23 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Adds test data for VCS dependencies, as discussed above. Snapshots record the current behavior, so the fix for #1152 will show its effect as snapshot changes.

  • new helper _helpers/local_pckages/e_vcs: a tiny package plus init_repo.py, which turns the folder into a local git repo on demand (skips if .git exists; fixed author/branch via git config, fixed commit date, core.autocrlf=input, so the commit hash is reproducible across machines). .git is gitignored. See its README.
  • environment: local testbed runs init_repo.py and installs package-e via git+file:// (absolute URL resolved at install time; pip doesn't support relative VCS URLs)
  • requirements: git+ssh://git@… entry added to with-urls.txt; local git+file:///… entry added to local.txt

Follow-up PRs: pipenv and poetry lock files, regenerated with the real tools against the helper repo.

No code changes. Prepares #1152.

I used Claude Code to help prepare this change; I reviewed it myself.

@pinsara23
pinsara23 requested a review from a team as a code owner November 30, 2026 11:24
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@jkowalleck

Copy link
Copy Markdown
Member

please also add a git+ssh://git@... link if it is missing

please streamline the test beds with existing ones

please consolidate the tested - we probably already have ones for the purposes.
I see we have a with-urls and a local already - use them.

And while on it, please dont scope this around pipenv - add them entries for all the supported methods.

After this, please adjust the PR title and description.
Thanks in advance.

@pinsara23

Copy link
Copy Markdown
Contributor Author

Thanks! I'll repurpose this PR and drop the separate local-vcs testbed. Plan:

  • requirements: add a git+ssh://git@… entry to with-urls.txt, and local VCS entries (git+file:///…, file:///…) to local.txt
  • pipenv: with-urls already covers git+ssh (six); add local VCS entries to local
  • poetry: with-urls already covers ssh://git@…; add a local git dependency to local and regenerate lock10/11/20/21
  • environment: add a local VCS install to local

Two questions before I start:

  1. Local VCS entries need a real git repo for locking/installing, and file:// URLs are absolute and machine-specific. Should the init scripts create a throwaway git repo (e.g. from _helpers/local_pckages/c) at init time, or would you prefer hand-written lock entries with a fixed placeholder path like file:///path/to/repo?
  2. For environment, installing via git+ssh needs SSH credentials, so I'd cover ssh only in the requirements/lock-file testbeds. OK?

@pinsara23 pinsara23 changed the title test(pipenv): add testbed for local VCS dependencies test: add local VCS and git+ssh entries to testbeds Nov 30, 2026
@jkowalleck

Copy link
Copy Markdown
Member

Two questions before I start:

  1. Local VCS entries need a real git repo for locking/installing, and file:// URLs are absolute and machine-specific. Should the init scripts create a throwaway git repo (e.g. from _helpers/local_pckages/c) at init time, or would you prefer hand-written lock entries with a fixed placeholder path like file:///path/to/repo?

Interesting point, and thanks for bringing this up. 👍
Did not think about this earlier.

My first idea was - and it is pretty raw:

  • lets have a new _helpers/local_pckages/<something>
    • with a readme that tells what this about and how it need to be setup
    • add all the files needed for python
    • add a .gitconfig
      • sets the default author
      • sets the default branch name
    • add a .gitignore that omits any python caches AND the .git folder
    • add a septup.py - or setup.bat(windows) and setup.sh(non-windows)
      that does the following:
      • if a .git folder exists, it will just stop
      • puts this file under git - run git init
    • did I forget something? Anything else that could be beneficial or needed?
  • lets call the respective setup script before any install that depends on it.
  • Q: can we use relative paths for the URL in the manifest(pipfile, ...)?
  • e.g. git+file:../../
  • did not test it
  • what are our options here? make a relative URL on install-time?
  1. For environment, installing via git+ssh needs SSH credentials, so I'd cover ssh only in the requirements/lock-file testbeds. OK?

please add one wherever possible - please don't write lock files from hand.

There are options to use repos without credentials - like git+ssh://git@github.com:CycloneDX/cyclonedx-python-lib.git
see existing one:

six = {ref = "1.16.0", git = "git+ssh://git@github.com/benjaminp/six.git"}

@pinsara23

Copy link
Copy Markdown
Contributor Author

Thanks! Agreed on the helper-package approach. A few findings before I build it:

  1. Relative URLs: pip rejects them for VCS. I tried git+file:repos/pkg, git+file:./repos/pkg and git+file://./repos/pkg, and all fail. So the setup step would resolve the absolute git+file:// URL at install/lock time.
  2. A .gitconfig inside the folder isn't picked up by git (only ~/.gitconfig and .git/config are read), so the setup script would pass author/branch via git -c … / GIT_* env vars, with a fixed author date, so the commit hash is reproducible (it ends up in lock files and snapshots).
  3. I'd avoid naming it setup.py, since pip would treat it as the package's build script. Suggest one cross-platform init_repo.py instead of .bat/.sh.
  4. git+ssh://git@github.com/… always needs an SSH key on GitHub, even for public repos (git@ is just the ssh user). That's fine for lock files, which are only read, but the environment testbed installs in CI, so ssh there would need a key. OK to cover ssh in requirements/pipenv/poetry only?

Plan: add _helpers/local_pckages/e_vcs (README, package files, .gitignore incl. .git, init_repo.py); call it from the environment init.py; regenerate pipenv and poetry lock files with the real tools instead of hand edits.

To keep reviews manageable, I'd split this: this PR → helper package + environment + requirements; follow-up PRs for pipenv and poetry lock files. OK?

@jkowalleck

Copy link
Copy Markdown
Member
  1. Relative URLs: pip rejects them for VCS. I tried git+file:repos/pkg, git+file:./repos/pkg and git+file://./repos/pkg, and all fail. So the setup step would resolve the absolute git+file:// URL at install/lock time.

Understood. Sounds good to me.

  1. A .gitconfig inside the folder isn't picked up by git (only ~/.gitconfig and .git/config are read), so the setup script would pass author/branch via git -c … / GIT_* env vars, with a fixed author date, so the commit hash is reproducible (it ends up in lock files and snapshots).

I see. or have a separate section in the setup scripts - git config ....
Pick whatever appears right to you.

  1. I'd avoid naming it setup.py, since pip would treat it as the package's build script. Suggest one cross-platform init_repo.py instead of .bat/.sh.

good catch. fully agree!

  1. git+ssh://git@github.com/… always needs an SSH key on GitHub, even for public repos (git@ is just the ssh user). That's fine for lock files, which are only read, but the environment testbed installs in CI, so ssh there would need a key. OK to cover ssh in requirements/pipenv/poetry only?

sounds reasonable - lets start with this. If needed, we can add on it later.

Plan: add _helpers/local_pckages/e_vcs (README, package files, .gitignore incl. .git, init_repo.py); call it from the environment init.py; regenerate pipenv and poetry lock files with the real tools instead of hand edits.

To keep reviews manageable, I'd split this: this PR → helper package + environment + requirements; follow-up PRs for pipenv and poetry lock files. OK?

thank you very much. please go ahead.

@jkowalleck jkowalleck added the CT Continuous Testing label Nov 30, 2026
@pinsara23
pinsara23 force-pushed the tests/pipenv-local-vcs branch from 38defdb to 96f52ab Compare November 30, 2026 17:51
@pinsara23 pinsara23 changed the title test: add local VCS and git+ssh entries to testbeds test: add local VCS helper package; VCS entries for environment and requirements testbeds Nov 30, 2026
@read-the-docs-community

read-the-docs-community Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 CycloneDX Python SBOM Tool | 🛠️ Build #36294087 | 📁 Comparing a4a96eb against latest (617e617)

  🔍 Preview build  

1 file changed
± changelog.html

…d requirements testbeds

Signed-off-by: Pinsara Sarathchandra <113714@foe.sjp.ac.lk>
@pinsara23
pinsara23 force-pushed the tests/pipenv-local-vcs branch from 96f52ab to af028a7 Compare November 30, 2026 17:54
@pinsara23

Copy link
Copy Markdown
Contributor Author

Fixed: the first push accidentally recorded e_vcs as an embedded repo (gitlink); it's now the 5 real files. Sorry for the noise.

Started on the pipenv follow-up and found a design question, which also applies to poetry:

  • pipenv (2026.8.0) rejects relative VCS URLs too: git+file:../../_helpers/… fails an assertion, and a bare relative path is refused as an unsupported URL.
  • With an absolute git+file:///… it locks fine, and ref = "main" resolves to the reproducible commit from init_repo.py.
  • But then Pipfile/Pipfile.lock (and snapshots) contain the absolute path of whichever machine ran the lock.

Options I see:
A) commit the lock as generated, absolute path included (the tool only reads it)
B) lock with the real tool, then rewrite the machine-specific prefix to a placeholder via a small script
C) generate Pipfile + Pipfile.lock at test-init time via an init.py, like the environment testbeds

Which would you prefer?

@jkowalleck jkowalleck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks fantastic. thank you so much for taking care of this.

…t snapshots

Signed-off-by: Pinsara Sarathchandra <113714@foe.sjp.ac.lk>
@pinsara23

Copy link
Copy Markdown
Contributor Author

Applied the suggested author name. Since it's part of the reproducible commit hash, I regenerated the environment snapshots in the same commit.

This also fixes the earlier CI failures: the environment snapshots accidentally contained a leftover package from a local prototype venv. Regenerated from a clean environment and verified locally that the local environment tests pass on a fresh init.

@jkowalleck

Copy link
Copy Markdown
Member

for pipenv, the following worked for me:

package-e = {git = "git+file:${PWD}/../../_helpers/local_pckages/e_vcs"}

@jkowalleck

jkowalleck commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

for pipenv, the following worked for me:

package-e = {git = "git+file:${PWD}/../../_helpers/local_pckages/e_vcs"}

to be independent from the dirt hat pipenv lock is called in, we might use an own env var: HELPERS_DIR or something - i am not certain about this ...

Any suggestions, @pinsara23 ?

PS: docs- https://pipenv.pypa.io/en/latest/credentials.html

@pinsara23

Copy link
Copy Markdown
Contributor Author

Tested with pipenv 2026.8.0, nice find! The lockfile keeps the variable unexpanded ("git": "git+file:${PWD}/../../_helpers/…"), so it's machine-independent. ref = "main" resolves to the reproducible commit (260d2e0…).

Suggestion: a dedicated env var rather than ${PWD}, since PowerShell/cmd don't set PWD as an env var and it depends on the cwd. E.g.:

package-e = {git = "git+file://${CDX_TEST_HELPERS_DIR}/local_pckages/e_vcs", ref = "main"}

CDX_TEST_HELPERS_DIR would be the absolute helpers path in URL form (forward slashes, leading slash, so /D:/… on Windows), matching the existing CDX_TEST_* naming. Only needed when (re-)locking, since cyclonedx-py just reads the lockfile. I'd document it in the testbed README.

I'd keep the git+file scheme literal in the Pipfile (not inside the variable), so cyclonedx-py can still tell it's a local VCS URL without expanding env vars. Works with the tool today: it reads the lock fine, and the variable shows up URL-encoded in the SBOM.

If that's OK, I'll prepare the pipenv follow-up PR this way after this one is merged.

@jkowalleck

Copy link
Copy Markdown
Member

for pipenv, the following worked for me:

package-e = {git = "git+file:${PWD}/../../_helpers/local_pckages/e_vcs"}

to be independent from the dirt hat pipenv lock is called in, we might use an own env var: HELPERS_DIR or something - i am not certain about this ...

Any suggestions, @pinsara23 ?

PS: docs- https://pipenv.pypa.io/en/latest/credentials.html

we could have a tests/_data/infiles/pipenv/.env file written, that sets a custom variable - but i dont like this much. it should be sufficient, but not desired if we can go other ways.

using ${PWH} works for me, for now. this can be improved later, in a different PR.

@jkowalleck

jkowalleck commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

If that's OK, I'll prepare the pipenv follow-up PR this way after this one is merged.

sure. lets merge this one and improve in a different dedicated PR later.

will merge .

@jkowalleck
jkowalleck merged commit 180d137 into CycloneDX:main Dec 1, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CT Continuous Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants