Skip to content

Instantly share code, notes, and snippets.

@winni2k
Last active March 25, 2021 07:39
Show Gist options
  • Save winni2k/857140501bfff6e23215be22bce90587 to your computer and use it in GitHub Desktop.
Save winni2k/857140501bfff6e23215be22bce90587 to your computer and use it in GitHub Desktop.
Trying to build conda package for crystal
mkdir -p $PREFIX/bin $PREFIX/lib $PREFIX/share
ls -lha
cp bin/* $PREFIX/bin/
cp -r lib/* $PREFIX/lib/
cp -r share/* $PREFIX/share/
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
PS1=${PS1:-}
[ -z "$PS1" ] && echo "Please run this script in interactive mode using 'bash -i'" && exit 1
conda_env_name=${1:-crystal}
wget https://github.com/crystal-lang/crystal/releases/download/1.0.0/crystal-1.0.0-1-linux-x86_64.tar.gz
tar -xf crystal-1.0.0-1-linux-x86_64.tar.gz
conda create -n $conda_env_name pcre libevent -y
conda activate $conda_env_name
echo $CONDA_PREFIX
cp -r crystal-1.0.0-1/* $CONDA_PREFIX/
cd $CONDA_PREFIX/lib/crystal/lib/
ln -s ../../libpcre.a
ln -s ../../libevent.a
cd -
crystal run hello_world.cr
puts "Hello World!"
# Jinja variables help maintain the recipe as you'll update the version only here.
# Using the name variable with the URL in line 14 is convenient
# when copying and pasting from another recipe, but not really needed.
{% set name = "crystal" %}
{% set version = "1.0.0" %}
package:
name: {{ name|lower }}
version: {{ version }}
source:
url: https://github.com/crystal-lang/crystal/releases/download/{{ version }}/crystal-{{ version }}-1-linux-x86_64.tar.gz
# If getting the source from GitHub, remove the line above,
# uncomment the line below, and modify as needed. Use releases if available:
# url: https://github.com/simplejson/simplejson/releases/download/{{ version }}/simplejson-{{ version }}.tar.gz
# and otherwise fall back to archive:
# url: https://github.com/simplejson/simplejson/archive/v{{ version }}.tar.gz
sha256: 00211ca77758e99210ec40b8c5517b086d2ff9909e089400f6d847a95e5689a4
# `openssl sha256 <file name>`.
# You may need the openssl package, available on conda-forge:
# `conda install openssl -c conda-forge``
build:
# Uncomment the following line if the package is pure Python and the recipe is exactly the same for all platforms.
# It is okay if the dependencies are not built for all platforms/versions, although selectors are still not allowed.
# See https://conda-forge.org/docs/maintainer/knowledge_base.html#noarch-python for more details.
# noarch: python
number: 0
# If the installation is complex, or different between Unix and Windows, use separate bld.bat and build.sh files instead of this key.
# By default, the package will be built for the Python versions supported by conda-forge and for all major OSs.
# Add the line "skip: True # [py<35]" (for example) to limit to Python 3.5 and newer, or "skip: True # [not win]" to limit to Windows.
# script: - "{{ PYTHON }} -m pip install . -vv"
requirements:
build:
# If your project compiles code (such as a C extension) then add the required compilers as separate entries here.
# Compilers are named 'c', 'cxx' and 'fortran'.
# - {{ compiler('cxx') }}
host:
# - python
# - pip
run:
- {{ compiler('cxx') }}
# - pcre
test:
files:
- hello_world.cr
commands:
- crystal build hello_world.cr
# Some packages might need a `test/commands` key to check CLI.
# List all the packages/modules that `run_test.py` imports.
# imports:
# - simplejson
# - simplejson.tests
about:
home: https://github.com/simplejson/simplejson
# Remember to specify the license variants for BSD, Apache, GPL, and LGPL.
# Use the SPDX identifier, e.g: GPL-2.0-only instead of GNU General Public License version 2.0
# See https://spdx.org/licenses/
license: MIT
# The license_family, i.e. "BSD" if license is "BSD-3-Clause". (optional)
license_family: MIT
# It is strongly encouraged to include a license file in the package,
# (even if the license doesn't require it) using the license_file entry.
# See https://docs.conda.io/projects/conda-build/en/latest/resources/define-metadata.html#license-file
# license_file: LICENSE.txt
summary: 'Simple, fast, extensible JSON encoder/decoder for Python'
# The remaining entries in this section are optional, but recommended.
description: |
simplejson is a simple, fast, complete, correct and extensible
JSON <https://json.org> encoder and decoder for Python 2.5+ and
Python 3.3+. It is pure Python code with no dependencies, but includes
an optional C extension for a serious speed boost.
doc_url: https://simplejson.readthedocs.io/
dev_url: https://github.com/simplejson/simplejson
extra:
recipe-maintainers:
# GitHub IDs for maintainers of the recipe.
# Always check with the people listed below if they are OK becoming maintainers of the recipe. (There will be spam!)
- LisaSimpson
- LandoCalrissian
@lh3
Copy link

lh3 commented Mar 24, 2021

I guess the segfault is reported by conda, not by crystal. You can try my v1.0 package to see if you can build locally. If you still get a segfault, you will need help from others. PS: crystal also requires libevent.

@winni2k
Copy link
Author

winni2k commented Mar 24, 2021

Take a look at build_env.sh. I think this does what you did with your package, just inside a conda evironment. I'll try your package next.

@winni2k
Copy link
Author

winni2k commented Mar 24, 2021

Unfortunately, the portable package also fails with a segmentation fault. I think this is something to take up with the conda community.

@winni2k
Copy link
Author

winni2k commented Mar 25, 2021

I have created a PR for this conda recipe to conda-forge: conda-forge/staged-recipes#14379

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment