Package: juliapkg
JuliaPkgDo you want to useJuliain your Python script/project/package?
No problem! JuliaPkg will help you out!Declare the version of Julia you require in ajuliapkg.jsonfile.Add any packages you need too.Calljuliapkg.resolve()et voila, your dependencies are there.Usejuliapkg.executable()to find the Julia executable andjuliapkg.project()to
find the project where the packages were installed.Virtual environments? PipEnv? Poetry? Conda? No problem! JuliaPkg will set up a
different project for each environment you work in, keeping your dependencies isolated.InstallpipinstalljuliapkgDeclare dependenciesFunctional interfacestatus(target=None)shows the status of dependencies.require_julia(version, target=None)declares that you require the given version of
Julia. Theversionis a Julia compat specifier, so1.5matches any1.*.*version at
least1.5.add(pkg, uuid, dev=False, version=None, path=None, url=None, rev=None, target=None)adds a required package. Its name and UUID are required.rm(pkg, target=None)remove a package.Note that these functions editjuliapkg.jsonbut do not actually install anything untilresolve()is called, which happens automatically inexecutable()andproject().Thetargetspecifies thejuliapkg.jsonfile to edit, or the directory containing it.
If not given, it will be your virtual environment or Conda environment if you are using one,
otherwise~/.pyjuliapkg.json.juliapkg.jsonYou can also editjuliapkg.jsondirectly if you like. Here is an example which requires
Julia v1..and the Example package v0.5.*:{"julia":"1","packages":{"Example":{"uuid":"7876af07-990d-54b4-ab0e-23690620f79a","version":"0.5"}}}Using Juliajuliapkg.executable()returns a compatible Julia executable.juliapkg.project()returns the project into which the packages have been installed.juliapkg.resolve(force=False)ensures all the depdencies are installed. You don't
normally need to do this because the other functions resolve automatically.DetailsConfigurationJuliaPkg does not generally need configuring, but for advanced usage the following options
are available. Options can be specified either as an environment variable or as an-Xoption topython. The-Xoption has higher precedence.Environment Variable-XOptionDescriptionPYTHON_JULIAPKG_EXE=<exe>-X juliapkg-exe=<exe>The Julia executable to use.PYTHON_JULIAPKG_PROJECT=<project>-X juliapkg-project=<project>The Julia project where pacakges are installed.PYTHON_JULIAPKG_OFFLINE=<yes/no>-X juliapkg-offline=<yes/no>Work in Offline Mode - does not install Julia or any packages.Which Julia gets used?JuliaPkg tries the following strategies in order to find Julia on your system:If the-X juliapkg-exeargument topythonis set, that is used.If the environment variablePYTHON_JULIAPKG_EXEis set, that is used.Ifjuliais in yourPATH, and is compatible, that is used.Ifjuliaupis in yourPATH, it is used to install a compatible version of Julia.Otherwise, JuliaPkg downloads a compatible version of Julia and installs it into the
Julia project.More strategies may be added in a future release.Where are Julia packages installed?JuliaPkg installs packages into a project whose location is determined by trying the
following strategies in order:If the-X juliapkg-projectargument topythonis set, that is used.If the environment variablePYTHON_JULIAPKG_PROJECTis set, that is used.If you are in a Python virtual environment or Conda environment, then{env}/julia_envsubdirectory is used.Otherwise~/.julia/environments/pyjuliapkgis used (respectsJULIA_DEPOT).More strategies may be added in a future release.Adding Julia dependencies to Python packagesJuliaPkg looks forjuliapkg.jsonfiles in many locations, namely:{project}/pyjuliapkgwhere project is as above (depending on your environment).Every directory and direct sub-directory insys.path.The last point means that if you put ajuliapkg.jsonfile in a package, then install that
package, then JuliaPkg will find those dependencies and install them.You can useadd,rmetc. above withtarget='/path/to/your/package'to modify the
dependencies of your package.Offline modeIf you set the environment variablePYTHON_JULIAPKG_OFFLINE=yes(or callpythonwith the
option-X juliapkg-offline=yes) then JuliaPkg will operate in offline mode. This means it
will not attempt to download Julia or any packages.Resolving will fail if Julia is not already installed. It is up to you to install any
required Julia packages.