Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2b4e6e7
add linting workflow
emmettbutler May 19, 2023
5a35eaf
no flake8
emmettbutler May 19, 2023
96ae2e4
run instead of script
emmettbutler May 19, 2023
1178fa4
noscript
emmettbutler May 19, 2023
9130df2
apply black and isort
emmettbutler May 19, 2023
8e0ebd6
workflow tweaks
emmettbutler May 19, 2023
b523dd8
proper checkout
emmettbutler May 19, 2023
0834fe0
use noqa to stop black and isort from fighting each other
emmettbutler May 19, 2023
0de1144
make dependencies check attempt both setuptools and hatch builds
emmettbutler May 16, 2023
1318d8c
patch hatchling to output dependency data
emmettbutler May 16, 2023
62de1af
generate metadata
emmettbutler May 16, 2023
770345f
set format attribute in generated nix expressions
emmettbutler May 16, 2023
d7c29fa
undo black and isort
emmettbutler May 16, 2023
fe5f170
moving toward generically supporting pep517 build backends
emmettbutler May 17, 2023
b15cc06
pin nixpkgs
emmettbutler May 18, 2023
7e183a4
fail during bootstrappedpip install phase with proof that patching works
emmettbutler May 18, 2023
98b70b8
simplify with overrideattrs
emmettbutler May 18, 2023
94d9a9c
checkin
emmettbutler May 18, 2023
fbd5974
checkin
emmettbutler May 18, 2023
a120933
simplify hatch patch
emmettbutler May 18, 2023
d9471e0
checkin
emmettbutler May 18, 2023
d41d200
fix crash
emmettbutler May 18, 2023
492057b
prefix overrides with an underscore to avoid infinite recursion
emmettbutler May 19, 2023
2d078d7
prefix overrides with an underscore to avoid infinite recursion
emmettbutler May 19, 2023
e816105
correct underscore placement
emmettbutler May 19, 2023
355722e
hook into correct spot in flit_core
emmettbutler May 19, 2023
de8bbde
cleanup
emmettbutler May 19, 2023
632808a
blank diff
emmettbutler May 19, 2023
47ed060
shrink pip patch
emmettbutler May 19, 2023
fe0b94c
patching pip is unnecessary
emmettbutler May 19, 2023
3a33ef8
allow specifying python version at cli
emmettbutler May 19, 2023
4892241
fmt
emmettbutler May 19, 2023
0885125
Merge branch 'emmett.butler/linting' into emmett.butler/hatch-support
emmettbutler May 19, 2023
ea74828
black
emmettbutler May 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: lint
on:
pull_request:
types: ['opened', 'edited', 'reopened', 'synchronize']
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-python@v4
name: Install Python
with:
python-version: '3.10'

- name: Install Dependencies
run: pip install black isort

- name: Lint Python Code
run: |
black --check pynixify
isort --check pynixify
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: "Test"
on:
pull_request:
push:
schedule:
- cron: '5 19 * * 5' # At 19:05 on Friday
Expand Down
35 changes: 21 additions & 14 deletions pynixify/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,21 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import json
from pathlib import Path
from dataclasses import dataclass
from typing import Optional, Dict
from packaging.version import Version, LegacyVersion, parse as parse_original
from pathlib import Path
from typing import Dict, Optional

from packaging.version import LegacyVersion, Version
from packaging.version import parse as parse_original


@dataclass
class PackageMetadata:
description: Optional[str]
license: Optional[str]
url: Optional[str]
_fmt: Optional[str] = "pyproject"


@dataclass
class Package:
Expand All @@ -38,9 +43,10 @@ def attr(self) -> str:
raise NotImplementedError()

async def metadata(self) -> PackageMetadata:
from pynixify.package_requirements import run_nix_build, NixBuildError
from pynixify.package_requirements import NixBuildError, run_nix_build

source = await self.source()
if source.name.endswith('.whl'):
if source.name.endswith(".whl"):
# Some nixpkgs packages use a wheel as source, which don't have a
# setup.py file. For now, ignore them assume they have no metadata
return PackageMetadata(
Expand All @@ -52,23 +58,23 @@ async def metadata(self) -> PackageMetadata:
assert nix_expression_path.exists()
nix_store_path = await run_nix_build(
str(nix_expression_path),
'--no-out-link',
'--no-build-output',
'--arg',
'file',
str(source.resolve())
"--no-out-link",
"--no-build-output",
"--arg",
"file",
str(source.resolve()),
)
if (nix_store_path / 'failed').exists():
print(f'Error parsing metadata of {source}. Assuming it has no metadata.')
if (nix_store_path / "failed").exists():
print(f"Error parsing metadata of {source}. Assuming it has no metadata.")
return PackageMetadata(
url=None,
description=None,
license=None,
)
with (nix_store_path / 'meta.json').open() as fp:
with (nix_store_path / "meta.json").open() as fp:
metadata = json.load(fp)
try:
version: Optional[str] = metadata.pop('version')
version: Optional[str] = metadata.pop("version")
except KeyError:
pass
else:
Expand All @@ -78,6 +84,7 @@ async def metadata(self) -> PackageMetadata:
self.version = Version(version)
return PackageMetadata(**metadata)


# mypy hack
def parse_version(version: str) -> Version:
v = parse_original(version)
Expand Down
Loading