Create Racket package

Hello,

i want to create a Racket package, when i did that on a directory containing the module code in a file that uses other code file and i want to install it with the package manager from a directory it installs well the module but parse also all the scheme file trying to install them as other modules and so i have a lot of error (in red) in the log. Just what i want is a way for package manager to use only my module files not the included files (it does the same even if i put them in subdirectories) to be able to install it without a ton of errors. I also want to provide the package as a git repositories but that i know how to do it but will have the same problem with included files.
I can not find a way to solve this problem?
perheaps doing : raco pkg new name ?
Regards,
Damien

I cannot sure what you want, so I just list all I think are related

  1. to publish package xxx that can be resolved by raco pkg install xxx, you need to register the package on https://pkgs.racket-lang.org/
  2. to install a local directory as a package, use raco pkg install at that directory, of course, the directory should have info.rkt
  3. to create a new package, use raco pkg new <package name>, and I think that package name needs to follow some rules, but I don't remember the detail
  4. to import a file, write (require "file.rkt")
  5. import a package is (require package), but if it has a submodule(a file), you can write (require package/submodule)
2 Likes

It sounds like you're saying that by default, a package install compiles all of the files in an installed subdirectory, and I believe that's correct.

I know this is going to sound obvious, but the easiest way to avoid this problem is to make sure that those files aren't in the package.

Not good enough?

Well, there are a few other ways to do it, as well.

One is to use the compile-omit-paths collection field.

Another would be to specify a subpath as the package directory, and move the other files out of that subdirectory.

Returning to point #1, though, it sounds like it might be simpler to create a new repository with just the files that compile.

Re-reading this, it sounds like you might actually be using the include library to literally include the text of one file inside another. In general, I ... think I would steer you away from doing that? ... but I can see how that might cause this problem. I'm just throwing things out there, now, but perhaps you could consider changing these files not to end with .rkt or .scm ? I just did some quick tests and this appeared to work.

1 Like

first here is my directory structure :
-rw-r--r--@ 1 mattei staff 1403 11 jan 09:52 Scheme+.rkt
drwxr-xr-x@ 5 mattei staff 160 17 jan 14:03 compiled
drwxr-xr-x@ 7 mattei staff 224 17 jan 14:03 examples
drwxr-xr-x@ 8 mattei staff 256 7 jan 10:10 included-files
drwxr-xr-x@ 7 mattei staff 224 11 jan 15:39 library
drwxr-xr-x@ 5 mattei staff 160 12 jan 14:46 required-files

i have made the subdirectory in the hope that subdirs will not be used by raco

only included-files and required-files and library are usefull to compile Scheme+.rkt module:

(module Scheme+ racket


	(provide def $bracket-apply$ <- ← -> → <+ ⥆ +> ⥅ declare $ & condx <> ≠ **)


	(include "included-files/def.scm")
	(include "included-files/array.scm")

	(require "required-files/apply-square-brackets.rkt")
	(require "required-files/assignment.rkt")

	(include "included-files/declare.scm")
	(include "included-files/condx.scm")
	(include "included-files/block.scm")
	(include "included-files/not-equal.scm")
	(include "library/exponential.scm")

	) ;; end module

i do not understand where to put the option compile-omit-paths ? seems to be useful in an API but not in command line, but perheaps i'm not right.

I want to keep the tree structure of project, if i put the main.rkt file ,the ones that is a module and the included (i admit i use some) and the required files outside of this tree structure this is not logic . Because in a project all files are in same directory or someones in sub directory but rarely outside.
This will be the last solution for me. Renaming scheme or racket files with another extension is shocking too , souund very strange for a modern language to be forced to do that...

anyway it works but if i distribute a racket package like this it will perheaps not display with a buil status of success in Racket Package Index ?
Damien

It seems you are missing the info.rkt file for more details see @dannypsnl answer above.
Within that file is a configuation option compile-omit-paths see 6.3 Controlling raco setup with "info.rkt" Files at the bottom.

compile-collection-zos further describes the possible values for compile-omit-paths.

That info.rkt is used to describe a package and it also will be used there.


Searching for a package that uses it I found an interesting way to use it in the frog package of @greghendershott

It uses a second info.rkt file in the subdirectory to exclude only the examples directory.
If you don't want to use a second info.rkt then you can specify the subdirectory in the parent directory info.rkt like this:

#lang info
(define compile-omit-paths '("example"))

I see that I was right in guessing that you're actually using include. I'm going to go out on a limb and suggest that it's fairly uncommon to use include in modern Racket; I think it's generally the case that every racket file is a separate module of compilation (or indeed, may contain multiple modules).

In a language like C, there's a fairly clear distinction between files that are units of compilation (those ending with .c) and those that are designed to be included (those ending with .h). I would suggest that files such as declare.scm and others that you're including are not separate units of compilation, but are instead "include files", so it doesn't seem unreasonable to give them names that reflect this. Perhaps something like declare.inc and condx.inc?

Opinions from others?

1 Like

thank a lot it worked now, no more errors with:

type or #lang info
(define compile-omit-paths '("included-files" "required-files" "library" "examples" "SRFI" "compiled"))

paste code here

i'm agree with you. But Scheme does not encourage this like C,having no convention,and having module defined differently from a scheme implementation to another one. Perheaps for this reason it is more compatible to use include.Also i use them because my included files are really lights , condx contains one or 2 macros of 10 lines like this:

; example:
;(define x 1)
;(condx ((= x 7) 'never)
;        (exec
;          (define y 3)
;          (set! x 7))
;        ((= y 1) 'definitely_not)
;        (exec
;          (set! y 10)
;          (define z 2))
;        ((= x 7) (+ x y z))
;        (else 'you_should_not_be_here))
;
; 19

(define-syntax condx
  (syntax-rules (exec else)
    ((_)
     (error 'condx "No else clause"))
    ((_ (else e ...))
     (let () e ...))
    ((_ (exec s ...) d1 ...)
     (let () s ... (condx d1 ...)))
    ((_ (t e ...) tail ...)
     (if t
         (let () e ...)
         (condx tail ...)))))

;; warning this ones behaves differently (can not remember the problem)
(define-syntax condx-begin
  (syntax-rules (exec else)
    ((_)
     (error 'condx-begin "No else clause"))
    ((_ (else e ...))
     (begin e ...))
    ((_ (exec s ...) d1 ...)
     (begin s ... (condx-begin d1 ...)))
    ((_ (t e ...) tail ...)
     (if t
         (begin e ...)
         (condx-begin tail ...)))))

;; (define x 1)
;; (condx ((= x 7) 'never)
;;         (exec
;;           (define y 3)
;;           (set! x 7))
;;         ((= y 1) 'definitely_not)
;;         (exec
;;           (set! y 10)
;;           (define z 2))
;;         ((= x 7) (+ x y z))
;;         (else 'you_should_not_be_here))

;; (define y 0)
;; (define z 0)
;; (set! x 1)
;; (condx-begin ((= x 7) 'never)
;;         (exec
;;           (set! y 3)
;;           (set! x 7))
;;         ((= y 1) 'definitely_not)
;;         (exec
;;           (set! y 10)
;;           (set! z 2))
;;         ((= x 7) (+ x y z))
;;         (else 'you_should_not_be_here))


and it comes from a Guile version of my code,Guile have different conventions for modules.

Yes, I wondered if there was a cross-platform issue. I agree that everything gets harder when writing code for two languages simultaneously.

1 Like

One convention I have seen in Racket is to use the extension .rktd

1 Like

another problem arising is that even if i can omit some subdirs for building it try to test them anayway and fail and also complain about depandancies but build with success

See test-omit-paths, works similar to compile-omit-paths!

ok with test-omit-paths and some dummy test and the server index update on test and all it finally succeeds in all build,test,deps...