Skip to main content

JuliaPkg

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Tests Codecov

Do you want to use Julia in your Python script/project/package? No problem! JuliaPkg will help you out!

  • Declare the version of Julia you require in a juliapkg.json file.
  • Add any packages you need too.
  • Call juliapkg.resolve() et voila, your dependencies are there.
  • Use juliapkg.executable() to find the Julia executable and juliapkg.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.

Install

pip install juliapkg

Declare dependencies

Functional interface

  • status(target=None) shows the status of dependencies.
  • require_julia(version, target=None) declares that you require the given version of Julia. The version is a Julia compat specifier, so 1.5 matches any 1.*.* version at least 1.5.
  • add(pkg, uuid=None, dev=False, version=None, path=None, subdir=None, url=None, rev=None, preferences=None, target=None) adds a required package.
    • version is a version compat specifier.
    • dev=True installs the package in dev mode.
    • path, subdir, url and rev specify the location of the package.
    • preferences is a dict of package preferences.
  • rm(pkg, target=None) removes a package.

Note that these functions edit juliapkg.json but do not actually install anything until resolve() is called, which happens automatically in executable() and project().

The target specifies the juliapkg.json file 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.json

You can also edit juliapkg.json directly 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"
        }
    }
}

Each package may also specify an optional "preferences" object; see add() above.

Command line interface

You can also use the CLI, some examples:

python -m juliapkg --help
python -m juliapkg add Example --version=0.5
python -m juliapkg resolve
python -m juliapkg status
python -m juliapkg run -E 'using Example; Example.hello("world")'
python -m juliapkg remove Example

Using Julia

  • juliapkg.executable() returns a compatible Julia executable.
  • juliapkg.project() returns the project into which the packages have been installed.
  • juliapkg.libjulia() returns the path to the libjulia library.
  • juliapkg.resolve(force=False, dry_run=False) ensures all the dependencies are installed. You don't normally need to do this because the other functions resolve automatically.
  • juliapkg.update(dry_run=False) updates the dependencies.

Details

Configuration

JuliaPkg 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 -X option to python. The -X option has higher precedence.

Environment Variable -X Option Description
PYTHON_JULIAPKG_EXE=<exe> -X juliapkg-exe=<exe> The Julia executable to use.
PYTHON_JULIAPKG_PROJECT=<project> -X juliapkg-project=<project> The Julia project where packages 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-exe argument to python is set, that is used.
  • If the environment variable PYTHON_JULIAPKG_EXE is set, that is used.
  • If julia is in your PATH, and is compatible, that is used.
  • If juliaup is in your PATH, 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-project argument to python is set, that is used.
  • If the environment variable PYTHON_JULIAPKG_PROJECT is set, that is used.
  • If you are in a Python virtual environment or Conda environment, then {env}/julia_env subdirectory is used.
  • Otherwise ~/.julia/environments/pyjuliapkg is used (respects JULIA_DEPOT).

More strategies may be added in a future release.

If the project is explicitly specified (with -X juliapkg-project or PYTHON_JULIAPKG_PROJECT) then it is considered "shared" and dependencies will only ever be added, not removed.

Adding Julia dependencies to Python packages

JuliaPkg looks for juliapkg.json files in many locations, namely:

  • {project}/pyjuliapkg where project is as above (depending on your environment).
  • Every installed package (looks through sys.path and sys.meta_path).

The last point means that if you put a juliapkg.json file in a package, then install that package, then JuliaPkg will find those dependencies and install them.

You can use add, rm etc. above with target='/path/to/your/package' to modify the dependencies of your package.

Offline mode

If you set the environment variable PYTHON_JULIAPKG_OFFLINE=yes (or call python with 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

juliapkg-0.1.25.tar.gz (25.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

juliapkg-0.1.25-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file juliapkg-0.1.25.tar.gz.

File metadata

  • Download URL: juliapkg-0.1.25.tar.gz
  • Upload date:
  • Size: 25.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for juliapkg-0.1.25.tar.gz
Algorithm Hash digest
SHA256 6ef636c5d62e1d9ff66e5a901ca0bde807553e8d74710d6aa61792cfd80f91d8
MD5 0d01e73b20b53ef54e70ff3422177ed9
BLAKE2b-256 f404319bdb7772e25baa72e4610c33a5708a6a2a0f8382a64e0725065e7886dc

See more details on using hashes here.

File details

Details for the file juliapkg-0.1.25-py3-none-any.whl.

File metadata

  • Download URL: juliapkg-0.1.25-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"20.04","id":"focal","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for juliapkg-0.1.25-py3-none-any.whl
Algorithm Hash digest
SHA256 0c04922c54ffefa82fd35780809dc76e2c4ee4eda67770016ee136c7a06e826b
MD5 84772c469b88aca3511803afec5886f6
BLAKE2b-256 585ef26e8157176844e3a3bc3872e43fb06c7064c5d9b2ba02d827bd1708f488

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.26

2 files

This release

0.1.25 This release

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page