Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try out nix #521

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ on:
branches: [ trunk ]

jobs:
build_nix:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Install Nix
uses: cachix/install-nix-action@v17
- name: Fix Nix installation
run: |
nix-channel --add https://nixos.org/channels/nixpkgs-unstable
nix-channel --update
- name: Build
run: nix build .#
build:
strategy:
matrix:
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.5)
project(python LANGUAGES C CXX VERSION 3.8.5)

find_program(SYSTEM_PYTHON python3.8)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -394,7 +396,7 @@ else()
OUTPUT
${FROZEN_MODULE_OUTPUT}
COMMAND
/usr/bin/python3.8 util/freeze_modules.py ${FROZEN_MODULE_OUTPUT_DIR}
${SYSTEM_PYTHON} util/freeze_modules.py ${FROZEN_MODULE_OUTPUT_DIR}
${FROZEN_MODULE_INPUT}
WORKING_DIRECTORY
${CMAKE_SOURCE_DIR}
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
description = "A flake for building Hello World";
inputs.nixpkgs.url = github:NixOS/nixpkgs/a46c5b471eea21bb4d1b75c9f3d3d8e66f2c3a1b;
outputs = { self, nixpkgs }: {
defaultPackage.x86_64-linux =
# Notice the reference to nixpkgs here.
with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation {
pname = "python";
name = "skybison";
src = self;
dontUseCmakeConfigure=true;
buildInputs = [
cmake
clang
ninja
python38

bzip2
libffi
lzma
openssl
readline
sqlite
zlib
];
buildPhase = ''
cmake -G Ninja -B build -DCMAKE_TOOLCHAIN_FILE=util/linux.cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
ninja -C build python
'';
installPhase = "mv build $out";
};
};
}
3 changes: 3 additions & 0 deletions third-party/cpython/Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1117,10 +1117,13 @@ setup_readline(readlinestate *mod_state)
/* Set our completion function */
rl_attempted_completion_function = flex_complete;
/* Set Python word break characters */
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wincompatible-pointer-types-discards-qualifiers"
completer_word_break_characters =
rl_completer_word_break_characters =
strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
/* All nonalphanums except '.' */
#pragma clang diagnostic pop

mod_state->begidx = PyLong_FromLong(0L);
mod_state->endidx = PyLong_FromLong(0L);
Expand Down
Loading