Create Package from folder structure with subpackages - julia

I have been given a folder called PackageName with the following structure.
PackageName/
|- SubPackage.jl/
|- src/
|- MyModule.jl
|- test/
|- runtests.jl
|- Project.toml
|- Manifest.toml
|- Project.toml
|- Manifest.toml
|- .gitignore
|- .gitattributes
|- README.md
Inside PackageName there are various .git files like .gitignore, .gitattributes and README.md. There are also a Project.toml and a Manifest.toml which are required in a Julia package. Finally, there are various folders with the structure of SubPackage. Essentially they also contain a Project.toml and a Manifest.toml. They also contain a src/ directory with a Module named MyModule.jl and a test/ directory with some unit testing. The MyModule.jl has a function called myfunction(), which is exported.
I would like to use all the SubPackage-style packages but I am encountering some issues. PackageName doesn't seem to be a proper Julia package because
it doesn't have a src/ directory.
it's Project.toml has an author, a version and [deps] fields but lacks a name and uuid.
What is the best way to go about using the packages in this folder properly within a Julia environment? Essentially I would like to be able to do using PackageName and being able to use myfunction().

Related

Python 3.x: import a function, config dictionary, ... etc. from a file in a different directory

The folder tree of my project is:
project:
|
| -- src:
|--- dir_a:
|--- file_a.py
|--- dir_b:
|--- file_b.py
I want to import a function, config dictionary, ... etc. in the file_a.py (the current file) from the file_b.py
I found many answers talking about packages and modules, but I don't know anything about them because I'm writing simple python files. Moreover, I want to send this project to someone to use it on his computer (running some files .py from the command line) without editing the system path manually or any other hard solutions.
I would create a new package that has both dir_a and dir_b in it. Then you need an empty file __init__.py in every directory in the package.
src/
|_ pkg/
|_ __init__.py
|_ dir_a/
|_ __init__.py
|_ file_a.py
|_ dir_b/
|_ __init__.py
|_ file_b.py
Then, provided there are no circular dependencies, in file_a.py you can put any of these:
import pkg.dir_b.file_b
# or
from pkg.dir_b.file_b import ...
# or
from pkg.dir_b import file_b

Wordpress theme development: Possible to have main theme files in subfolder?

I'm developing a theme locally and using Gulp to run tasks. My theme directory structure looks like this:
|- theme folder/
|- app/
|- css/
|- fonts/
|- images/
|- index.html
|- js/
|- scss/
|- dist/
|- optimized files from app/
|- all other standard WP theme files and subdirs
|- gulpfile.js
|- node_modules/
|- package.json
When WordPress loads the theme, I see a blank screen, which is to be expected. WP looks for the theme files in the top-level directory of the theme folder. Is it possible to point directly to the dist folder? If it helps, I'm using Flywheel for my local dev setup.
index.php, style.css (the main stylesheet where you declare theme's metadata), header.php and footer.php need to be placed in the root of your theme's folder. Every other files (assets, includes, et cetera) can live in their own subdirectory.
For more details, please read: Organizing Theme Files | Theme Developer Handbook.

use devtools imported packages in a shiny app

I am developing a page with devtools and using DESCRIPTION imports to load appropriate packages. I also added a Shiny app to my package structure (according to the article), so it looks as the following:
- mypacakge
|- inst
|- shiny-examples
|- myapp
|- ui.R
|- server.R
|- R
|- runExample.R
|- ...
|- DESCRIPTION
|- ...
Now, the shiny app works when I add the library instructions at the top of the ui/server files. Is there any way to not paste these instructions, but simply use the DESCRIPTION imported packages? And also, is there any way to make shiny app see package functions from in R folder without running devtools::load_all in Shiny?

How to change the path before injection

Is it possible to change the path of the injected file before injection occurs?
I am using Grunt/Bower/Connect/Wiredep, and my directory structure is:
www
|- dev-dist/
|- node_modules/
|- src/
|- vendor/
|- bower.json
|- Gruntfile.js
|- package.json
(Note: in my .bowerrc file I've added directory: vendor)
When I run the custom task grunt serve:dev it will create the directory dev-dist, I will then copy my index.html (only) to the folder, after which I run the task wiredep.
After running wiredep, the src paths to my dependencies are all prefixed with '../vendor/'. The problem is that when I run connect I have the option base: ['vendor', 'dev-dist', 'src']. When everything is served, the relative path to vendor doesn't make any sense because the vendor dir is already served at the root.
Is there a way I can modify the path to the injected files before wiredep injects them? (So I can remove the '../vendor')
What I would like to have happen is from the same workspace be able to run grunt serve:* and specify dev/stage/prod environments. This is why I did not want to serve the whole www directory.
Is there a way to exclude folders from being served in connect? (So instead of specifying base:[...], I can just exclude the stage-dist / prod-dist folders)
Thanks,
JD
You can use the option ignorePath with a regular expression
ignorePath: /\.\.\//,
from the wiredep to remove the ../ from the path that is getting injected. The configuration details are available over here https://github.com/taptapship/wiredep#configuration
I haven't used connect yet, so I am not sure of your second part of the question.

Copying files using SBT

I am using SBT for building a java project and have a requirement of copying text files (that are not resources, but used by java classes to read instead).
I am inexperienced with either SBT or Scala (needed for build.scala file)
Any help would be really appreciated.
For example, if my directory structure is:
test
|- files
|- one.text
|- main
|- java
|- Test.java
I want the one.text file available as well in the target folder once I execute an sbt goal like
sbt test
Following lines in your build.sbt should do the trick:
unmanagedResourceDirectories in Test <+= (baseDirectory) {_ / "files"}
unmanagedSourceDirectories in Test <+= (baseDirectory) {_ / "main" / "java"}
You have a non standard project layout though. If you can change it to a standard "maven style":
project/src/main/java
project/src/main/resources
project/src/test/java/{Test.java, ...}
project/src/test/resources/{one.text, ...}
sbt will do resource copying automatically.

Resources