Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(manager/pep621): support hatch environments (#25211)
Co-authored-by: Sebastian Poxhofer <secustor@users.noreply.github.com> Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
- Loading branch information
1 parent
d5508b7
commit 98dccff
Showing
6 changed files
with
135 additions
and
2 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
lib/modules/manager/pep621/__fixtures__/pyproject_with_hatch.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
[project] | ||
name = "hatch" | ||
dependencies = [ | ||
"requests==2.30.0" | ||
] | ||
|
||
[tool.hatch.envs.default] | ||
dependencies = [ | ||
"coverage[toml]==6.5", | ||
"pytest", | ||
] | ||
|
||
[[tool.hatch.envs.all.matrix]] | ||
python = ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
|
||
[tool.hatch.envs.lint] | ||
detached = true | ||
dependencies = [ | ||
"black>=23.1.0", | ||
] | ||
|
||
[tool.hatch.envs.experimental] | ||
extra-dependencies = [ | ||
"baz", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import is from '@sindresorhus/is'; | ||
import type { | ||
PackageDependency, | ||
UpdateArtifact, | ||
UpdateArtifactsResult, | ||
} from '../../types'; | ||
import type { PyProject } from '../schema'; | ||
import { parseDependencyList } from '../utils'; | ||
import type { PyProjectProcessor } from './types'; | ||
|
||
export class HatchProcessor implements PyProjectProcessor { | ||
process( | ||
pyproject: PyProject, | ||
deps: PackageDependency[] | ||
): PackageDependency[] { | ||
const hatch_envs = pyproject.tool?.hatch?.envs; | ||
if (is.nullOrUndefined(hatch_envs)) { | ||
return deps; | ||
} | ||
|
||
for (const [envName, env] of Object.entries(hatch_envs)) { | ||
const depType = `tool.hatch.envs.${envName}`; | ||
const envDeps = parseDependencyList(depType, env?.dependencies); | ||
deps.push(...envDeps); | ||
const extraDeps = parseDependencyList( | ||
depType, | ||
env?.['extra-dependencies'] | ||
); | ||
deps.push(...extraDeps); | ||
} | ||
|
||
return deps; | ||
} | ||
|
||
updateArtifacts( | ||
updateArtifact: UpdateArtifact, | ||
project: PyProject | ||
): Promise<UpdateArtifactsResult[] | null> { | ||
// Hatch does not have lock files at the moment | ||
// https://github.com/pypa/hatch/issues/749 | ||
return Promise.resolve(null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { HatchProcessor } from './hatch'; | ||
import { PdmProcessor } from './pdm'; | ||
|
||
export const processors = [new PdmProcessor()]; | ||
export const processors = [new HatchProcessor(), new PdmProcessor()]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters